Returns the ARN user or role whose credentials are used to call the API.
        Returns:
            (str): The ARN user or role
6736
def get_caller_identity_arn(self):
        
        assumed_role = self.boto_session.client('sts').get_caller_identity()['Arn']

        if 'AmazonSageMaker-ExecutionRole' in assumed_role:
            role = re.sub(r'^(.+)sts::(\d+):assumed-role/(.+?)/.*$', r'\1iam::\2:role/service-role/\3', assumed_role)
            return role

        role = re.sub(r'^(.+)sts::(\d+):assumed-role/(.+?)/.*$', r'\1iam::\2:role/\3', assumed_role)

        # Call IAM to get the role's path
        role_name = role[role.rfind('/') + 1:]
        try:
            role = self.boto_session.client('iam').get_role(RoleName=role_name)['Role']['Arn']
        except ClientError:
            LOGGER.warning("Couldn't call 'get_role' to get Role ARN from role name {} to get Role path."
                           .format(role_name))

        return role
743951
def get_user(request):
    
    if settings.LOCKDOWN and hasattr(request, 'user'):
        if request.user.is_authenticated:
            user = request.user.username
        else:
            # This may happen with crafted requests
            user = ''
    else:
        user = getattr(settings, 'DEFAULT_USER', getpass.getuser())

    return user
814173
def custom_role(self):
        
        if self.api and self.custom_role_id:
            return self.api._get_custom_role(self.custom_role_id)
1305123
def _get_roles_for_request(request, application):
        
        roles = application.get_roles_for_person(request.user)

        if common.is_admin(request):
            roles.add("is_admin")
            roles.add('is_authorised')

        return roles
987611
def get_roles(server_context, container_path=None):
    
    url = server_context.build_url(security_controller, 'getRoles.api', container_path=container_path)
    return server_context.make_request(url, None)
24449
def user_roles(self):
        
        # We do here some lazy loading.
        if not self._user_roles:
            self._user_roles = UserRoleManager(self)
        return self._user_roles
1048603
def accepts_roles(*roles):
    

    def wrapper(f):
        @functools.wraps(f)
        def wrapped(*args, **kwargs):
            if is_authenticated():
                if not flask_login.current_user.has_any_roles(*roles):
                    return abort(403)
            else:
                return abort(401)
            return f(*args, **kwargs)

        return wrapped

    return wrapper
412563
def get_authorization_user(self, **kwargs):
        """"""
        if self.authorization_user is not None:
            return self.authorization_user

        self.authorization_user = self.request.user
        return self.request.user
1368673
def get_user_roles(self):
        
        if self.is_anonymous_user():
            return []
        current_user = ploneapi.user.get_current()
        return ploneapi.user.get_roles(user=current_user)
245143
def role(args):
    
    src_acct, src_username, dst_acct, dst_role = \
        "205134639408 htang 114692162163 mvrad-datasci-role".split()

    p = OptionParser(role.__doc__)
    p.add_option("--profile", default="mvrad-datasci-role", help="Profile name")
    p.add_option('--device',
                    default="arn:aws:iam::" + src_acct + ":mfa/" + src_username,
                    metavar='arn:aws:iam::123456788990:mfa/dudeman',
                    help="The MFA Device ARN. This value can also be "
                    "provided via the environment variable 'MFA_DEVICE' or"
                    " the ~/.aws/credentials variable 'aws_mfa_device'.")
    p.add_option('--duration',
                    type=int, default=3600,
                    help="The duration, in seconds, that the temporary "
                            "credentials should remain valid. Minimum value: "
                            "900 (15 minutes). Maximum: 129600 (36 hours). "
                            "Defaults to 43200 (12 hours), or 3600 (one "
                            "hour) when using '--assume-role'. This value "
                            "can also be provided via the environment "
                            "variable 'MFA_STS_DURATION'. ")
    p.add_option('--assume-role', '--assume',
                    default="arn:aws:iam::" + dst_acct + ":role/" + dst_role,
                    metavar='arn:aws:iam::123456788990:role/RoleName',
                    help="The ARN of the AWS IAM Role you would like to "
                    "assume, if specified. This value can also be provided"
                    " via the environment variable 'MFA_ASSUME_ROLE'")
    p.add_option('--role-session-name',
                    help="Friendly session name required when using "
                    "--assume-role",
                    default=getpass.getuser())
    p.add_option('--force',
                    help="Refresh credentials even if currently valid.",
                    action="store_true")
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    # Use a config to check the expiration of session token
    config = get_config(AWS_CREDS_PATH)
    validate(opts, config)
618184
def current_access(self):
        
        return self.access_for(actor=current_auth.actor, anchors=current_auth.anchors)
973509
def currentuser(self):
        
        request = requests.get(
            '{0}/api/v3/user'.format(self.host),
            headers=self.headers, verify=self.verify_ssl, auth=self.auth, timeout=self.timeout)

        return request.json()
622025
def get_user(user=None):
    
    if user is None:
        # Return the current authenticated user
        user = getSecurityManager().getUser()
    elif isinstance(user, MemberData):
        # MemberData wrapped user -> get the user object
        user = user.getUser()
    elif isinstance(user, basestring):
        # User ID -> get the user
        user = get_member_by_login_name(get_portal(), user, False)
        if user:
            user = user.getUser()
    return user
51594
def get_execution_role(sagemaker_session=None):
    
    if not sagemaker_session:
        sagemaker_session = Session()
    arn = sagemaker_session.get_caller_identity_arn()

    if ':role/' in arn:
        return arn
    message = 'The current AWS identity is not a role: {}, therefore it cannot be used as a SageMaker execution role'
    raise ValueError(message.format(arn))
651734
def user_is(role, get_user=import_user):
    
    def wrapper(func):
        @wraps(func)
        def inner(*args, **kwargs):
            from .models import Role
            current_user = get_user()
            if role in current_user.roles:
                return func(*args, **kwargs)
            raise Forbidden("You do not have access")
        return inner
    return wrapper
971019
def Credentials(self):
		

		return(clc.v2.API.Call('GET','servers/%s/%s/credentials' % (self.alias,self.name),session=self.session))
853287
function getRole(user) {
      user = user || getCurrentUser();
      return _.find(userRoles, {role: user.role});
    }