Documentation ¶
Index ¶
- Constants
- func InitializeContext(ctx context.Context) context.Context
- type ContextKey
- type Session
- func (s *Session) ConfigureContentEncryptionAlgorithm(ctx context.Context, alg string) error
- func (s *Session) ConfigureJSONPayload(ctx context.Context, props map[string]interface{}) error
- func (s *Session) ConfigureKeyEncryptionAlgorithm(ctx context.Context, alg string) error
- func (s *Session) ConfigurePayloadWithContentType(ctx context.Context, payload, contentType string)
- func (s *Session) ConfigurePrivateKey(ctx context.Context, privateKeyPEM string) error
- func (s *Session) ConfigurePublicKey(ctx context.Context, publicKeyPEM string) error
- func (s *Session) ConfigureSignatureAlgorithm(ctx context.Context, alg string) error
- func (s *Session) ConfigureSymmetricKey(ctx context.Context, symmetricKey string)
- func (s *Session) GenerateEncryptedJWTInContext(ctx context.Context, ctxtKey string) error
- func (s *Session) GenerateSignedEncryptedJWTInContext(ctx context.Context, ctxtKey string) error
- func (s *Session) GenerateSignedJWTInContext(ctx context.Context, ctxtKey string) error
- func (s *Session) ProcessEncryptedJWT(ctx context.Context, token string) error
- func (s *Session) ProcessSignedEncryptedJWT(ctx context.Context, token string) error
- func (s *Session) ProcessSignedJWT(ctx context.Context, token string) error
- func (s *Session) ValidateInvalidJWT(ctx context.Context, expectedError string) error
- func (s *Session) ValidateJWT(ctx context.Context) error
- func (s *Session) ValidateJWTRequirements() error
- func (s *Session) ValidatePayloadJSONProperties(ctx context.Context, expectedPayload map[string]interface{}) error
- type Steps
Constants ¶
const ( // TypeJWT for signed tokens in typ header. TypeJWT = "JWT" // TypeJWE for encrypted tokens in typ header. TypeJWE = "JWE" // ContentTypeJWT for signed encrypted tokens where the encrypted token will include // a cty header with this value. ContentTypeJWT = "JWT" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey defines a type to store the JWT session in context.Context.
type Session ¶
type Session struct { Token string Payload []byte ContentType string SignedMessage *jws.Message EncryptedMessage *jwe.Message SignatureAlgorithm jwa.SignatureAlgorithm KeyEncryptionAlgorithm jwa.KeyEncryptionAlgorithm ContentEncryptionAlgorithm jwa.ContentEncryptionAlgorithm PublicKey interface{} PrivateKey interface{} }
Session contains the information of a JWT session.
func GetSession ¶
GetSession returns the HTTP session stored in context. Note that the context should be previously initialized with InitializeContext function.
func (*Session) ConfigureContentEncryptionAlgorithm ¶
ConfigureContentEncryptionAlgorithm configures a content encryption algorithm for the JWT (JWE).
func (*Session) ConfigureJSONPayload ¶
ConfigureJSONPayload configures the JWT payload with a map of properties.
func (*Session) ConfigureKeyEncryptionAlgorithm ¶
ConfigureKeyEncryptionAlgorithm configures a key encryption algorithm for the JWT (JWE).
func (*Session) ConfigurePayloadWithContentType ¶
func (s *Session) ConfigurePayloadWithContentType( ctx context.Context, payload, contentType string, )
ConfigurePayloadWithContentType configures the payload and the content type (cty header).
func (*Session) ConfigurePrivateKey ¶
ConfigurePrivateKey configures the private key to sign a JWT token or to decrypt a JWE token.
func (*Session) ConfigurePublicKey ¶
ConfigurePublicKey configures the public key to verify the signature of a JWT token or to encrypt a JWE token.
func (*Session) ConfigureSignatureAlgorithm ¶
ConfigureSignatureAlgorithm configures a signature algorithm for the JWT (JWS).
func (*Session) ConfigureSymmetricKey ¶
ConfigureSymmetricKey configures the symmetric key. It sets this key as public and private key.
func (*Session) GenerateEncryptedJWTInContext ¶
GenerateEncryptedJWTInContext builds a JWT with encrypted payload and stores it in the context.
func (*Session) GenerateSignedEncryptedJWTInContext ¶
GenerateSignedEncryptedJWTInContext builds a JWT with signed encrypted payload and stores it in the context. The payload is signed first. Then the whole JWT is considered as payload for encryption phase. The content type header (cty) of the final token is set to JWT.
func (*Session) GenerateSignedJWTInContext ¶
GenerateSignedJWTInContext builds a JWT with signed payload and stores it in the context.
func (*Session) ProcessEncryptedJWT ¶
ProcessEncryptedJWT reads an encrypted JWT (JWE) and stores in the session the token, encrypted message and payload. There is no validation method for encrypted tokens.
func (*Session) ProcessSignedEncryptedJWT ¶
ProcessSignedEncryptedJWT reads a signed encrypted JWT and stores in the session the embedded signed token, the encrypted message, the signed message and the signed payload. Note that this token expects that a signed JWT token is the payload of a JWE token.
func (*Session) ProcessSignedJWT ¶
ProcessSignedJWT reads a signed JWT and stores the data in the session. This method does not validate the token; use ValidateJWT for this purpose.
func (*Session) ValidateInvalidJWT ¶
ValidateInvalidJWT checks that the token is invalid (the claims and the signature of the token). Note that JWE tokens are not validated.
func (*Session) ValidateJWT ¶
ValidateJWT checks that the token is valid (the claims and the signature of the token). Note that JWE tokens are not validated.
func (*Session) ValidateJWTRequirements ¶ added in v0.16.0
type Steps ¶
type Steps struct { }
Steps type is responsible to initialize the JWT steps in godog framework.
func (Steps) InitializeSteps ¶
InitializeSteps adds JWT steps to the scenario context. It implements StepsInitializer interface. It returns a new context (context is immutable) with the JWT Context.