wwauth

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JwtCtxKey = &contextKey{"jwt"}

Functions

func AwsFilter added in v0.2.2

func AwsFilter(field string, op string, value string) *string

AwsFilter helps format and attempts to escape filter expressions.

func ContextWithJwt added in v0.13.6

func ContextWithJwt(ctx context.Context, token *jwt.Token) context.Context

func GenerateRandomBytes added in v0.0.6

func GenerateRandomBytes(length int) []byte

func GenerateRandomString

func GenerateRandomString(length int, charset []rune) string

func GenerateUrlSafeRandomBytes added in v0.0.6

func GenerateUrlSafeRandomBytes(numBytes int) string

func RandomAlphanumeric added in v0.0.23

func RandomAlphanumeric(length int) string

func RandomHumanPassword

func RandomHumanPassword() string

func TokenFromHeader

func TokenFromHeader(r *http.Request) string

func UserTypeFromAdminGetUserResult added in v0.2.2

func UserTypeFromAdminGetUserResult(res *cognitoidentityprovider.AdminGetUserOutput) types.UserType

Types

type AdminCreateUserOpt

type AdminCreateUserOpt struct {
	Attributes        []types.AttributeType
	TemporaryPassword string
	SuppressEmail     bool
}

type CognitoAuth

type CognitoAuth struct {
	// contains filtered or unexported fields
}

func NewCognitoAuth

func NewCognitoAuth(
	log zerolog.Logger,
	awsConfig aws.Config,
	userPoolId string,
	clientId string,
) *CognitoAuth

func NewCognitoAuthFromEnv added in v0.9.0

func NewCognitoAuthFromEnv(
	log zerolog.Logger,
	awsConfig aws.Config,
) *CognitoAuth

func (*CognitoAuth) AdminCreateUser

func (c *CognitoAuth) AdminCreateUser(ctx context.Context, email string, opt AdminCreateUserOpt) (*types.UserType, error)

func (*CognitoAuth) AdminGetUser

func (*CognitoAuth) AdminResendTemporaryPassword

func (c *CognitoAuth) AdminResendTemporaryPassword(ctx context.Context, email string) error

func (*CognitoAuth) AdminSetTemporaryPassword added in v0.4.0

func (c *CognitoAuth) AdminSetTemporaryPassword(ctx context.Context, id string) (string, error)

AdminSetTemporaryPassword sets the user's password to a temporary 'human' password. The user will need to set a password when they login.

func (*CognitoAuth) Idp

func (*CognitoAuth) ListUsers added in v0.2.2

ListUsers with pagination handling. This is always important as cognito will sometimes return an empty page with a token.

func (*CognitoAuth) PublicSettings added in v0.0.14

func (c *CognitoAuth) PublicSettings() CognitoAuthPublicSettings

func (*CognitoAuth) UserPoolId

func (c *CognitoAuth) UserPoolId() string

type CognitoAuthPublicSettings added in v0.0.14

type CognitoAuthPublicSettings struct {
	UserPoolId string `json:"UserPoolId"`
	ClientId   string `json:"ClientId"`
	Region     string `json:"Region"`
}

CognitoAuthPublicSettings should precisely represent the 'UserPoolConfig' interface in ww-cognito-react.

type EntraAuth added in v0.15.0

type EntraAuth struct {
	*JwtAuth
	EntraPublicSettings
}

func NewEntraAuth added in v0.15.0

func NewEntraAuth(ctx context.Context, input NewEntraAuthInput) (*EntraAuth, error)

type EntraClaims added in v0.14.7

type EntraClaims struct {
	Email string   `json:"email"`
	Name  string   `json:"name"`
	Oid   string   `json:"oid"`
	Roles []string `json:"roles"`
	jwt.RegisteredClaims
}

func (EntraClaims) HasRole added in v0.14.7

func (user EntraClaims) HasRole(role string) bool

func (EntraClaims) UserId added in v0.15.4

func (user EntraClaims) UserId() uuid.UUID

type EntraPublicSettings added in v0.15.0

type EntraPublicSettings struct {
	TenantId string `json:"tenantId"`
	ClientId string `json:"clientId"`
}

type JwtAuth added in v0.14.0

type JwtAuth struct {
	JwtAuthOpt
	// contains filtered or unexported fields
}

func NewJwtAuth added in v0.14.0

func NewJwtAuth(log zerolog.Logger, opt JwtAuthOpt) *JwtAuth

NewJwtAuth DANGER: It is very important for newClaims to return a fresh claims pointer, otherwise all requests will share the same JWT claims pointer!

func (*JwtAuth) JwtMiddleware added in v0.14.0

func (auth *JwtAuth) JwtMiddleware(next http.Handler) http.Handler

func (*JwtAuth) ParseJwt added in v0.14.0

func (auth *JwtAuth) ParseJwt(tokenStr string) (*jwt.Token, error)

type JwtAuthOpt added in v0.14.0

type JwtAuthOpt struct {
	Jwks     jwk.Set
	Issuer   string
	Audience string
	// DANGER: It is very important for newClaims to return a fresh claims pointer,
	// otherwise all requests will share the same JWT claims pointer!
	NewClaims func() jwt.Claims
}

type NewEntraAuthInput added in v0.15.0

type NewEntraAuthInput struct {
	Log zerolog.Logger
	EntraPublicSettings
	// Usually an API scope i.e. "api://<client-id>/my-api"
	Audience string
	// MSAL.js seems to use v1.0, v2.0 is supposed to be more standards compliant
	// [citation needed].
	Version string
}

type OidcConfig added in v0.14.7

type OidcConfig struct {
	JwksUri string `json:"jwks_uri"`
	Issuer  string `json:"issuer"`
}

OidcConfig i.e. https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration

type UrlSigner added in v0.2.1

type UrlSigner struct {
	// contains filtered or unexported fields
}

func NewUrlSigner added in v0.2.1

func NewUrlSigner(privateKey []byte) *UrlSigner

func NewUrlSignerRandom added in v0.2.1

func NewUrlSignerRandom() *UrlSigner

func (*UrlSigner) SignUrl added in v0.2.1

func (us *UrlSigner) SignUrl(requestUrl *url.URL, expirySeconds int) *url.URL

func (*UrlSigner) SignUrlForTime added in v0.2.1

func (us *UrlSigner) SignUrlForTime(requestUrl *url.URL, expirySeconds int, signedAt time.Time) *url.URL

func (UrlSigner) VerifyUrl added in v0.2.1

func (us UrlSigner) VerifyUrl(rawUrl string) (bool, error)

Jump to

Keyboard shortcuts

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