Simple Password Grant fails after alpha2-0410
See original GitHub issueI am able to get a token via password grant flow on version 1.0.0-alpha2-0410
and older, but in any newer versions (NuGet skips forward to 0417) password grant won’t give me a token, it 404s.
The only clue I have is that when it was working it complained : AspNet.Security.OpenIdConnect.Server.OpenIdConnectServerMiddleware: Information: No explicit audience was associated with the access token.
With newer versions it doesn’t complain about audience but doesn’t give me a token either, just 404s. It complains normally about missing fields if I break the request.
This most of my code, it is very simple with nothing custom added in the database (local MS-SQL).
ConfigureServices
services.AddMvc();
// Add the database context, defaults to scoped; new context for each request.
services.AddDbContext<QbDbContext>(
options => { options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")); });
// Adds Identity to IoC and confugres with the database.
services.AddIdentity<QbUser, IdentityRole>(ConfigureIdentityOptions)
.AddEntityFrameworkStores<QbDbContext>()
.AddDefaultTokenProviders();
services.AddOpenIddict<QbUser, QbDbContext>()
.EnableTokenEndpoint("/api/auth/token") // Password grant route
.AllowPasswordFlow() // Enables password grant
.DisableHttpsRequirement() // TODO: Must unset this in production
.AddEphemeralSigningKey() // TODO: Must unset this in production
.SetAccessTokenLifetime(TimeSpan.FromDays(365));
private static void ConfigureIdentityOptions(IdentityOptions options)
{
options.SignIn.RequireConfirmedEmail = false;
options.SignIn.RequireConfirmedPhoneNumber = true;
options.Password.RequireDigit = false;
options.Password.RequireLowercase = false;
options.Password.RequireUppercase = false;
options.Password.RequireNonAlphanumeric = false;
options.Password.RequiredLength = 8;
}
Configure
app.UseIdentity(); // Authorization using ASP Identity.
app.UseOAuthValidation();
app.UseOpenIddict(); // OpenIddict takes care of the token issuing.
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
public class QbUser : OpenIddictUser
{
}
public class QbDbContext : OpenIddictDbContext<QbUser>
{
public QbDbContext(DbContextOptions options) : base(options)
{
}
}
Am I doing something obvious wrong or is there a bug?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
what's the alternative to password grant now that it is ...
The Resource Owner Password Grant solved your problem perfectly fine, but now it got deprecated :( Note It says in the OAuth 2.0...
Read more >Don't use the OAuth password grant type - Scott Brady
The resource owner password credentials grant type involves the application impersonating the user. When you use OAuth, you're after delegation ...
Read more >What is the OAuth 2.0 Password Grant Type?
The Password grant is one of the simplest OAuth grants and involves only one step: the application presents a traditional username and password ......
Read more >Implementing the password grant type | Apigee Edge
The following flow diagram illustrates the resource owner password grant type flow with Apigee Edge serving as the authorization server. Tip: To see...
Read more >OAuth 2.0 Password Grant Type
The latest OAuth 2.0 Security Best Current Practice disallows the password grant entirely, and the grant is not defined in OAuth 2.1. More...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s definitely an unwanted consequence of the recent design change I mentioned. Looks like we’ll have to rework it a bit 😄
Will be fixed by https://github.com/openiddict/openiddict-core/pull/203. The approach I have in mind is to make having your own “token endpoint action” mandatory to support password token requests. i.e you’ll have to include something like that in your project:
(of course, token requests will still be validated by OpenIddict itself before MVC is invoked)