-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Duende.IdentityServer from Blazor WebAssembly App protecting ASP.NET Core API using Client Credentials with custom allowed scope - invalid_scope #44122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@javiercn @SteveSandersonMS Can you please take a look at this? |
@Ogglas thanks for contacting us. Does the same configuration work without using our integration package? |
Hi @Ogglas. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@javiercn Yes it does. You can try it out by installing Duende IdentityServer Templates like this:
https://docs.duendesoftware.com/identityserver/v5/quickstarts/0_overview/ Then create a new project with template: "Duende IdentityServer with ASP.NET Core Identity (Duende Software)" Works: Does not work: I did manage to get an extra scope like this:
However If I remove
I'm guessing it has something to do with Using the following code:
|
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
@adityamandaleeka @javiercn @SteveSandersonMS I noticed something else as well. Using the following code:
I get a token with the following request:
I then tried to create a policy like this:
And use it like this:
Using the |
My Blazor app stopped working with a "invalid_scope". Source: https://github.com/marinasundstrom/todo-app Here is the Identity Server log:
IdentityServer config: public static IEnumerable<ApiResource> ApiResources =>
new ApiResource[]
{
// the api requires the role claim
new ApiResource("myapi", "The Web Api", new[] { JwtClaimTypes.Name, JwtClaimTypes.PreferredUserName, JwtClaimTypes.Email, JwtClaimTypes.Role })
{
Scopes = new string[] { "myapi" }
}
}; I started working again when I removed the scope "email" from "DefaultScopes" in appsettings.json in my Blazor app: {
"Local": {
"Authority": "https://localhost:5041",
"ClientId": "clientapp",
"RedirectUri": "https://localhost:5021/authentication/login-callback",
"ResponseType": "code",
"DefaultScopes": [
"openid",
"profile",
// "email",
"myapi"
],
"PostLogoutRedirectUri": "https://localhost:5021/"
}
} |
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
I have a
Blazor WebAssembly App
created withMicrosoft Visual Studio
with these specifications:Target Framework .NET 6.0
,Authentication Type Individual Accounts
andASP.NET Core Hosted
:Using this answer I have been able to add Client Credentials flow
https://stackoverflow.com/a/67324222/3850405
I removed this from
appsettings.json
:Edit
Startup.cs
orProgram.cs
:This request will work:
However I want this client to have its own
AllowedScopes
. If I then changeAllowedScopes = { "WebApplication4.ServerAPI"}
toAllowedScopes = { "WebApplication4.IntegrationAPI"}
and of course modifying the request.Server then responds with:
If I look at logging I get the following history:
What I take with me is this:
I then looked at these guides:
DuendeArchive/IdentityServer4#4632 (comment)
https://docs.duendesoftware.com/identityserver/v5/quickstarts/1_client_credentials/
I therefore added this code:
and
This still gave me the same error.
I then added a new list with clients:
Removed the old client from
AddApiAuthorization
and used this code instead:This gave me a new error when requesting a token:
Logs:
If I look at https://localhost:44397/.well-known/openid-configuration I only see
WebApplication4.ServerAPI
inscopes_supported
no matter the configuration.Describe the solution you'd like
I want to do it like this so that I can add a policy like this later:
Meaning that I only want Client Credentials flow to get the scope
WebApplication4.IntegrationAPI
and I don't want Authorization Code Grant, normal login flow viaauthorization_code
, to have this scope or be able to request this scope.Additional context
No response
The text was updated successfully, but these errors were encountered: