rest

package
v0.0.1-alpha.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GenericRestService

type GenericRestService[E any] struct {
	SystemRestService
	// contains filtered or unexported fields
}

type JWTService

type JWTService struct {
	JsonWebTokenServicer
	middleware.JsonWebTokenMiddleware
	// contains filtered or unexported fields
}

func (*JWTService) CreateSession

func (jwtService *JWTService) CreateSession(w http.ResponseWriter,
	r *http.Request) (service.Session, error)

Creates a new web service session by parsing the organization and Service from the JWT Claims and creating a service.Session object that represents the user and their organization and Service membership.

func (*JWTService) GenerateToken

func (jwtService *JWTService) GenerateToken(w http.ResponseWriter, req *http.Request)

func (*JWTService) RefreshToken

func (jwtService *JWTService) RefreshToken(w http.ResponseWriter, req *http.Request)

func (*JWTService) Validate

func (jwtService *JWTService) Validate(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

Validates the raw JWT token to ensure it's not expired or contains any invalid claims. This is used by the negroni middleware to enforce authenticated access to procted resources.

type JsonWebToken

type JsonWebToken struct {
	Value string `json:"token"`
	Error string `json:"error"`
}

type JsonWebTokenClaims

type JsonWebTokenClaims struct {
	ServerID uint64 `json:"sid"`
	UserID   uint64 `json:"uid"`
	Email    string `json:"email"`
	Services string `json:"services"`
	jwt.StandardClaims
}

type JsonWebTokenServicer

type JsonWebTokenServicer interface {
	ParseToken(r *http.Request, extractor request.Extractor) (*jwt.Token, *JsonWebTokenClaims, error)
	middleware.AuthMiddleware
	middleware.JsonWebTokenMiddleware
}

func CreateJsonWebTokenService

func CreateJsonWebTokenService(
	app *app.App,
	responseWriter response.HttpWriter,
	expiration int,
	keyAttributes *keystore.KeyAttributes,
	keystore keystore.KeyStorer) (JsonWebTokenServicer, error)

Createa a new JsonWebBokenService with custom expiration

func NewJsonWebTokenService

func NewJsonWebTokenService(
	app *app.App,
	keyAttributes *keystore.KeyAttributes,
	keystore keystore.KeyStorer,
	responseWriter response.HttpWriter) (JsonWebTokenServicer, error)

Creates a new JsonWebTokenService with default configuration

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

type RestService

type RestService interface {
	RegisterEndpoints(router *mux.Router, baseURI, baseFarmURI string) []string
}

type RestServiceRegistry

type RestServiceRegistry interface {
	JsonWebTokenService() JsonWebTokenServicer
	SystemRestService() SystemRestServicer
}

func NewRestServiceRegistry

func NewRestServiceRegistry(app *app.App) 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(
	app *app.App,
	httpWriter response.HttpWriter,
	endpointList *[]string) SystemRestServicer

Jump to

Keyboard shortcuts

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