Class specific implementation of from_jwt which should take jwt components and return
        and instance of this Class with jwt information loaded.
        :return: Jwt object containing the headers, payload and key
553175
def _from_jwt(cls, headers, payload, key=None):
        
        jwt = Jwt(
            secret_key=key,
            issuer=payload.get('iss', None),
            subject=payload.get('sub', None),
            algorithm=headers.get('alg', None),
            valid_until=payload.get('exp', None),
            nbf=payload.get('nbf', None),
        )
        jwt.__decoded_payload = payload
        jwt.__decoded_headers = headers
        return jwt
202831
def process_request(self, request):
        
        use_jwt_cookie_requested = request.META.get(USE_JWT_COOKIE_HEADER)
        header_payload_cookie = request.COOKIES.get(jwt_cookie_header_payload_name())
        signature_cookie = request.COOKIES.get(jwt_cookie_signature_name())

        if not use_jwt_cookie_requested:
            metric_value = 'not-requested'
        elif header_payload_cookie and signature_cookie:
            # Reconstitute JWT auth cookie if split cookies are available and jwt cookie
            # authentication was requested by the client.
            request.COOKIES[jwt_cookie_name()] = '{}{}{}'.format(
                header_payload_cookie,
                JWT_DELIMITER,
                signature_cookie,
            )
            metric_value = 'success'
        elif header_payload_cookie or signature_cookie:
            # Log unexpected case of only finding one cookie.
            if not header_payload_cookie:
                log_message, metric_value = self._get_missing_cookie_message_and_metric(
                    jwt_cookie_header_payload_name()
                )
            if not signature_cookie:
                log_message, metric_value = self._get_missing_cookie_message_and_metric(
                    jwt_cookie_signature_name()
                )
            log.warning(log_message)
        else:
            metric_value = 'missing-both'

        monitoring.set_custom_metric('request_jwt_cookie', metric_value)
193101
def from_dict(cls, data):
        
        auth_info = _AuthenticationInformation.from_dict(data.get("auth_info"))
        instance = cls(auth_info=auth_info)
        instance.user_id_hash_type = data.get("hash_type")
        instance.attributes = data.get("attributes", {})
        instance.user_id = data.get("user_id")
        instance.requester = data.get("requester")
        return instance
248591
def get_jwk(header, payload)
      kid = header['kid']

      # cache hit
      return JWKS_CACHE[kid] if JWKS_CACHE[kid]
  
      # fetch jwk
      logger.info("[Okta::Jwt] Fetching public key: kid => #{kid} ...") if logger
      jwks_response = client(payload['iss']).get do |req|
        req.url get_metadata(payload)['jwks_uri']
      end
      jwk = JSON.parse(jwks_response.body)['keys'].find do |key|
        key.dig('kid') == kid
      end
  
      # cache and return the key
      jwk.tap{JWKS_CACHE[kid] = jwk}
    end
962201
def _decrypt(self, rj, token):
        
        if self.iss:
            keys = self.key_jar.get_jwt_decrypt_keys(rj.jwt, aud=self.iss)
        else:
            keys = self.key_jar.get_jwt_decrypt_keys(rj.jwt)
        return rj.decrypt(token, keys=keys)
225110
def get_jwt_key_data():
    
    global __jwt_data

    if __jwt_data:
        return __jwt_data

    from cloud_inquisitor import config_path
    from cloud_inquisitor.config import dbconfig

    jwt_key_file = dbconfig.get('jwt_key_file_path', default='ssl/private.key')
    if not os.path.isabs(jwt_key_file):
        jwt_key_file = os.path.join(config_path, jwt_key_file)

    with open(os.path.join(jwt_key_file), 'r') as f:
        __jwt_data = f.read()

    return __jwt_data
717320
def getPayloadStruct(self, attributes, objType):
        
        payload = {self.payloadObj: attributes,
                   objType + "_class":
                       {self.payloadObj: attributes}}
        return payload
302969
def RequestPacket(self):
        
        attr = self._PktEncodeAttributes()

        if self.authenticator is None:
            self.authenticator = self.CreateAuthenticator()

        if self.id is None:
            self.id = self.CreateID()

        header = struct.pack('!BBH16s', self.code, self.id,
            (20 + len(attr)), self.authenticator)

        return header + attr
659214
def get_jwt(self, request):
        
        try:
            authorization = request.authorization
        except ValueError:
            return None
        if authorization is None:
            return None
        authtype, token = authorization
        if authtype.lower() != self.auth_header_prefix.lower():
            return None
        return token
82159
def dict_to_instance(self, content):
        
        klass = self.schema['title']
        cls = get_model_class(klass, api=self.__api__)
        # jdict = json.loads(content, encoding="utf-8")
        ### check if we have a response
        properties_dict = content[self.schema['title']][self.schema['title']]
        #@todo: find a way to handle the data
        # validation fails if the none values are not removed
        new_dict = helpers.remove_properties_containing_None(properties_dict)
        obj = cls(new_dict)
        #obj.links = content[self.schema['title']]['links']
        return obj
311876
def get_instance(self, payload):
        
        return MemberInstance(
            self._version,
            payload,
            account_sid=self._solution['account_sid'],
            queue_sid=self._solution['queue_sid'],
        )
299212
def extract_jwt_token(self, token):
        
        # Note: we disable exp verification because we will do it ourselves
        with InvalidTokenHeader.handle_errors('failed to decode JWT token'):
            data = jwt.decode(
                token,
                self.encode_key,
                algorithms=self.allowed_algorithms,
                options={'verify_exp': False},
            )
        self._validate_jwt_data(data, access_type=AccessType.access)
        return data
817686
def core__decode_token token
      begin
        body = JWT.decode(token, Rails.application.secrets.secret_key_base,
                          true, algorithm: 'HS256')[0]
        return HashWithIndifferentAccess.new body
      rescue => exception
        return nil
      end
    end
248691
def generate_session_token(secret_key, **payload):
    
    return jwt.encode(payload, secret_key, algorithm=token_encryption_algorithm()).decode('utf-8')
152659
function get_jwt_token(ctx)
{
	// Parses "Authorization: Bearer ${token}"
	if (ctx.header.authorization)
	{
		const match = ctx.header.authorization.match(/^Bearer (.+)$/i)

		if (match)
		{
			return match[1]
		}
	}

	// (doesn't read cookies anymore to protect users from CSRF attacks)
	// // Tries the "authentication" cookie
	// if (ctx.cookies.get('authentication'))
	// {
	// 	return ctx.cookies.get('authentication')
	// }
}
48480
def to_dict(self):
        
        jdict = {
            'user': self.user,
            'summary': self.summary,
            'body': self.body,
            'markup': self.markup,
            'url': self.url,
            'timestamp': self.timestamp
            }
        return jdict
1356813
def token(self):
        
        prefixes = ("Bearer", "Token")
        auth_header = self.headers.get("Authorization")

        if auth_header is not None:
            for prefix in prefixes:
                if prefix in auth_header:
                    return auth_header.partition(prefix)[-1].strip()

        return auth_header