Improvements for tokens
This commit is contained in:
parent
effa79aacd
commit
8ccd490bed
15 changed files with 34 additions and 30 deletions
|
|
@ -19,19 +19,19 @@ var (
|
|||
)
|
||||
|
||||
const (
|
||||
ScopeAdminLoggedIn Scope = "login.admin"
|
||||
ScopeUserAdmin Scope = "user.admin"
|
||||
)
|
||||
|
||||
func (*AdminLoggedIn) Scope() component.ScopeInfo {
|
||||
return component.ScopeInfo{
|
||||
Scope: ScopeAdminLoggedIn,
|
||||
Description: "session has a signed in admin",
|
||||
DeniedMessage: "user must be signed into an admin account with TOTP enabled",
|
||||
Scope: ScopeUserAdmin,
|
||||
Description: "session must have a valid admin",
|
||||
DeniedMessage: "user must have an admin account with TOTP enabled",
|
||||
TakesParam: false,
|
||||
}
|
||||
}
|
||||
|
||||
func (al *AdminLoggedIn) HasScope(param string, r *http.Request) (bool, error) {
|
||||
user, _, err := al.Dependencies.Auth.SessionOf(r)
|
||||
_, user, err := al.Dependencies.Auth.SessionOf(r)
|
||||
return user != nil && user.IsAdmin() && user.IsTOTPEnabled(), err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue