server

package
v0.0.0-...-2389199 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateAge

func CalculateAge(t time.Time) int

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"`
	OtpIssuer   string    `json:"otp_issuer"`
	ServiceName string    `json:"service_name"`
	Namespace   string    `json:"namespace"`
	Mail        mail.Mail `json:"mail"`
}

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) EditGet

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

func (*HttpServer) EditOtpPost

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

func (*HttpServer) EditPost

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

func (*HttpServer) Home

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

func (*HttpServer) LoginGet

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

func (*HttpServer) LoginOtpGet

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

func (*HttpServer) LoginOtpPost

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

func (*HttpServer) LoginPost

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

func (*HttpServer) LoginResetPasswordPost

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

func (*HttpServer) MailDelete

func (h *HttpServer) MailDelete(rw http.ResponseWriter, _ *http.Request, params httprouter.Params)

func (*HttpServer) MailPassword

func (h *HttpServer) MailPassword(rw http.ResponseWriter, _ *http.Request, params httprouter.Params)

func (*HttpServer) MailPasswordPost

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

func (*HttpServer) MailVerify

func (h *HttpServer) MailVerify(rw http.ResponseWriter, _ *http.Request, params httprouter.Params)

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(flowPart bool, 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{}

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) *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
	NeedOtp bool
}

func (UserAuth) IsGuest

func (u UserAuth) IsGuest() bool

func (UserAuth) NextFlowUrl

func (u UserAuth) NextFlowUrl(origin *url.URL) *url.URL

type UserHandler

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

Jump to

Keyboard shortcuts

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