Documentation
¶
Index ¶
- Variables
- func AuthCookie(token, path string) *http.Cookie
- func GetTLSConfig(setupRootCA bool) (*tls.Config, error)
- func NoAuthenticationWrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc
- func SetAuthHeaders(headers *http.Header, authOpts *AuthenticationOpts)
- type AuthenticationBackend
- type AuthenticationOpts
- type BasicAuthenticationBackend
- func (b *BasicAuthenticationBackend) Authenticate(username string, password string) (string, error)
- func (b *BasicAuthenticationBackend) DefaultUserRole(user string) string
- func (b *BasicAuthenticationBackend) Name() string
- func (b *BasicAuthenticationBackend) SetDefaultUserRole(role string)
- func (b *BasicAuthenticationBackend) Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc
- type ConnectionType
- type CrudClient
- func (c *CrudClient) Create(resource string, value interface{}) error
- func (c *CrudClient) Delete(resource string, id string) error
- func (c *CrudClient) Get(resource string, id string, value interface{}) error
- func (c *CrudClient) List(resource string, values interface{}) error
- func (c *CrudClient) Update(resource string, id string, value interface{}) error
- type ExtraAsset
- type HtpasswdMapProvider
- type KeystoneAuthenticationBackend
- func (b *KeystoneAuthenticationBackend) Authenticate(username string, password string) (string, error)
- func (b *KeystoneAuthenticationBackend) CheckUser(token string) (string, error)
- func (b *KeystoneAuthenticationBackend) DefaultUserRole(user string) string
- func (b *KeystoneAuthenticationBackend) Name() string
- func (b *KeystoneAuthenticationBackend) SetDefaultUserRole(role string)
- func (b *KeystoneAuthenticationBackend) Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc
- type NoAuthenticationBackend
- func (h *NoAuthenticationBackend) Authenticate(username string, password string) (string, error)
- func (h *NoAuthenticationBackend) DefaultUserRole(user string) string
- func (h *NoAuthenticationBackend) Name() string
- func (b *NoAuthenticationBackend) SetDefaultUserRole(role string)
- func (h *NoAuthenticationBackend) Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc
- type PathPrefix
- type RestClient
- type Route
- type Server
- func (s *Server) AddGlobalVar(key string, v interface{})
- func (s *Server) HandleFunc(path string, f auth.AuthenticatedHandlerFunc, ...)
- func (s *Server) Listen() error
- func (s *Server) ListenAndServe()
- func (s *Server) RegisterLoginRoute(authBackend AuthenticationBackend)
- func (s *Server) RegisterRoutes(routes []Route, auth AuthenticationBackend)
- func (s *Server) Serve()
- func (s *Server) ServeIndex(w http.ResponseWriter, r *auth.AuthenticatedRequest)
- func (s *Server) Stop()
- type User
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AuthCookie ¶ added in v0.19.1
AuthCookie returns a authentication cookie
func NoAuthenticationWrap ¶ added in v0.19.1
func NoAuthenticationWrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc
func SetAuthHeaders ¶ added in v0.19.1
func SetAuthHeaders(headers *http.Header, authOpts *AuthenticationOpts)
SetAuthHeaders apply all the cookie used for authentication to the header
Types ¶
type AuthenticationBackend ¶
type AuthenticationBackend interface { Name() string DefaultUserRole(user string) string SetDefaultUserRole(role string) Authenticate(username string, password string) (string, error) Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc }
AuthenticationBackend is the interface of a authentication backend
func NewAuthenticationBackendByName ¶ added in v0.19.1
func NewAuthenticationBackendByName(name string) (backend AuthenticationBackend, err error)
NewAuthenticationBackendByName creates a new auth backend based on the name
type AuthenticationOpts ¶
AuthenticationOpts describes the elements used by a client to authenticate to an HTTP server. It can be either a username/password couple or a token
type BasicAuthenticationBackend ¶
type BasicAuthenticationBackend struct { *auth.BasicAuth // contains filtered or unexported fields }
func NewBasicAuthenticationBackend ¶
func NewBasicAuthenticationBackend(name string, provider auth.SecretProvider, role string) (*BasicAuthenticationBackend, error)
func NewBasicAuthenticationBackendFromConfig ¶
func NewBasicAuthenticationBackendFromConfig(name string) (*BasicAuthenticationBackend, error)
func (*BasicAuthenticationBackend) Authenticate ¶
func (b *BasicAuthenticationBackend) Authenticate(username string, password string) (string, error)
func (*BasicAuthenticationBackend) DefaultUserRole ¶ added in v0.19.1
func (b *BasicAuthenticationBackend) DefaultUserRole(user string) string
DefaultUserRole returns the default user role
func (*BasicAuthenticationBackend) Name ¶ added in v0.19.1
func (b *BasicAuthenticationBackend) Name() string
Name returns the name of the backend
func (*BasicAuthenticationBackend) SetDefaultUserRole ¶ added in v0.19.1
func (b *BasicAuthenticationBackend) SetDefaultUserRole(role string)
SetDefaultUserRole defines the default user role
func (*BasicAuthenticationBackend) Wrap ¶
func (b *BasicAuthenticationBackend) Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc
type ConnectionType ¶ added in v0.16.0
type ConnectionType int
const ( // TCP connection TCP ConnectionType = 1 + iota // TLS secure connection TLS // ExtraAssetPrefix is used for extra assets ExtraAssetPrefix = "/extra-statics" )
type CrudClient ¶
type CrudClient struct {
RestClient
}
func NewCrudClient ¶
func NewCrudClient(url *url.URL, authOpts *AuthenticationOpts) (*CrudClient, error)
func (*CrudClient) Create ¶
func (c *CrudClient) Create(resource string, value interface{}) error
func (*CrudClient) Delete ¶
func (c *CrudClient) Delete(resource string, id string) error
func (*CrudClient) Get ¶
func (c *CrudClient) Get(resource string, id string, value interface{}) error
func (*CrudClient) List ¶
func (c *CrudClient) List(resource string, values interface{}) error
func (*CrudClient) Update ¶
func (c *CrudClient) Update(resource string, id string, value interface{}) error
type ExtraAsset ¶ added in v0.16.0
type HtpasswdMapProvider ¶ added in v0.19.1
HtpasswdMapProvider defines a basic auth secret provider
func NewHtpasswdMapProvider ¶ added in v0.19.1
func NewHtpasswdMapProvider(users map[string]string) *HtpasswdMapProvider
NewHtpasswdMapProvider creates a new htpassword provider based on a map
func (*HtpasswdMapProvider) AddUser ¶ added in v0.19.1
func (h *HtpasswdMapProvider) AddUser(user, password string)
AddUser add a new user with the given password
func (*HtpasswdMapProvider) SecretProvider ¶ added in v0.19.1
func (h *HtpasswdMapProvider) SecretProvider() auth.SecretProvider
SecretProvider returns a SecretProvider
type KeystoneAuthenticationBackend ¶
type KeystoneAuthenticationBackend struct { AuthURL string Tenant string Domain string // contains filtered or unexported fields }
func NewKeystoneAuthenticationBackendFromConfig ¶
func NewKeystoneAuthenticationBackendFromConfig(name string) (*KeystoneAuthenticationBackend, error)
func NewKeystoneBackend ¶
func (*KeystoneAuthenticationBackend) Authenticate ¶
func (b *KeystoneAuthenticationBackend) Authenticate(username string, password string) (string, error)
func (*KeystoneAuthenticationBackend) CheckUser ¶
func (b *KeystoneAuthenticationBackend) CheckUser(token string) (string, error)
func (*KeystoneAuthenticationBackend) DefaultUserRole ¶ added in v0.19.1
func (b *KeystoneAuthenticationBackend) DefaultUserRole(user string) string
DefaultUserRole return the default user role
func (*KeystoneAuthenticationBackend) Name ¶ added in v0.19.1
func (b *KeystoneAuthenticationBackend) Name() string
Name returns the name of the backend
func (*KeystoneAuthenticationBackend) SetDefaultUserRole ¶ added in v0.19.1
func (b *KeystoneAuthenticationBackend) SetDefaultUserRole(role string)
SetDefaultUserRole defines the default user role
func (*KeystoneAuthenticationBackend) Wrap ¶
func (b *KeystoneAuthenticationBackend) Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc
type NoAuthenticationBackend ¶
type NoAuthenticationBackend struct { }
func NewNoAuthenticationBackend ¶
func NewNoAuthenticationBackend() *NoAuthenticationBackend
func (*NoAuthenticationBackend) Authenticate ¶
func (h *NoAuthenticationBackend) Authenticate(username string, password string) (string, error)
func (*NoAuthenticationBackend) DefaultUserRole ¶ added in v0.19.1
func (h *NoAuthenticationBackend) DefaultUserRole(user string) string
DefaultUserRole returns the name of the backend
func (*NoAuthenticationBackend) Name ¶ added in v0.19.1
func (h *NoAuthenticationBackend) Name() string
Name returns the name of the backend
func (*NoAuthenticationBackend) SetDefaultUserRole ¶ added in v0.19.1
func (b *NoAuthenticationBackend) SetDefaultUserRole(role string)
SetDefaultUserRole defines the default user role
func (*NoAuthenticationBackend) Wrap ¶
func (h *NoAuthenticationBackend) Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc
type RestClient ¶
type RestClient struct {
// contains filtered or unexported fields
}
func NewRestClient ¶
func NewRestClient(url *url.URL, authOpts *AuthenticationOpts) (*RestClient, error)
type Route ¶
type Server ¶
type Server struct { sync.RWMutex http.Server Host string ServiceType common.ServiceType Router *mux.Router Addr string Port int AuthBackend AuthenticationBackend CnxType ConnectionType // contains filtered or unexported fields }
func NewServer ¶
func NewServerFromConfig ¶
func NewServerFromConfig(serviceType common.ServiceType) (*Server, error)
func (*Server) AddGlobalVar ¶ added in v0.19.1
func (*Server) HandleFunc ¶
func (s *Server) HandleFunc(path string, f auth.AuthenticatedHandlerFunc, authBackend AuthenticationBackend)
HandleFunc specifies the handler function and the authentication backend used for a given path
func (*Server) RegisterLoginRoute ¶ added in v0.19.1
func (s *Server) RegisterLoginRoute(authBackend AuthenticationBackend)
func (*Server) RegisterRoutes ¶
func (s *Server) RegisterRoutes(routes []Route, auth AuthenticationBackend)
func (*Server) ServeIndex ¶ added in v0.19.1
func (s *Server) ServeIndex(w http.ResponseWriter, r *auth.AuthenticatedRequest)
ServeIndex servers the index page
Source Files
¶
- auth.go
- basic.go
- basic_map_provider.go
- client.go
- keystone.go
- noauth.go
- server.go
- tls.go