Multiple ApiResource's sharing scame scope name errors #2304
Comments
Correct, this is how it's designed and is a trade off to allow other features. |
If you don't mind me asking, what are the other features that it enables? I know that I am going to get asked why we can't share scopes across applications so if I have an answer that will help answer it when asked. Thanks. |
From a design perspective scopes are meant to model your API. Why do two different APIs have the same scope? Introspection becomes odd when two different APIs share the same scope, and that's why it's designed the way it is now. In IdentityServer3 all scopes were "flat". |
Sure, scopes are meant to model the api auth. If the API wants to have a scope of "admin", for example, why should another api not be able to use the scope "admin"? Are you suggesting that every ApiResource needs to know about every other ApiResource's scopes in order to not create a duplicate scope? In the scenario where someone wants to register their API with the identity server, now they have to cross their fingers that the scope they want, and perhaps coded for, is not being used by some other API in the system. Why should the system care what an API calls its scopes or if the scopes overlap? Consider this problem when you are hosting tens, if not hundreds, of APIs in an enterprise setting using this system, like I am about to do. There are going to be common scopes that everyone is going to want to use for their APIs. However, they are not going to be able to do that. Off the top of my head here are some that I have already been asked about:
Now when someone goes to register their API against the identity system, they may (or may not) be able to create the scopes that they want for their API because "another api is using that scope". Why do/should they care that another API is using that scope? Why should they have to come up with some unique scope name? Now throw 50 APIs in to the mix. cringe Perhaps there is a scenario that I am not thinking of? If I forked the code and removed this constraint would it break anything within the system that you know about? Thanks! |
Yes, scopes need to be unique across all APIs. Imagine if they were not -- a client's request would be ambiguous. Look at how google does it: https://developers.google.com/oauthplayground/. Normally I put a dot in mine if I want to have multiple scopes per logical API, e.g. "mycoolapi.read-only", and "mycoolapi.read-write". |
Cool. I'll come up with a naming convention for the team. Thanks for the reply. |
Also, beware creating too many scopes. Scopes are meant to allow an end user to give permission to a client application to use the API on the uer's behalf. They're not meant for user-level permissions (the sound of some of your scopes above worry me, like "qa" and "general user"). I've seen train wrecks where people misunderstand and/or overuse scopes. Just something to consider. |
@brockallen Interesting comments. We are developing a typical SOA architecture with multiple autonomous (independent) APIs composed at the UI layer. A UI application will require access to multiple APIs. It will typically need to access most of the APIs servicing the needs of multiple users. The UI itself is a resource that users access. But it is itself a single client of the multiple backend APIs. Because in IdentityServer, scopes are "scoped" to a resource, this means that either the UI must make a single request to IdentityServer asking for many scopes, or the UI must manage multiple tokens for each service it needs to access. What I was hoping for, was that by adding the same scope to multiple resources, requesting that single scope would grant a token with an audience for all the API resources that shared that scope. This model is unambiguous since the scopes are shared - you don't have to disambiguate between resources - you are asking for accessing to all of them by specifying a single scope. Clearly, we can just ask for multiple scopes - but as it is currently, this model does run the risk of "too many scopes" being created since we have to create at least one scope per resource. I wondered if you had any thoughts on this? |
You can request multiple scopes in one authorization request, and the resultant access token can be used at those different APIs. |
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. |
If I have multiple ApiResource's. Can those resources share the same scope name? Right now the framework is suggesting that it cannot. I am getting the following:
When I ask for a token:
With the following ApiResource's (serialized):
being returned by the following method on class extending IResourceStore interface:
The text was updated successfully, but these errors were encountered: