Documentation ¶
Index ¶
- Constants
- func AuthenticationBasic(authProvider *AuthenticationProvider) echo.MiddlewareFunc
- func AuthenticationBearer(authProvider *AuthenticationProvider) echo.MiddlewareFunc
- func Authorization(roles ...Role) echo.MiddlewareFunc
- func NewBasicAuthorizationContext(tenant, username, password string) context.Context
- func NewBearerAuthorizationContext(token string) context.Context
- func SkipCheck(c echo.Context) bool
- type AuthContext
- type AuthenticationProvider
- type ErrInvalidAuthType
- type Role
Constants ¶
View Source
const (
SecurityContextKey = "__SecurityContextKey__"
)
Variables ¶
This section is empty.
Functions ¶
func AuthenticationBasic ¶
func AuthenticationBasic(authProvider *AuthenticationProvider) echo.MiddlewareFunc
func AuthenticationBearer ¶
func AuthenticationBearer(authProvider *AuthenticationProvider) echo.MiddlewareFunc
func Authorization ¶
func Authorization(roles ...Role) echo.MiddlewareFunc
Authorization checks if context contains at least one given privilege (OR check) on failure request ends with 401 unauthorized error
Types ¶
type AuthContext ¶
AuthContext holds information about user who has been authenticated for request
func GetUserSecurityContext ¶
func GetUserSecurityContext(c echo.Context) (AuthContext, error)
func (*AuthContext) CheckPrivilege ¶
func (s *AuthContext) CheckPrivilege(roles ...Role) bool
CheckPrivilege checks if user in AuthContext has at least one (OR) of given privilege
type AuthenticationProvider ¶
type AuthenticationProvider struct {
// contains filtered or unexported fields
}
func NewAuthProvider ¶
func NewAuthProvider(client *c8y.Client) *AuthenticationProvider
func (*AuthenticationProvider) Authorize ¶
func (a *AuthenticationProvider) Authorize(ctx context.Context) (AuthContext, bool)
type ErrInvalidAuthType ¶
type ErrInvalidAuthType struct {
Err error
}
ErrInvalidAuthType is error type when the KeyAuth middleware detects and invalid auth type, e.g. Basic vs Bearer
func (*ErrInvalidAuthType) Error ¶
func (e *ErrInvalidAuthType) Error() string
Error returns errors text
Click to show internal directories.
Click to hide internal directories.