context

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// Internal Auth Context Header, carries information of the
	// client that has been authenticated.
	// Where content itself will be of usual string format, which
	// is obtained by json marshaling of struct AuthInfo followed
	// by base64 encoding of the json marshaled content.
	//
	// This is usually Added by Auth Gateway, if present it
	// indicates that authentication is successfully performed
	// by Auth Gateway.
	HttpClientAuthContext = "Auth-Info"

	// grpc gateway will typically move the header to lowercase
	GrpcClientAuthContext = "auth-info"
)

Variables

This section is empty.

Functions

func DeleteAuthInfoHeader

func DeleteAuthInfoHeader(r *http.Request)

delete the Auth info header from the given HTTP request

func ProcessAuthInfo

func ProcessAuthInfo(ctx context.Context) (context.Context, error)

Processes the headers available in context, to validate that the authentication is already performed

func SetAuthInfoHeader

func SetAuthInfoHeader(r *http.Request, info *AuthInfo) error

Sets Auth Info Header in the provided Http Request typically will be used only by the entity that has performed that authentication on the given http request already and has the relevant Auth Info Context.

Types

type AuthInfo

type AuthInfo struct {
	Realm         string   `json:"realm,omitempty"`
	UserName      string   `json:"preferred_username"`
	Email         string   `json:"email,omitempty"`
	EmailVerified bool     `json:"email_verified,omitempty"`
	FullName      string   `json:"name,omitempty"`
	FirstName     string   `json:"given_name,omitempty"`
	LastName      string   `json:"family_name,omitempty"`
	SessionID     string   `json:"sid,omitempty"`
	Roles         []string `json:"roles,omitempty"`
	IsRoot        bool     `json:"isRoot,omitempty"`
}

Auth construct obtained as part of the auth action being performed while processing a request, this is json tagged to allow passing the inforamtion internally in the system between the microservices we can validate entities like user, devices, service accounts etc

func GetAuthInfoFromContext

func GetAuthInfoFromContext(ctx context.Context) (*AuthInfo, error)

gets Auth Info from Context available in the Http Request

func GetAuthInfoHeader

func GetAuthInfoHeader(r *http.Request) (*AuthInfo, error)

gets Auth Info Header available in the Http Request

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL