mirror of
https://github.com/wso2/open-mcp-auth-proxy.git
synced 2025-10-22 16:23:03 +00:00
fix: Update ScopesSupported to match RFC 9728 Section 2
This commit is contained in:
parent
56d969b785
commit
8ca4bb4787
5 changed files with 17 additions and 66 deletions
|
@ -10,7 +10,6 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
"github.com/wso2/open-mcp-auth-proxy/internal/config"
|
||||
logger "github.com/wso2/open-mcp-auth-proxy/internal/logging"
|
||||
)
|
||||
|
||||
|
@ -160,55 +159,6 @@ func ParseJWT(tokenStr string) (jwt.MapClaims, error) {
|
|||
return claims, nil
|
||||
}
|
||||
|
||||
// Process the required scopes
|
||||
func GetRequiredScopes(cfg *config.Config, requestBody *RPCEnvelope) []string {
|
||||
|
||||
var scopeObj interface{}
|
||||
found := false
|
||||
for _, m := range cfg.ProtectedResourceMetadata.ScopesSupported {
|
||||
if val, ok := m[requestBody.Method]; ok {
|
||||
scopeObj = val
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch v := scopeObj.(type) {
|
||||
case string:
|
||||
return []string{v}
|
||||
case []any:
|
||||
if requestBody.Params != nil {
|
||||
if paramsMap, ok := requestBody.Params.(map[string]any); ok {
|
||||
name, ok := paramsMap["name"].(string)
|
||||
if ok {
|
||||
for _, item := range v {
|
||||
if scopeMap, ok := item.(map[interface{}]interface{}); ok {
|
||||
if scopeVal, exists := scopeMap[name]; exists {
|
||||
if scopeStr, ok := scopeVal.(string); ok {
|
||||
return []string{scopeStr}
|
||||
}
|
||||
if scopeArr, ok := scopeVal.([]any); ok {
|
||||
var scopes []string
|
||||
for _, s := range scopeArr {
|
||||
if str, ok := s.(string); ok {
|
||||
scopes = append(scopes, str)
|
||||
}
|
||||
}
|
||||
return scopes
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Extracts the Bearer token from the Authorization header
|
||||
func ExtractAccessToken(authHeader string) (string, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue