fix(19.7): RB-WR-02 a padded token scope name fails boot
validatePluginTokenScope checked the trimmed name with pact.ValidTokenScopeName while compileTokenScopes registered the untrimmed one, so " blog:read" booted, was listed under its padded name and could never be granted, and the duplicate check depended on registration order. The name is now validated exactly as registered, which is the shared rule pact.ValidTokenScopeName states.
This commit is contained in:
@@ -103,8 +103,11 @@ func compileTokenScopes(reg *Registry, plugins []party.Plugin) error {
|
||||
}
|
||||
|
||||
func validatePluginTokenScope(reg *Registry, pluginID string, scope pact.TokenScope, cat *tokenScopeCatalog) error {
|
||||
name := strings.TrimSpace(scope.Name)
|
||||
if name == "" || !pact.ValidTokenScopeName(name) {
|
||||
// The name is checked exactly as compileTokenScopes registers it: a padded
|
||||
// name (" blog:read", "blog:read\n") fails pact.ValidTokenScopeName and
|
||||
// boot, instead of being listed under a name no token request can match.
|
||||
name := scope.Name
|
||||
if !pact.ValidTokenScopeName(name) {
|
||||
return fmt.Errorf("cabana: plugin %s registered invalid token scope name %q", pluginID, scope.Name)
|
||||
}
|
||||
if name == scopeAll || name == "admin" || strings.HasPrefix(name, "admin:") {
|
||||
|
||||
Reference in New Issue
Block a user