auth

package
v0.0.0-...-0406d23 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const APIKeyContextKey contextKey = "APIKeyContextKey"
View Source
const AuthContextKey contextKey = "AuthContextKey"
View Source
const ClientIPContextKey contextKey = "ClientIPContextKey"
View Source
const GinContextKey contextKey = "GinContextKey"

Define the key you want to use to store the gin.Context in the request context

View Source
const LocaleContextKey contextKey = "LocaleContextKey"
View Source
const UserAgentContextKey contextKey = "UserAgentContextKey"

Variables

This section is empty.

Functions

func APIKey

func APIKey(ctx context.Context) *string

func Auth

func Auth(ctx context.Context) jwt.MapClaims

func CalculateFingerprint

func CalculateFingerprint(pubKey *rsa.PublicKey) ([]byte, error)

func CalculateThumbprint

func CalculateThumbprint(pubKey *rsa.PublicKey, hashFunc hash.Hash) ([]byte, error)

func ClientIP

func ClientIP(ctx context.Context) *string

func CreateJWKSFile

func CreateJWKSFile(col *mongo.Collection) error

func CreateToken

func CreateToken(claims map[string]interface{}, kid string, key interface{}) (string, error)

CreateToken takes some claims and a private key (either rsa or ec) and returns a signed json web token

func GenerateRSAKeyPair

func GenerateRSAKeyPair(bits int) (*rsa.PrivateKey, error)

func GoogleLogin

func GoogleLogin(c context.Context, idToken string) (string, error)

func Locale

func Locale(ctx context.Context) *string

func Middleware

func Middleware(client *grpc.ClientConn) gin.HandlerFunc

func Token

func Token(claims jwt.MapClaims, k model.Key) (*string, error)

func UserAgent

func UserAgent(ctx context.Context) *string

func ValidateToken

func ValidateToken(tokenString string, jwksURL string) (*jwt.Token, error)

Types

type JWKSKey

type JWKSKey struct {
	Kid     string   `json:"kid"`
	Kty     string   `json:"kty"`
	Use     string   `json:"use"`
	Alg     string   `json:"alg"`
	N       string   `json:"n"`
	E       string   `json:"e"`
	X5c     []string `json:"x5c,omitempty"`
	X5t     string   `json:"x5t,omitempty"`
	X5tS256 string   `json:"x5t#S256,omitempty"`
}

JWKSKey represents a JSON Web Key (JWK).

Jump to

Keyboard shortcuts

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