Validator

class scitokens.Validator[source]

Bases: object

Validate the contents of a SciToken.

Given a SciToken, validate the contents of its claims. Unlike verification, which checks that the token is correctly signed, validation provides an easy-to-use interface that ensures the claims in the token are understood by the user.

Methods Summary

__call__(token)

Call self as a function.

add_validator(claim, validate_op)

Add a validation callback for a given claim. When the given claim encountered in a token, validate_op object will be called with the following signature::.

validate(token[, critical_claims])

Validate the claims of a token.

Methods Documentation

__call__(token)[source]

Call self as a function.

add_validator(claim, validate_op)[source]

Add a validation callback for a given claim. When the given claim encountered in a token, validate_op object will be called with the following signature:

>>> validate_op(value)

where value is the value of the token’s claim converted to a python object.

The validator should return True if the value is acceptable and False otherwise.

validate(token, critical_claims=None)[source]

Validate the claims of a token.

This will iterate through all claims in the given SciToken and determine whether all claims a valid, given the current set of validators.

If critical_claims is specified, then validation will fail if one or more claim in this list is not present in the token.

This will throw an exception if the token is invalid and return True if the token is valid.