question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Revamping application permissions in OpenIddict RC3

See original GitHub issue

In RC2, we introduced application permissions. To make the migration from RC1 to RC2 smoother, application permissions were mostly optional and OpenIddict had a fallback mechanism called “implicit permissions” it used to determine whether an application could perform the requested action. For instance, if no permission was explicitly attached to the application, it was considered fully trusted and was granted all the permissions.

Similarly, if you granted the “token endpoint” permission to an application but NO “grant type” permission, it was assumed the client application was allowed to use the password or client credentials grants.

Retrospectively, this logic was too complex and I decided to remove it in RC3.

What will change in RC3?

Starting with RC3, permissions are no longer optional nor implicit: if you don’t explicitly grant an application the necessary permissions, it will be blocked by OpenIddict.

To attach permissions to an application, use OpenIddictApplicationManager:

var descriptor = new OpenIddictApplicationDescriptor
{
    ClientId = "mvc",
    ClientSecret = "901564A5-E7FE-42CB-B10D-61EF6A8F3654",
    DisplayName = "MVC client application",
    PostLogoutRedirectUris = { new Uri("http://localhost:53507/signout-callback-oidc") },
    RedirectUris = { new Uri("http://localhost:53507/signin-oidc") },
    Permissions =
    {
        OpenIddictConstants.Permissions.Endpoints.Authorization,
        OpenIddictConstants.Permissions.Endpoints.Logout,
        OpenIddictConstants.Permissions.Endpoints.Token,
        OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
        OpenIddictConstants.Permissions.GrantTypes.RefreshToken,
        OpenIddictConstants.Permissions.Scopes.Email,
        OpenIddictConstants.Permissions.Scopes.Profile,
        OpenIddictConstants.Permissions.Scopes.Roles
    }
};

await _applicationManager.CreateAsync(descriptor);

What if I don’t want to use permissions?

If you don’t care about permissions (e.g because you don’t have third-party clients), you can disable them:

services.AddOpenIddict()

    // Register the OpenIddict server handler.
    .AddServer(options =>
    {
        options.IgnoreEndpointPermissions();
        options.IgnoreGrantTypePermissions();
        options.IgnoreScopePermissions();
    });

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
replaysMikecommented, Jul 25, 2018

I see why my migrations didn’t have the schema - my EF project is separate from the web project. I needed to add in my ef context (as pointed out by https://github.com/openiddict/openiddict-core/issues/401):

protected override void OnModelCreating(ModelBuilder builder)
{
    base.OnModelCreating(builder);
    // Add your customizations after calling base.OnModelCreating(builder);
    builder.UseOpenIddict();
}
0reactions
replaysMikecommented, Jul 25, 2018

Indeed, deleting the database and having that call run again recreated all the proper schema. I probably did this in 2 steps and didn’t add OpenIddict until after. Probably related to this issue - https://github.com/openiddict/openiddict-core/issues/439

I’ll make sure to put proper migrations in, this isn’t related to RC3 then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenIddict RC3 is out | Kévin Chalet's blog
For instance, if no permission was explicitly attached to the application, it was considered fully trusted and was granted all the permissions.
Read more >
Implementing advanced scenarios using the new OpenIddict ...
In this post, discover how to leverage the events model introduced in OpenIddict RC3 to implement advanced features.
Read more >
Application permissions - OpenIddict documentation
OpenIddict includes a built-in feature codenamed "application permissions" that allows controlling and limiting the OAuth 2.0/OpenID Connect features each ...
Read more >
Openiddict
IIS OpenIddict WindowsCryptographicExcepti. NET Core Web Application dialog, select Change under Authentication. NET Core Web Application dialog, ...
Read more >
SQLite | Software Engineering
This article shows how to implement authentication and secure a Blazor WASM application hosted in ASP.NET Core using the backend for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found