Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrMissingRealm indicates Realm name is required ErrMissingRealm = errors.New("realm is missing") // ErrForbidden when HTTP status 403 is given ErrForbidden = errors.New("you don't have permission to access this resource") // ErrInvalidPrivKey indicates that the given private EncryptionKey is invalid ErrInvalidClaims = errors.New("token payload content invalid") // ErrNoPrivKeyFile indicates that the given private EncryptionKey is unreadable ErrNoPrivKeyFile = errors.New("private EncryptionKey file unreadable") // ErrNoPubKeyFile indicates that the given public EncryptionKey is unreadable ErrNoPubKeyFile = errors.New("public EncryptionKey file unreadable") // ErrInvalidPrivKey indicates that the given private EncryptionKey is invalid ErrInvalidPrivKey = errors.New("private EncryptionKey invalid") // ErrInvalidPubKey indicates the the given public EncryptionKey is invalid ErrInvalidPubKey = errors.New("public EncryptionKey invalid") // ErrInvalidKey indicates the the given EncryptionKey is invalid ErrInvalidKey = errors.New("encrypty EncryptionKey invalid") )
View Source
var ActiveUserContextKey = contextKey{}
Functions ¶
func ParsePrivateKey ¶
func ParsePrivateKey(priKey []byte) (key *rsa.PrivateKey, err error)
pass through if private key is nil
Types ¶
type BearerTokenValidator ¶
type BearerTokenValidator struct { // Realm name to display to the user. Required. Realm string // Duration that a jwt token is valid. Optional, defaults to one hour. Timeout time.Duration // Callback function that should perform the authorization of the authenticated user. Called // only after an authentication success. Must return true on success, false on failure. // Optional, default to success. TokenValidator func(token *jwt.Token, c context.Context) error // Set the identity handler function. that mean the jwt is pass validete IdentityHandler func(c context.Context, claims jwt.MapClaims) (*Identity, error) // Secret EncryptionKey used for signing. Required. EncryptionKey []byte // Private EncryptionKey PrivKey *rsa.PrivateKey // Public EncryptionKey PubKey *rsa.PublicKey }
func (*BearerTokenValidator) Init ¶
func (b *BearerTokenValidator) Init() error
Init initialize jwt configs.
type Identity ¶
func UserFromContext ¶
get User Id from context, grpc interceptor convert metadata into context
Click to show internal directories.
Click to hide internal directories.