Documentation
¶
Index ¶
- Constants
- func AddJWTToTheIncomingContext(ctx context.Context, jwtToken string) context.Context
- func AddJWTToTheOutgoingContext(ctx context.Context, jwtToken string) context.Context
- func CreateContextWithJWT(tb testing.TB) (context.Context, context.CancelFunc)
- func CreateContextWithTimeoutWithJWT(tb testing.TB, timeout time.Duration) (context.Context, context.CancelFunc)
- func CreateIncomingContextWithJWT(tb testing.TB) (context.Context, context.CancelFunc)
- func CreateIncomingContextWithTimeoutWithJWT(tb testing.TB, timeout time.Duration) (context.Context, context.CancelFunc)
- func CreateJWT(tb testing.TB) (string, string, error)
- func CreateJWTWithClaims(tb testing.TB, claims *jwt.MapClaims) (string, string, error)
- func CreateJWTWithReadRole(tb testing.TB) (string, string, error)
- func CreateJWTWithWriteRole(tb testing.TB) (string, string, error)
Constants ¶
const ( SharedSecretKey = "SHARED_SECRET_KEY" AuthKey = "authorization" BearerPrefixLowercase = "bearer " )
Variables ¶
This section is empty.
Functions ¶
func CreateContextWithJWT ¶
CreateContextWithJWT can be used only with test clients, which send the request to the server.
func CreateContextWithTimeoutWithJWT ¶
func CreateContextWithTimeoutWithJWT(tb testing.TB, timeout time.Duration) (context.Context, context.CancelFunc)
CreateContextWithTimeoutWithJWT can be used only with test clients, which send the request to the server.
func CreateIncomingContextWithJWT ¶
CreateIncomingContextWithJWT can be used to test the actual call, which performs the authorization.
func CreateIncomingContextWithTimeoutWithJWT ¶
func CreateIncomingContextWithTimeoutWithJWT(tb testing.TB, timeout time.Duration) (context.Context, context.CancelFunc)
CreateIncomingContextWithTimeoutWithJWT can be used to test the actual call, which performs the authorization.
func CreateJWT ¶
CreateJWT returns random signing key and JWT token (HS256 encoded) in a string with both roles, read and write. Only 1 token can persist in the system (otherwise, env variable holding secret key would be re-written).
func CreateJWTWithClaims ¶
CreateJWTWithClaims returns random signing key and JWT token (HS256 encoded) in a string with defined claims.
func CreateJWTWithReadRole ¶
CreateJWTWithReadRole returns random signing key and JWT token (HS256 encoded) in a string with only write role. Only 1 token can persist in the system (otherwise, env variable holding secret key would be re-written).
func CreateJWTWithWriteRole ¶
CreateJWTWithWriteRole returns random signing key and JWT token (HS256 encoded) in a string with only write role. Only 1 token can persist in the system (otherwise, env variable holding secret key would be re-written).
Types ¶
This section is empty.