server better organized
This commit is contained in:
@@ -49,8 +49,8 @@ func NewAuth(
|
||||
}
|
||||
}
|
||||
|
||||
// AddIdentity will add an Identity to the context that can then be retrieved via GetIdentity.
|
||||
func (a *Auth) AddIdentity(c *gin.Context) {
|
||||
// Identify will add an Identity to the context that can then be retrieved via GetIdentity.
|
||||
func (a *Auth) Identify(c *gin.Context) {
|
||||
if err := a.addIdentity(c); err != nil {
|
||||
c.Error(err)
|
||||
c.Abort()
|
||||
@@ -98,9 +98,14 @@ func (a *Auth) addIdentity(c *gin.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Authenticate should only be used along with and after AddIdentity
|
||||
// Authenticate should only be used along with and after Identify
|
||||
// Typically used with response.Handler to make a gin.HandlerFunc.
|
||||
func (a *Auth) Authenticate(assertions ...AuthorizationAssertions) func(c *gin.Context) (response.Response, error) {
|
||||
func (a *Auth) Authenticate(assertions ...AuthorizationAssertions) func(c *gin.Context) {
|
||||
return response.Handler(a.AuthenticateHandler(assertions...))
|
||||
}
|
||||
|
||||
// See Authenticate.
|
||||
func (a *Auth) AuthenticateHandler(assertions ...AuthorizationAssertions) func(c *gin.Context) (response.Response, error) {
|
||||
return func(c *gin.Context) (response.Response, error) {
|
||||
id, ok := getIdentity(c)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user