Removed VerifyClaims
This commit is contained in:
parent
e044d4b5ed
commit
b922dbdbda
1 changed files with 5 additions and 18 deletions
23
pkg/auth.go
23
pkg/auth.go
|
|
@ -8,26 +8,9 @@ import (
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
"github.com/OpenCHAMI/jwtauth/v5"
|
"github.com/OpenCHAMI/jwtauth/v5"
|
||||||
"github.com/lestrrat-go/jwx/jwk"
|
"github.com/lestrrat-go/jwx/v2/jwk"
|
||||||
)
|
)
|
||||||
|
|
||||||
func VerifyClaims(testClaims []string, r *http.Request) (bool, error) {
|
|
||||||
// extract claims from JWT
|
|
||||||
_, claims, err := jwtauth.FromContext(r.Context())
|
|
||||||
if err != nil {
|
|
||||||
return false, fmt.Errorf("failed to get claims(s) from token: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify that each one of the test claims are included
|
|
||||||
for _, testClaim := range testClaims {
|
|
||||||
_, ok := claims[testClaim]
|
|
||||||
if !ok {
|
|
||||||
return false, fmt.Errorf("failed to verify claim(s) from token: %s", testClaim)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func VerifyScope(testScopes []string, r *http.Request) (bool, error) {
|
func VerifyScope(testScopes []string, r *http.Request) (bool, error) {
|
||||||
// extract the scopes from JWT
|
// extract the scopes from JWT
|
||||||
var scopes []string
|
var scopes []string
|
||||||
|
|
@ -112,3 +95,7 @@ func FetchPublicKeyFromURL(url string) (*jwtauth.JWTAuth, error) {
|
||||||
|
|
||||||
return tokenAuth, nil
|
return tokenAuth, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LoadAccessToken() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue