Documentation
¶
Index ¶
- Variables
- type GenericRestService
- type InMem
- func (i *InMem) DeleteSession(token string)
- func (i *InMem) GenSessionID() (string, error)
- func (i *InMem) GetOrCreateUser(userName string) *entities.User
- func (i *InMem) GetSession(token string) (webauthn.SessionData, bool)
- func (i *InMem) SaveSession(token string, data webauthn.SessionData)
- func (i *InMem) SaveUser(user *entities.User)
- type JsonWebTokenRestService
- func (restService *JsonWebTokenRestService) CreateSession(w http.ResponseWriter, r *http.Request) (service.Session, error)
- func (restService *JsonWebTokenRestService) GenerateToken(w http.ResponseWriter, req *http.Request)
- func (restService *JsonWebTokenRestService) RefreshToken(w http.ResponseWriter, r *http.Request)
- func (restService *JsonWebTokenRestService) Verify(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- type JsonWebTokenServicer
- type Logger
- type RestRegistry
- type RestService
- type RestServiceRegistry
- type SystemRestService
- func (restService *SystemRestService) Certificate(w http.ResponseWriter, r *http.Request)
- func (restService *SystemRestService) Config(w http.ResponseWriter, r *http.Request)
- func (restService *SystemRestService) Endpoints(w http.ResponseWriter, r *http.Request)
- func (restService *SystemRestService) EventsPage(w http.ResponseWriter, r *http.Request)
- func (restService *SystemRestService) PublicKey(w http.ResponseWriter, r *http.Request)
- func (restService *SystemRestService) Status(w http.ResponseWriter, r *http.Request)
- type SystemRestServicer
- type WebAuthnRestService
- func (restService *WebAuthnRestService) BeginLogin(w http.ResponseWriter, r *http.Request)
- func (restService *WebAuthnRestService) BeginRegistration(w http.ResponseWriter, r *http.Request)
- func (restService *WebAuthnRestService) FinishLogin(w http.ResponseWriter, r *http.Request)
- func (restService *WebAuthnRestService) FinishRegistration(w http.ResponseWriter, r *http.Request)
- func (restService *WebAuthnRestService) RegistrationStatus(w http.ResponseWriter, r *http.Request)
- func (restService *WebAuthnRestService) Verify(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- type WebAuthnRestServicer
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidToken = errors.New("invalid token") ErrInvalidUserClaim = errors.New("invalid user id claim") ErrInvalidEmailClaim = errors.New("invalid email claim") )
var ( ErrInvalidOrganizationID = errors.New("invalid organization id") ErrUserAlreadyExists = errors.New("user already registered") ErrInvalidUserIDHeader = errors.New("invalid user id header") ErrInvalidUserID = errors.New("invalid user") )
var (
ErrInvalidOrganiztionID = errors.New("rest/jwt: invalid organization id")
)
Functions ¶
This section is empty.
Types ¶
type GenericRestService ¶
type GenericRestService[E any] struct { SystemRestService // contains filtered or unexported fields }
type InMem ¶
type InMem struct {
// contains filtered or unexported fields
}
func (*InMem) DeleteSession ¶
func (*InMem) GenSessionID ¶
func (*InMem) GetSession ¶
func (i *InMem) GetSession(token string) (webauthn.SessionData, bool)
func (*InMem) SaveSession ¶
func (i *InMem) SaveSession(token string, data webauthn.SessionData)
type JsonWebTokenRestService ¶
type JsonWebTokenRestService struct {
JsonWebTokenServicer
// contains filtered or unexported fields
}
func (*JsonWebTokenRestService) CreateSession ¶
func (restService *JsonWebTokenRestService) CreateSession( w http.ResponseWriter, r *http.Request) (service.Session, error)
Creates a new web service session from the parsed JWT
func (*JsonWebTokenRestService) GenerateToken ¶
func (restService *JsonWebTokenRestService) 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 (*JsonWebTokenRestService) RefreshToken ¶
func (restService *JsonWebTokenRestService) RefreshToken(w http.ResponseWriter, r *http.Request)
Exchange a JWT for a new token with a new expiration date
func (*JsonWebTokenRestService) Verify ¶
func (restService *JsonWebTokenRestService) 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 JsonWebTokenServicer ¶
type JsonWebTokenServicer interface {
middleware.JsonWebTokenMiddleware
}
func NewJsonWebTokenRestService ¶
func NewJsonWebTokenRestService( logger *logging.Logger, responseWriter response.HttpWriter, jwtService *jwt.Service, userService service.UserServicer) (JsonWebTokenServicer, error)
Instantiate a new JsonWebTokenService
type RestRegistry ¶
type RestRegistry struct {
RestServiceRegistry
// contains filtered or unexported fields
}
func (*RestRegistry) JsonWebTokenService ¶
func (registry *RestRegistry) JsonWebTokenService() JsonWebTokenServicer
func (*RestRegistry) SystemRestService ¶
func (registry *RestRegistry) SystemRestService() SystemRestServicer
func (*RestRegistry) WebAuthnRestService ¶
func (registry *RestRegistry) WebAuthnRestService() WebAuthnRestServicer
type RestService ¶
type RestServiceRegistry ¶
type RestServiceRegistry interface {
JsonWebTokenService() JsonWebTokenServicer
SystemRestService() SystemRestServicer
WebAuthnRestService() WebAuthnRestServicer
}
func NewRestServiceRegistry ¶
func NewRestServiceRegistry( logger *logging.Logger, ca ca.CertificateAuthority, serverKeyAttributes *keystore.KeyAttributes, serviceRegistry *service.Registry, config *config.WebService, jwtClaimsIssuer string) RestServiceRegistry
type SystemRestService ¶
type SystemRestService struct {
SystemRestServicer
// contains filtered or unexported fields
}
func (*SystemRestService) Certificate ¶
func (restService *SystemRestService) Certificate(w http.ResponseWriter, r *http.Request)
Writes the web server x509 certificate in PEM form
func (*SystemRestService) Config ¶
func (restService *SystemRestService) Config(w http.ResponseWriter, r *http.Request)
Writes the application configuration
func (*SystemRestService) Endpoints ¶
func (restService *SystemRestService) Endpoints(w http.ResponseWriter, r *http.Request)
Writes a list of webservice REST and WebSocket endpoints
func (*SystemRestService) EventsPage ¶
func (restService *SystemRestService) EventsPage(w http.ResponseWriter, r *http.Request)
Writes a page of system event log entries
func (*SystemRestService) PublicKey ¶
func (restService *SystemRestService) PublicKey(w http.ResponseWriter, r *http.Request)
Writes the web server public key in PEM form
func (*SystemRestService) Status ¶
func (restService *SystemRestService) Status(w http.ResponseWriter, r *http.Request)
Writes the current system status and metrics
type SystemRestServicer ¶
type SystemRestServicer interface {
Config(w http.ResponseWriter, r *http.Request)
Certificate(w http.ResponseWriter, r *http.Request)
Endpoints(w http.ResponseWriter, r *http.Request)
EventsPage(w http.ResponseWriter, r *http.Request)
PublicKey(w http.ResponseWriter, r *http.Request)
Status(w http.ResponseWriter, r *http.Request)
}
func NewSystemRestService ¶
func NewSystemRestService( ca ca.CertificateAuthority, serverKeyAttributes *keystore.KeyAttributes, httpWriter response.HttpWriter, logger *logging.Logger, endpointList *[]string) SystemRestServicer
type WebAuthnRestService ¶
type WebAuthnRestService struct {
WebAuthnRestServicer
// contains filtered or unexported fields
}
func (*WebAuthnRestService) BeginLogin ¶
func (restService *WebAuthnRestService) BeginLogin(w http.ResponseWriter, r *http.Request)
func (*WebAuthnRestService) BeginRegistration ¶
func (restService *WebAuthnRestService) BeginRegistration(w http.ResponseWriter, r *http.Request)
func (*WebAuthnRestService) FinishLogin ¶
func (restService *WebAuthnRestService) FinishLogin(w http.ResponseWriter, r *http.Request)
func (*WebAuthnRestService) FinishRegistration ¶
func (restService *WebAuthnRestService) FinishRegistration(w http.ResponseWriter, r *http.Request)
func (*WebAuthnRestService) RegistrationStatus ¶
func (restService *WebAuthnRestService) RegistrationStatus(w http.ResponseWriter, r *http.Request)
func (*WebAuthnRestService) Verify ¶
func (restService *WebAuthnRestService) Verify( w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type WebAuthnRestServicer ¶
type WebAuthnRestServicer interface {
BeginRegistration(w http.ResponseWriter, r *http.Request)
FinishRegistration(w http.ResponseWriter, r *http.Request)
BeginLogin(w http.ResponseWriter, r *http.Request)
FinishLogin(w http.ResponseWriter, r *http.Request)
RegistrationStatus(w http.ResponseWriter, r *http.Request)
middleware.AuthMiddleware
}
func NewWebAuthnRestService ¶
func NewWebAuthnRestService( logger *logging.Logger, config *config.WebService, responseWriter response.HttpWriter, jwtService *jwt.Service, userService service.UserServicer, registrationService service.RegistrationServicer, sessionService service.WebAuthnSessionServicer) (WebAuthnRestServicer, error)