server

package
v0.0.0-...-b249e79 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: GPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForEachRole

func ForEachRole(roles string, next func(role string))

func HasRole

func HasRole(roles, test string) bool

func NewHttpServer

func NewHttpServer(conf Conf, db *database.DB, signingKey mjwt.Signer) *http.Server

func ParseClaims

func ParseClaims(claims string) map[string]bool

func PrepareRedirectUrl

func PrepareRedirectUrl(targetPath string, origin *url.URL) *url.URL

Types

type Conf

type Conf struct {
	Listen      string             `json:"listen"`
	BaseUrl     string             `json:"base_url"`
	ServiceName string             `json:"service_name"`
	Issuer      string             `json:"issuer"`
	SsoServices []issuer.SsoConfig `json:"sso_services"`
}

type HttpServer

type HttpServer struct {
	// contains filtered or unexported fields
}

func (*HttpServer) DbTx

func (h *HttpServer) DbTx(rw http.ResponseWriter, action func(tx *database.Tx) error) bool

DbTx wraps a database transaction with http error messages and a simple action function. If the action function returns an error the transaction will be rolled back. If there is no error then the transaction is committed.

func (*HttpServer) DbTxRaw

func (h *HttpServer) DbTxRaw(action func(tx *database.Tx) error) bool

func (*HttpServer) Home

func (*HttpServer) ManageAppsGet

func (h *HttpServer) ManageAppsGet(rw http.ResponseWriter, req *http.Request, _ httprouter.Params, auth UserAuth)

func (*HttpServer) ManageAppsPost

func (h *HttpServer) ManageAppsPost(rw http.ResponseWriter, req *http.Request, _ httprouter.Params, auth UserAuth)

func (*HttpServer) ManageUsersGet

func (h *HttpServer) ManageUsersGet(rw http.ResponseWriter, req *http.Request, _ httprouter.Params, auth UserAuth)

func (*HttpServer) ManageUsersPost

func (h *HttpServer) ManageUsersPost(rw http.ResponseWriter, req *http.Request, _ httprouter.Params, auth UserAuth)

func (*HttpServer) OptionalAuthentication

func (h *HttpServer) OptionalAuthentication(next UserHandler) httprouter.Handle

func (*HttpServer) RequireAdminAuthentication

func (h *HttpServer) RequireAdminAuthentication(next UserHandler) httprouter.Handle

func (*HttpServer) RequireAuthentication

func (h *HttpServer) RequireAuthentication(next UserHandler) httprouter.Handle

func (*HttpServer) SafeRedirect

func (h *HttpServer) SafeRedirect(rw http.ResponseWriter, req *http.Request)

type IdTokenClaims

type IdTokenClaims struct {
	Subject string `json:"subject"`
}

IdTokenClaims contains the JWT claims for an access token

func (IdTokenClaims) Type

func (a IdTokenClaims) Type() string

func (IdTokenClaims) Valid

func (a IdTokenClaims) Valid() error

type JWTAccessGenerate

type JWTAccessGenerate struct {
	// contains filtered or unexported fields
}

func NewJWTAccessGenerate

func NewJWTAccessGenerate(signer mjwt.Signer, db *database.DB) *JWTAccessGenerate

func (*JWTAccessGenerate) Token

func (j *JWTAccessGenerate) Token(ctx context.Context, data *oauth2.GenerateBasic, isGenRefresh bool) (access, refresh string, err error)

type UserAuth

type UserAuth struct {
	ID          string
	DisplayName string
	UserInfo    UserInfoFields
}

func (UserAuth) IsGuest

func (u UserAuth) IsGuest() bool

type UserHandler

type UserHandler func(rw http.ResponseWriter, req *http.Request, params httprouter.Params, auth UserAuth)

type UserInfoFields

type UserInfoFields map[string]any

func (UserInfoFields) GetBoolean

func (u UserInfoFields) GetBoolean(key string) (bool, bool)

func (UserInfoFields) GetString

func (u UserInfoFields) GetString(key string) (string, bool)

func (UserInfoFields) GetStringOrDefault

func (u UserInfoFields) GetStringOrDefault(key, other string) string

func (UserInfoFields) GetStringOrEmpty

func (u UserInfoFields) GetStringOrEmpty(key string) string

Jump to

Keyboard shortcuts

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