rest

package
v0.0.4-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken      = errors.New("invalid token")
	ErrInvalidUserClaim  = errors.New("invalid user id claim")
	ErrInvalidEmailClaim = errors.New("invalid email claim")
)
View Source
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")
)
View Source
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 NewInMem

func NewInMem(log Logger) *InMem

func (*InMem) DeleteSession

func (i *InMem) DeleteSession(token string)

func (*InMem) GenSessionID

func (i *InMem) GenSessionID() (string, error)

func (*InMem) GetOrCreateUser

func (i *InMem) GetOrCreateUser(userName string) *entities.User

func (*InMem) GetSession

func (i *InMem) GetSession(token string) (webauthn.SessionData, bool)

func (*InMem) SaveSession

func (i *InMem) SaveSession(token string, data webauthn.SessionData)

func (*InMem) SaveUser

func (i *InMem) SaveUser(user *entities.User)

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 Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

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 RestService interface {
	RegisterEndpoints(router *mux.Router, baseURI, baseFarmURI string) []string
}

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)

Jump to

Keyboard shortcuts

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