- Integrated ACL (Access Control List) functionality into the OAuth guard, enabling permission checks and rate limiting based on ACL configurations. - Updated error responses for token validation and refresh token handling to use standardized error types. - Enhanced error handling for ACL-related issues, providing detailed HTTP responses based on specific ACL error types. - Improved overall security and user experience by ensuring proper authorization checks are enforced during API requests.
27 lines
483 B
Go
27 lines
483 B
Go
package acl
|
|
|
|
// Global is the global ACL enforcer
|
|
var Global Enforcer = nil
|
|
|
|
// New creates a new ACL enforcer
|
|
func New(config *Config) Enforcer {
|
|
|
|
if config == nil {
|
|
config = &DefaultConfig
|
|
}
|
|
|
|
return &ACL{
|
|
Config: config,
|
|
}
|
|
}
|
|
|
|
// Load loads the ACL enforcer
|
|
func Load(config *Config) (Enforcer, error) {
|
|
Global = New(config)
|
|
return Global, nil
|
|
}
|
|
|
|
// Enabled returns true if the ACL is enabled, otherwise false
|
|
func (acl *ACL) Enabled() bool {
|
|
return acl.Config.Enabled
|
|
}
|