Identityserver4: Duplicate scopes validation breaking after updating to 2.2.0

Created on 23 Apr 2018  路  7Comments  路  Source: IdentityServer/IdentityServer4

Issue / Steps to reproduce the problem

After upgrading from 2.0.0 to 2.2.0 I started getting en error Duplicate API scopes found. This is an invalid configuration. Use different names for API scopes. Scopes found: xxx, yyy. As per https://github.com/IdentityServer/IdentityServer4/pull/2200#issuecomment-378961758 this should not affect existing code. Is this expected behavior?

Exception

System.Exception: Duplicate API scopes found. This is an invalid configuration. Use different names for API scopes. Scopes found: xxx, yyy, zzz
   at void IdentityServer4.Stores.IResourceStoreExtensions.CheckForDuplicates(string[] identityScopeNames, string[] apiScopeNames)
...
question

All 7 comments

Can you show your API Resource config?

It's fairly complex to show because of the custom code we use to configure resources and clients but I guess it's related to having several ApiResource sharing the same scopes. Will try to isolate the problem and provide more details.

Adding a resource like this breaks in 2.2.0

apiResources.Add(new ApiResource("apiname", "Some API")
{
    Scopes =
    {
        new Scope("apiname"), // repeating here
        new Scope("otherscope"),
        new Scope("anotherscope"),
    },
});

Ah, yes, you're configuring it incorrectly. The ctor like this:

new ApiResource("apiname", "Some API")

adds this:

Scopes =
    {
        new Scope("apiname"), // repeating here
   }

So use one or the other.

Thanks, I can fix that, just wanted to know if this was an expected breaking change because of the new validation for duplicate scopes as it wasn't failing on 2.0.0

Duplicate scope names was always an invalid configuration. We decided to add validation around it.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings