Documentation
¶
Overview ¶
Package middleware provides middleware for the Ocular API. It includes authentication, authorization, and other middleware
Index ¶
- func AuthorizeIdentity(authorizers ...identities.Authorizer) gin.HandlerFunc
- func BearerAuthenticator() gin.HandlerFunc
- func CertificateAuthenticator() gin.HandlerFunc
- func ContextAssigner(manager cluster.ContextManager) gin.HandlerFunc
- func GetClusterContext(c context.Context) (cluster.Context, bool)
- func GetIdentity(c *gin.Context) (identities.Identity, bool)
- func MustClusterContext(c *gin.Context) cluster.Context
- func SetClusterContext(c *gin.Context, ctx cluster.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthorizeIdentity ¶
func AuthorizeIdentity(authorizers ...identities.Authorizer) gin.HandlerFunc
AuthorizeIdentity is a middleware that checks if the user is authorized to access the resource. It will check if the identities.Identity from the request is authorized by calling each identity.Authorizer provided. If any of the authorizers return true, the user is authorized.
func BearerAuthenticator ¶
func BearerAuthenticator() gin.HandlerFunc
BearerAuthenticator is a gin middleware that authenticates the user using a bearer token. It checks the "Authorization" header for a bearer token and verifies it. If the token is valid, it sets the "identity" key in the context with the user information. If the token is invalid, it returns a 401 Unauthorized response.
func CertificateAuthenticator ¶
func CertificateAuthenticator() gin.HandlerFunc
CertificateAuthenticator is a gin middleware that authenticates the user using a client certificate. It checks the TLS connection for client certificates and verifies them.
func ContextAssigner ¶
func ContextAssigner(manager cluster.ContextManager) gin.HandlerFunc
ContextAssigner is a gin middleware that assigns the cluster context to the request context. It checks the "X-ClusterContext-Name" header for the context name. If the header is not set, it will use the default context if enabled. The context assigned is the one that is used for authorization and for interacting with the cluster.
func GetClusterContext ¶
GetClusterContext retrieves the cluster context from the request context.
func GetIdentity ¶
func GetIdentity(c *gin.Context) (identities.Identity, bool)
GetIdentity retrieves the identity from the context.
func MustClusterContext ¶
MustClusterContext retrieves the cluster context from the request context. It panics if the context is not found or is not of type cluster.Context.
Types ¶
This section is empty.