authorization

package
v25.0.0-split-vector3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthJwtCtxKey  = ctxKey("authorizationJwt")
	AuthMetaHeader = "Dgraph.Authorization"
)

Variables

This section is empty.

Functions

func GetJwtToken

func GetJwtToken(ctx context.Context) string

func ParseExpires

func ParseExpires(ExpiresHeaderStr string) (int64, error)

func ParseMaxAge

func ParseMaxAge(CacheControlHeaderStr string) (int64, error)

Types

type AuthMeta

type AuthMeta struct {
	VerificationKey string
	JWKUrl          string
	JWKUrls         []string

	RSAPublicKey  *rsa.PublicKey `json:"-"` // Ignoring this field
	Header        string
	Namespace     string
	Algo          string
	SigningMethod jwt.SigningMethod `json:"-"` // Ignoring this field
	Audience      []string

	ClosedByDefault bool
	// contains filtered or unexported fields
}

func Parse

func Parse(schema string) (*AuthMeta, error)

func ParseAuthMeta

func ParseAuthMeta(schema string) (*AuthMeta, error)

func (*AuthMeta) AttachAuthorizationJwt

func (a *AuthMeta) AttachAuthorizationJwt(ctx context.Context,
	header http.Header) (context.Context, error)

AttachAuthorizationJwt adds any incoming JWT authorization data into the grpc context metadata.

func (*AuthMeta) ExtractCustomClaims

func (a *AuthMeta) ExtractCustomClaims(ctx context.Context) (*CustomClaims, error)

func (*AuthMeta) FetchJWK

func (a *AuthMeta) FetchJWK(i int) error

FetchJWK fetches the JSON web Key set for the JWKUrl at a given index.

func (*AuthMeta) FetchJWKs

func (a *AuthMeta) FetchJWKs() error

FetchJWKs fetches the JSON Web Key sets for the JWKUrls. It returns an error if the fetching of key is failed even for one of the JWKUrl.

func (*AuthMeta) GetHeader

func (a *AuthMeta) GetHeader() string

func (*AuthMeta) InitHttpClient

func (a *AuthMeta) InitHttpClient()

type CustomClaims

type CustomClaims struct {
	AuthVariables map[string]interface{}
	jwt.RegisteredClaims
	// contains filtered or unexported fields
}

func (*CustomClaims) UnmarshalJSON

func (c *CustomClaims) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshalls the claims present in the JWT. It also adds standard claims to the `AuthVariables`. If there is an auth variable with name same as one of auth variable then the auth variable supersedes the standard claim.

Jump to

Keyboard shortcuts

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