Give the user with user_full_name the auth_role permissions on the remote project with project_name.
        :param args Namespace arguments parsed from the command line
5320
def run(self, args):
        
        email = args.email                  # email of person to give permissions, will be None if username is specified
        username = args.username            # username of person to give permissions, will be None if email is specified
        auth_role = args.auth_role          # type of permission(project_admin)
        project = self.fetch_project(args, must_exist=True, include_children=False)
        user = self.remote_store.lookup_or_register_user_by_email_or_username(email, username)
        self.remote_store.set_user_project_permission(project, user, auth_role)
        print(u'Gave user {} {} permissions for project {}.'.format(user.full_name, auth_role, project.name))
514187
public CompletableFuture<Revision> addPerUserPermission(Author author, String projectName,
                                                            String repoName, User member,
                                                            Collection<Permission> permission) {
        requireNonNull(author, "author");
        requireNonNull(projectName, "projectName");
        requireNonNull(repoName, "repoName");
        requireNonNull(member, "member");
        requireNonNull(permission, "permission");

        return getProject(projectName).thenCompose(project -> {
            ensureProjectMember(project, member);
            return addPermissionAtPointer(author, projectName,
                                          perUserPermissionPointer(repoName, member.id()), permission,
                                          "Add permission of '" + member.id() +
                                          "' as '" + permission + "' to the project " + projectName);
        });
    }
674090
def delete_permission(self, vname, username):
        
        vname = quote(vname, '')
        path = Client.urls['vhost_permissions'] % (vname, username)
        return self._call(path, 'DELETE')
769023
def delete_user_role(self, user, role):
        
        self.project_service.set_auth(self._token_project)
        self.project_service.delete_user_role(user, role)
887814
def global_permission_set(self):
        ''''''
        only_admins_create_admins = Or(
            AllowAdmin,
            And(
                ObjAttrTrue(
                    lambda r, _: r.data.get('admin') is not True),
                Or(
                    AllowPermission('org:admin')
                )
            )
        )

        return And(
            AllowOnlyAuthenticated,
            Or(
                Not(AllowCreate),
                only_admins_create_admins
            )
        )
929258
def register_add_user_command(self, add_user_func):
        
        description = "Gives user permission to access a remote project."
        add_user_parser = self.subparsers.add_parser('add-user', description=description)
        add_project_name_or_id_arg(add_user_parser, help_text_suffix="add a user to")
        user_or_email = add_user_parser.add_mutually_exclusive_group(required=True)
        add_user_arg(user_or_email)
        add_email_arg(user_or_email)
        _add_auth_role_arg(add_user_parser, default_permissions='project_admin')
        add_user_parser.set_defaults(func=add_user_func)
1255326
def main(*argv):
    
    try:
        adminUsername = argv[0]
        adminPassword = argv[1]
        siteURL = argv[2]
        deleteUser = argv[3]
        #   Logic
        #
        sh = arcrest.AGOLTokenSecurityHandler(adminUsername, adminPassword)
        admin = arcrest.manageorg.Administration(securityHandler=sh)
        community = admin.community
        user = community.user
        res = user.deleteUser(username=deleteUser)
        if res.has_key('success'):
            arcpy.SetParameterAsText(4, str(res['success']).lower() == "true")
        else:
            arcpy.SetParameterAsText(4, False)
        del sh
        del admin
        del community
        del user
        del res
    except arcpy.ExecuteError:
        line, filename, synerror = trace()
        arcpy.AddError("error on line: %s" % line)
        arcpy.AddError("error in file name: %s" % filename)
        arcpy.AddError("with error message: %s" % synerror)
        arcpy.AddError("ArcPy Error Message: %s" % arcpy.GetMessages(2))
    except FunctionError, f_e:
        messages = f_e.args[0]
        arcpy.AddError("error in function: %s" % messages["function"])
        arcpy.AddError("error on line: %s" % messages["line"])
        arcpy.AddError("error in file name: %s" % messages["filename"])
        arcpy.AddError("with error message: %s" % messages["synerror"])
        arcpy.AddError("ArcPy Error Message: %s" % messages["arc"])
    except:
        line, filename, synerror = trace()
        arcpy.AddError("error on line: %s" % line)
        arcpy.AddError("error in file name: %s" % filename)
        arcpy.AddError("with error message: %s" % synerror)
1081003
def get_auth_scope(cls, instance_config):
        
        auth_scope = instance_config.get('auth_scope')
        if not auth_scope:
            return None

        if not auth_scope.get('project'):
            raise IncompleteAuthScope()

        if auth_scope['project'].get('name'):
            # We need to add a domain scope to avoid name clashes. Search for one. If not raise IncompleteAuthScope
            if not auth_scope['project'].get('domain', {}).get('id'):
                raise IncompleteAuthScope()
        else:
            # Assume a unique project id has been given
            if not auth_scope['project'].get('id'):
                raise IncompleteAuthScope()

        return auth_scope
261445
def get_permissions(self, virtual_host):
        
        virtual_host = quote(virtual_host, '')
        return self.http_client.get(API_VIRTUAL_HOSTS_PERMISSION %
                                    (
                                        virtual_host
                                    ))
833707
def space_set_acl(args):
    
    acl_updates = [{"email": user,
                   "accessLevel": args.role} for user in args.users]
    r = fapi.update_workspace_acl(args.project, args.workspace, acl_updates)
    fapi._check_response_code(r, 200)
    errors = r.json()['usersNotFound']

    if len(errors):
        eprint("Unable to assign role for unrecognized users:")
        for user in errors:
            eprint("\t{0}".format(user['email']))
        return 1

    if fcconfig.verbosity:
        print("Successfully updated {0} role(s)".format(len(acl_updates)))

    return 0
161494
def register_list_auth_roles_command(self, list_auth_roles_func):
        
        description = "List authorization roles for use with add_user command."
        list_auth_roles_parser = self.subparsers.add_parser('list-auth-roles', description=description)
        list_auth_roles_parser.set_defaults(func=list_auth_roles_func)
904021
def authorize(self, request, *args, **kwargs):
        
        user = request.user
        if not user.is_authenticated or not user.socialaccount_set.exists():
            raise PermissionDenied()
1166927
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_add_post(obj, user)
590976
def unshare_project(project_id, usernames,**kwargs):
    

    user_id = kwargs.get('user_id')
    proj_i = _get_project(project_id)
    proj_i.check_share_permission(user_id)

    for username in usernames:
        user_i = _get_user(username)
        #Set the owner ship on the network itself
        proj_i.unset_owner(user_i.id, write=write, share=share)
    db.DBSession.flush()
1314633
def users_list(self, permission_set=None, role=None, **kwargs):
        ""
        api_path = "/api/v2/users.json"
        api_query = {}
        if "query" in kwargs.keys():
            api_query.update(kwargs["query"])
            del kwargs["query"]
        if permission_set:
            api_query.update({
                "permission_set": permission_set,
            })
        if role:
            api_query.update({
                "role": role,
            })
        return self.call(api_path, query=api_query, **kwargs)
1287536
def get_users_in_project(self, projectname):
        
        cmd = ["list", "assoc", "where", "account=%s" % projectname]
        results = self._read_output(cmd)

        user_list = []
        for result in results:
            if result["User"] != "":
                user_list.append(result["User"])
        return user_list
45754
def _add_project_filter_auth_role_arg(arg_parser):
    
    help_text = "Filters project listing to just those projects with the specified role. "
    help_text += "See command list_auth_roles for AuthRole values."
    arg_parser.add_argument("--auth-role",
                            metavar='AuthRole',
                            type=to_unicode,
                            dest='auth_role',
                            help=help_text,
                            default=None)