virgil_sdk.jwt package

Submodules

virgil_sdk.jwt.jwt module

class virgil_sdk.jwt.jwt.Jwt(jwt_header_content=None, jwt_body_content=None, signature_data=None)[source]

Bases: virgil_sdk.jwt.abstractions.access_token.AccessToken

The Jwt class implements abstract AccessToken in terms of Virgil JWT.

classmethod from_string(jwt_string)[source]

Initializes a new instance of the Jwt class using its string representation.

Parameters:jwt_string – String representation of signed jwt. It must be equal to: base64UrlEncode(JWT Header) + “.” + base64UrlEncode(JWT Body) “.” + base64UrlEncode(Jwt Signature).
Returns:Initialized instance of Jwt.
Raises:ValueError – Wrong jwt format.
identity

Jwt identity.

is_expired(expiration_timestamp=None)[source]

Whether or not token is expired.

signature_data

Gets a digital signature of jwt.

to_string()[source]

Jwt string representation.

unsigned_data

String representation of jwt without signature. It equals to: base64UrlEncode(JWT Header) + “.” + base64UrlEncode(JWT Body)

virgil_sdk.jwt.jwt_body_content module

class virgil_sdk.jwt.jwt_body_content.JwtBodyContent(app_id, identity, issued_at, expires_at, data)[source]

Bases: object

JwtBodyContent represents content of Jwt.

expires_at

When jwt expire.

classmethod from_json(json_loaded_dict)[source]

Initializes a new instance of the JwtBodyContent from json representation.

identity

Jwt identity.

identity_prefix
issuer

Jwt issuer.

json

JwtBodyContent json representation.

subject_prefix

virgil_sdk.jwt.jwt_generator module

class virgil_sdk.jwt.jwt_generator.JwtGenerator(app_id, api_key, api_public_key_id, lifetime, access_token_signer)[source]

Bases: object

The JwtGenerator class implements Jwt generation.

Parameters:
generate_token(identity, data=None)[source]

Generates new JWT using specified identity and additional data.

Parameters:
  • identity – Identity to generate with.
  • data – Dictionary with additional data which will be kept in jwt body.
Returns:

A new instance of Jwt.

virgil_sdk.jwt.jwt_header_content module

class virgil_sdk.jwt.jwt_header_content.JwtHeaderContent(algorithm, key_id, access_token_type='JWT', content_type='virgil-jwt;v=1')[source]

Bases: object

JwtHeaderContent represents header of Jwt

ACCESS_TOKEN_TYPE = 'JWT'
CONTENT_TYPE = 'virgil-jwt;v=1'
access_token_type

Access token type.

algorithm

Signature algorithm.

content_type

Access token content type.

classmethod from_json(json_loaded_dict)[source]

Initializes a new instance of the JwtHeaderContent from json representation.

Parameters:json_loaded_dict – JwtHeaderContent json representation
Returns:A new instance of JwtHeaderContent.
json

JwtHeaderContent json representation.

key_id

Id of public key which is used for jwt signature verification.

virgil_sdk.jwt.jwt_verifier module

class virgil_sdk.jwt.jwt_verifier.JwtVerifier(access_token_signer, api_public_key, api_public_key_id)[source]

Bases: object

The JwtVerifier provides verification for Jwt.

verify_token(jwt_token)[source]

To verify specified token.

Parameters:jwt_token – An instance of Jwt to be verified.
Returns:True if token is verified, otherwise False.

virgil_sdk.jwt.token_context module

class virgil_sdk.jwt.token_context.TokenContext(identity, operation, force_reload=False, service=None)[source]

Bases: object

TokenContext provides payload for CallbackJwtProvider.get_token(TokenContext)

force_reload

You can set up token cache in CachingCallbackProvider.get_token and reset cached token if True.

identity

Identity that should be used in access token.

operation

Operation for which token is needed.

service

Service for which token is needed.

Module contents