How to use the scitokens.SciToken function in scitokens

To help you get started, we’ve selected a few scitokens examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PanDAWMS / panda-server / pandaserver / server / panda.py View on Github external
def __init__(self, env, tmpLog):
            # environ
            self.subprocess_env = env
            # header
            self.headers_in = {}
            # content-length
            if 'CONTENT_LENGTH' in self.subprocess_env:
                self.headers_in["content-length"] = self.subprocess_env['CONTENT_LENGTH']
            # scitoken
            try:
                if panda_config.token_authType == 'scitokens' and 'HTTP_AUTHORIZATION' in env:
                    serialized_token = env['HTTP_AUTHORIZATION'].split()[1]
                    token = scitokens.SciToken.deserialize(serialized_token, audience=panda_config.token_audience)
                    # check issuer
                    if 'iss' not in token:
                        tmpLog.error('issuer is undefined')
                    elif panda_config.token_issuers != '' and token['iss'] not in panda_config.token_issuers.split(','):
                        tmpLog.error('invalid issuer {0}'.format(token['iss']))
                    else:
                        for c, v in token.claims():
                            self.subprocess_env['SCI_TOKEN_{0}'.format(str(c))] = str(v)
                        # use sub and scope as DN and FQAN
                        if 'SSL_CLIENT_S_DN' not in self.subprocess_env:
                            self.subprocess_env['SSL_CLIENT_S_DN'] = str(token['sub'])
                            i = 0
                            for scope in token['scope'].split():
                                if scope.startswith('role:'):
                                    self.subprocess_env['GRST_CRED_SCI_TOKEN_{0}'.format(i)] = 'VOMS ' + str(scope.split(':')[-1])
                                    i += 1

scitokens

SciToken reference implementation library

Apache-2.0
Latest version published 1 year ago

Package Health Score

45 / 100
Full package analysis

Popular scitokens functions