Documentation ¶
Index ¶
- Constants
- type AppInfo
- type Authentication
- type Config
- type FuncAreWeHealthy
- type FuncAreWeReady
- type JwtChecker
- type JwtCustomClaims
- type JwtInfo
- func (ji *JwtInfo) GetIssuerId() string
- func (ji *JwtInfo) GetJwtCustomClaimsFromContext(c echo.Context) *JwtCustomClaims
- func (ji *JwtInfo) GetJwtDuration() int
- func (ji *JwtInfo) GetLogger() golog.MyLogger
- func (ji *JwtInfo) GetTokenFromUserInfo(userInfo *UserInfo) (*jwt.Token, error)
- func (ji *JwtInfo) JwtMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func (ji *JwtInfo) ParseToken(jwtToken string) (*JwtCustomClaims, error)
- type Server
- func (s *Server) AddGetRoute(baseURL string, urlPath string, handler echo.HandlerFunc)
- func (s *Server) GetEcho() *echo.Echo
- func (s *Server) GetHealthHandler(healthyFunc FuncAreWeHealthy, msg string) echo.HandlerFunc
- func (s *Server) GetListenAddress() string
- func (s *Server) GetLog() golog.MyLogger
- func (s *Server) GetReadinessHandler(readyFunc FuncAreWeReady, msg string) echo.HandlerFunc
- func (s *Server) GetRestrictedGroup() *echo.Group
- func (s *Server) GetRouter() *http.ServeMux
- func (s *Server) GetStartTime() time.Time
- func (s *Server) StartServer() error
- type SimpleAdminAuthenticator
- type SimpleVersionWriter
- type UserInfo
- type VersionReader
Constants ¶
const ( MIMEAppJSON = "application/json" MIMEHtml = "text/html" MIMEAppJSONCharsetUTF8 = MIMEAppJSON + "; " + charsetUTF8 HeaderContentType = "Content-Type" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authentication ¶ added in v0.3.2
type Authentication interface { AuthenticateUser(user, passwordHash string) bool GetUserInfoFromLogin(login string) (*UserInfo, error) }
func NewSimpleAdminAuthenticator ¶ added in v0.3.2
func NewSimpleAdminAuthenticator(u *UserInfo, mainAdminPassword string, jwtCheck JwtChecker) Authentication
NewSimpleAdminAuthenticator Function to create an instance of SimpleAdminAuthenticator
type Config ¶ added in v0.3.2
type Config struct { ListenAddress string Authenticator Authentication JwtCheck JwtChecker VersionReader VersionReader Logger golog.MyLogger WebRootDir string Content embed.FS RestrictedUrl string }
type FuncAreWeHealthy ¶
type FuncAreWeReady ¶
type JwtChecker ¶ added in v0.3.2
type JwtChecker interface { ParseToken(jwtToken string) (*JwtCustomClaims, error) GetTokenFromUserInfo(userInfo *UserInfo) (*jwt.Token, error) JwtMiddleware(next echo.HandlerFunc) echo.HandlerFunc GetLogger() golog.MyLogger GetJwtDuration() int GetIssuerId() string GetJwtCustomClaimsFromContext(c echo.Context) *JwtCustomClaims }
func NewJwtChecker ¶ added in v0.3.2
func NewJwtChecker(secret, issuer, subject, contextKey string, duration int, l golog.MyLogger) JwtChecker
NewJwtChecker creates a new JwtChecker
type JwtCustomClaims ¶
type JwtCustomClaims struct { jwt.RegisteredClaims User *UserInfo }
JwtCustomClaims are custom claims extending default ones.
type JwtInfo ¶ added in v0.3.2
type JwtInfo struct { Secret string `json:"secret"` Duration int `json:"duration"` IssuerId string `json:"issuer_id"` Subject string `json:"subject"` JwtContextKey string `json:"jwt_context_key"` // Context key for storing the JWT token // contains filtered or unexported fields }
func (*JwtInfo) GetIssuerId ¶ added in v0.3.2
func (*JwtInfo) GetJwtCustomClaimsFromContext ¶ added in v0.3.2
func (ji *JwtInfo) GetJwtCustomClaimsFromContext(c echo.Context) *JwtCustomClaims
GetJwtCustomClaimsFromContext returns the JWT Custom claims from the Echo context
func (*JwtInfo) GetJwtDuration ¶ added in v0.3.2
func (*JwtInfo) GetTokenFromUserInfo ¶ added in v0.3.2
func (*JwtInfo) JwtMiddleware ¶ added in v0.3.2
func (ji *JwtInfo) JwtMiddleware(next echo.HandlerFunc) echo.HandlerFunc
func (*JwtInfo) ParseToken ¶ added in v0.3.2
func (ji *JwtInfo) ParseToken(jwtToken string) (*JwtCustomClaims, error)
type Server ¶ added in v0.3.2
type Server struct { Authenticator Authentication JwtCheck JwtChecker VersionReader VersionReader // contains filtered or unexported fields }
Server is a struct type to store information related to all handlers of web server
func CreateNewServerFromEnvOrFail ¶ added in v0.3.2
func CreateNewServerFromEnvOrFail(defaultPort int, defaultServerIp string, srvConfig *Config) *Server
CreateNewServerFromEnvOrFail creates a new server from environment variables or fails
func NewGoHttpServer ¶
NewGoHttpServer is a constructor that initializes the server,routes and all fields in Server type
func (*Server) AddGetRoute ¶ added in v0.3.2
AddGetRoute adds a handler for this web server
func (*Server) GetEcho ¶ added in v0.3.2
func (s *Server) GetEcho() *echo.Echo
GetEcho returns a pointer to the Echo reference
func (*Server) GetHealthHandler ¶ added in v0.3.2
func (s *Server) GetHealthHandler(healthyFunc FuncAreWeHealthy, msg string) echo.HandlerFunc
func (*Server) GetListenAddress ¶ added in v0.3.2
GetListenAddress returns the listen address of this web server
func (*Server) GetReadinessHandler ¶ added in v0.3.2
func (s *Server) GetReadinessHandler(readyFunc FuncAreWeReady, msg string) echo.HandlerFunc
func (*Server) GetRestrictedGroup ¶ added in v0.3.2
func (s *Server) GetRestrictedGroup() *echo.Group
GetRestrictedGroup adds a handler for this web server
func (*Server) GetStartTime ¶ added in v0.3.2
GetStartTime returns the start time of this web server
func (*Server) StartServer ¶ added in v0.3.2
StartServer initializes all the handlers paths of this web server, it is called inside the NewGoHttpServer constructor
type SimpleAdminAuthenticator ¶ added in v0.3.2
type SimpleAdminAuthenticator struct {
// contains filtered or unexported fields
}
SimpleAdminAuthenticator Create a struct that will implement the Authentication interface
func (*SimpleAdminAuthenticator) AuthenticateUser ¶ added in v0.3.2
func (sa *SimpleAdminAuthenticator) AuthenticateUser(userLogin, passwordHash string) bool
AuthenticateUser Implement the AuthenticateUser method for SimpleAdminAuthenticator
func (*SimpleAdminAuthenticator) GetUserInfoFromLogin ¶ added in v0.3.2
func (sa *SimpleAdminAuthenticator) GetUserInfoFromLogin(login string) (*UserInfo, error)
GetUserInfoFromLogin Get the JWT claims from the login User
type SimpleVersionWriter ¶ added in v0.3.2
type SimpleVersionWriter struct {
Version AppInfo
}
SimpleVersionWriter Create a struct that will implement the VersionReader interface
func NewSimpleVersionReader ¶ added in v0.3.2
func NewSimpleVersionReader(app, ver, repo string) *SimpleVersionWriter
NewSimpleVersionReader is a constructor that initializes the VersionReader interface
func (SimpleVersionWriter) GetVersionInfo ¶ added in v0.3.2
func (s SimpleVersionWriter) GetVersionInfo() AppInfo
GetVersionInfo returns the version information of the application.
type UserInfo ¶ added in v0.3.2
type UserInfo struct { UserId int `json:"user_id"` ExternalId int `json:"external_id"` Name string `json:"name"` Email string `json:"email"` Login string `json:"login"` IsAdmin bool `json:"is_admin"` Groups []int `json:"groups"` }
UserInfo are custom claims extending default ones.
type VersionReader ¶ added in v0.3.2
type VersionReader interface {
GetVersionInfo() AppInfo
}