Documentation ¶
Index ¶
- Constants
- Variables
- func Auth(providers []security.HttpProvider) gin.HandlerFunc
- func Authorize(obj string, act string, enforcer security.Enforcer) gin.HandlerFunc
- func AuthorizeByID(act string, enforcer security.Enforcer) gin.HandlerFunc
- func Cache() gin.HandlerFunc
- func OnlyAuth() gin.HandlerFunc
- func ProvideAuthorizedIds(act string, enforcer security.Enforcer) gin.HandlerFunc
- func ProxyAuthorize(enforcer security.Enforcer, accessConfig proxy.AccessConfig) gin.HandlerFunc
- func Recovery(logger zerolog.Logger) gin.HandlerFunc
- func ReloadEnforcerPolicyOnChange(enforcer security.Enforcer) gin.HandlerFunc
- func SessionAuth(db mongo.DbClient, store sessions.Store) gin.HandlerFunc
- func SetAuthor() func(c *gin.Context)
- func SetAuthorToBulk() func(c *gin.Context)
Constants ¶
const ( CacheControlHeaderKey = "Cache-Control" DefaultCacheControlHeaderValue = "public, no-cache" )
const AuthorizedIds = "authorized_ids"
Variables ¶
var (
MissingUserKeyPanicMsg = "Key \"" + auth.UserKey + "\" does not exist"
)
Functions ¶
func Auth ¶
func Auth(providers []security.HttpProvider) gin.HandlerFunc
Auth middleware uses http providers to authenticate user. It checks auth only if request contains credentials.
func Authorize ¶
Authorize determines if current subject has been authorized to take an action on an object. Use OnlyAuth middleware to only check if user is authenticated.
func AuthorizeByID ¶
func AuthorizeByID( act string, enforcer security.Enforcer, ) gin.HandlerFunc
AuthorizeByID determines if current subject has been authorized to take an action on a object by id.
func OnlyAuth ¶
func OnlyAuth() gin.HandlerFunc
OnlyAuth determines if user is authenticated. Use Authorize middleware to check user permissions.
func ProvideAuthorizedIds ¶
func ProvideAuthorizedIds( act string, enforcer security.Enforcer, ) gin.HandlerFunc
ProvideAuthorizedIds determines on which objects current subject has been authorized to take an action.
func ProxyAuthorize ¶
func ProxyAuthorize( enforcer security.Enforcer, accessConfig proxy.AccessConfig, ) gin.HandlerFunc
ProxyAuthorize determines if current subject has been authorized to take an action on an object for proxy routes.
func Recovery ¶
func Recovery(logger zerolog.Logger) gin.HandlerFunc
Recovery recovers from any panics and if there was one it logs error and writes InternalServerError response.
func ReloadEnforcerPolicyOnChange ¶
func ReloadEnforcerPolicyOnChange(enforcer security.Enforcer) gin.HandlerFunc
ReloadEnforcerPolicyOnChange loads security policy if request changes policy.
func SessionAuth ¶
SessionAuth returns a Session Authorization middleware. It checks session and retrieves user using provider. It checks auth only if session exists.
func SetAuthor ¶
SetAuthor middleware sets authorized user id to author field to request body. Use it for create and update model endpoints.
func SetAuthorToBulk ¶
SetAuthorToBulk middleware sets authorized user id to author field to bulk request body. Use it for create and update model endpoints.
Types ¶
This section is empty.