Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var PortalTokenIssuer = "openmeter"
Functions ¶
func GetAuthenticatedSubject ¶
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
func NewAuthenticator ¶
func NewAuthenticator(portalTokenStrategy *PortalTokenStrategy) Authenticator
func (Authenticator) NewAuthenticatorMiddlewareFunc ¶
func (a Authenticator) NewAuthenticatorMiddlewareFunc(swagger *openapi3.T) func(http.Handler) http.Handler
NewAuthenticatorMiddlewareFunc returns a middleware function that authenticates requests based on the OpenAPI 3 security requirements. TODO: support custom claims
type AuthenticatorContextKey ¶
type AuthenticatorContextKey string
const (
AuthenticatorSubjectSessionKey AuthenticatorContextKey = "openmeter_subject"
)
type PortalToken ¶
type PortalTokenClaims ¶
type PortalTokenClaims struct { jwt.RegisteredClaims // Id is the unique identifier of the token. Id string `json:"id"` // AllowedMeterSlugs is a list of meter slugs that the token allows access to. AllowedMeterSlugs []string `json:"allowed_meter_slugs,omitempty"` }
PortalTokenClaims is the claims struct for the portal token.
func (*PortalTokenClaims) GetAllowedMeterSlugs ¶
func (c *PortalTokenClaims) GetAllowedMeterSlugs() ([]string, error)
GetAllowedMeterSlugs returns the list of allowed meter slugs.
type PortalTokenStrategy ¶
type PortalTokenStrategy struct {
// contains filtered or unexported fields
}
func NewPortalTokenStrategy ¶
func NewPortalTokenStrategy(secret string, expire time.Duration) (*PortalTokenStrategy, error)
func (*PortalTokenStrategy) Generate ¶
func (t *PortalTokenStrategy) Generate(subject string, allowedMeterSlugs *[]string, expiresAt *time.Time) (*PortalToken, error)
func (*PortalTokenStrategy) Validate ¶
func (t *PortalTokenStrategy) Validate(tokenString string) (*PortalTokenClaims, error)
Click to show internal directories.
Click to hide internal directories.