Validator
- class scitokens.Validator[source]
Bases:
objectValidate 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
claimencountered in a token,validate_opobject will be called with the following signature::.validate(token[, critical_claims])Validate the claims of a token.
Methods Documentation
- add_validator(claim, validate_op)[source]
Add a validation callback for a given claim. When the given
claimencountered in a token,validate_opobject will be called with the following signature:>>> validate_op(value)
where
valueis the value of the token’s claim converted to a python object.The validator should return
Trueif the value is acceptable andFalseotherwise.
- validate(token, critical_claims=None)[source]
Validate the claims of a token.
This will iterate through all claims in the given
SciTokenand determine whether all claims a valid, given the current set of validators.If
critical_claimsis 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
Trueif the token is valid.