Documentation
¶
Index ¶
- Variables
- func ParseAlgorithm(keyAttrs *keystore.KeyAttributes) (string, error)
- type RestHandler
- func (handler *RestHandler) CreateSession(w http.ResponseWriter, r *http.Request) (service.Session, error)
- func (handler *RestHandler) GenerateToken(w http.ResponseWriter, req *http.Request)
- func (handler *RestHandler) RefreshToken(w http.ResponseWriter, r *http.Request)
- func (handler *RestHandler) Verify(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- type Service
- func (service *Service) GenerateToken(user *entities.User) (string, error)
- func (service *Service) KeyFunc(token *jwt.Token) (interface{}, error)
- func (service *Service) ParseToken(w http.ResponseWriter, r *http.Request) (*jwt.Token, *TokenClaims, error)
- func (service *Service) ParseTokenString(tokenString string) (*jwt.Token, error)
- func (service *Service) PublicKey() crypto.PublicKey
- func (service *Service) Verify(token *jwt.Token) error
- type ServiceParams
- type SigningMethod
- type TokenClaims
- type TokenHandler
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAuthorizationHeaderRequired = errors.New("jwt/service: authorization header required") ErrInvalidToken = errors.New("jwt/service: invalid token") ErrInvalidUserClaim = errors.New("jwt/service: invalid user id claim") ErrInvalidEmailClaim = errors.New("jwt/service: invalid email claim") )
View Source
var (
ErrInvalidOrganiztionID = errors.New("rest/jwt: invalid organization id")
)
View Source
var (
ErrInvalidSignatureAlgorithm = errors.New("jwt: invalid signature algorithm")
)
Functions ¶
func ParseAlgorithm ¶
func ParseAlgorithm(keyAttrs *keystore.KeyAttributes) (string, error)
Types ¶
type RestHandler ¶
type RestHandler struct { TokenHandler // contains filtered or unexported fields }
func (*RestHandler) CreateSession ¶
func (handler *RestHandler) CreateSession( w http.ResponseWriter, r *http.Request) (service.Session, error)
Creates a new web service session from the parsed JWT
func (*RestHandler) GenerateToken ¶
func (handler *RestHandler) GenerateToken(w http.ResponseWriter, req *http.Request)
Decodes the requst body to a service.UserCredentials structure and generates a new JWT using the unmarshalled username and password.
func (*RestHandler) RefreshToken ¶
func (handler *RestHandler) RefreshToken(w http.ResponseWriter, r *http.Request)
Exchange a JWT for a new token with a new expiration date
func (*RestHandler) Verify ¶
func (handler *RestHandler) Verify( w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Validates the raw JWT token to ensure it's not expired or contains invalid claims. This is used by the negroni middleware to enforce authenticated access to procted resources.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(params ServiceParams) (*Service, error)
func (*Service) GenerateToken ¶
func (*Service) ParseToken ¶
func (service *Service) ParseToken( w http.ResponseWriter, r *http.Request) (*jwt.Token, *TokenClaims, error)
func (*Service) ParseTokenString ¶
type ServiceParams ¶
type SigningMethod ¶
type SigningMethod struct { jwt.SigningMethod // contains filtered or unexported fields }
func NewSigningMethod ¶
func NewSigningMethod(keyAttrs *keystore.KeyAttributes) (*SigningMethod, error)
func (*SigningMethod) Alg ¶
func (sm *SigningMethod) Alg() string
func (*SigningMethod) Digest ¶
func (sm *SigningMethod) Digest(signingString string) ([]byte, error)
type TokenClaims ¶
type TokenClaims struct { Organizations []uint64 `json:"orgs"` Services []uint64 `json:"svcs"` UserID uint64 `json:"uid"` WebAuthnClaims *webauthn.SessionData jwt.RegisteredClaims }
type TokenHandler ¶
type TokenHandler interface { middleware.JsonWebTokenMiddleware }
func NewRestHandler ¶
func NewRestHandler( logger *logging.Logger, responseWriter response.HttpWriter, jwtService *Service, userService service.UserServicer) (TokenHandler, error)
Instantiate a new JsonWebTokenService
Click to show internal directories.
Click to hide internal directories.