Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BearerAuthFuncGRPC ¶ added in v7.6.0
func BearerAuthFuncGRPC(auth authentication.Authentication) grpc_auth.AuthFunc
BearerAuthFuncGRPC returns a new grpc_auth.AuthFunc to use with the gazebo-web authentication library.
The passed in context.Context will contain the gRPC metadata.MD object (for header-based authentication) and the peer.Peer information that can contain transport-based credentials (e.g. `credentials.AuthInfo`).
auth := authentication.New[...]() srv := grpc.NewServer( grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(BearerAuthFuncGRPC(auth))), grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(BearerAuthFuncGRPC(auth))), )
func ExtractGRPCAuthSubject ¶ added in v7.13.0
ExtractGRPCAuthSubject extracts the authentication subject (sub) claim from the context metadata. This claim is usually injected in a middleware such as BearerToken or BearerAuthFuncGRPC, if present.
From the RFC7519, section 4.1.2: https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.2
The "sub" (subject) claim identifies the principal that is the subject of the JWT. The claims in a JWT are normally statements about the subject. The subject value MUST either be scoped to be locally unique in the context of the issuer or be globally unique. The processing of this claim is generally application specific. The "sub" value is a case-sensitive string containing a StringOrURI value.
This function only works with gRPC requests. It returns an error if the metadata couldn't be parsed or the subject is not present.
Types ¶
type Extractor ¶
Extractor extracts a string value from an HTTP request. It's usually used to extract a header from an HTTP request, but can also be used for extracting a user and password from the body.
There are a few implementations already provided by the request package, for example: Bearer tokens: request.BearerExtractor
type Middleware ¶
Middleware is used to modify or augment the behavior of an HTTP request handler.
func BearerToken ¶
func BearerToken(authentication authentication.Authentication) Middleware
BearerToken returns a Middleware for authenticating users using Bearer Tokens in JWT format.