Rescoped colead role and revised session handling.
This commit is contained in:
parent
da5f3524fa
commit
7dbcd05262
12 changed files with 376 additions and 50 deletions
14
auth.go
14
auth.go
|
|
@ -108,6 +108,20 @@ func hasAnyRole(roles []string, allowed []string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func isCoLeadOnly(claims *Claims) bool {
|
||||
return hasAnyRole(claims.Roles, []string{"colead"}) &&
|
||||
!hasAnyRole(claims.Roles, []string{"admin", "staffing"})
|
||||
}
|
||||
|
||||
func inSlice(v int, s []int) bool {
|
||||
for _, x := range s {
|
||||
if x == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func claimsFromContext(r *http.Request) *Claims {
|
||||
c, _ := r.Context().Value(claimsKey).(*Claims)
|
||||
return c
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue