mirror of
https://github.com/bitwarden/server.git
synced 2025-01-10 20:07:56 +01:00
build jwtoptions from JwtBearerAppBuilderExtensions
This commit is contained in:
parent
220243c8b4
commit
97c14100d2
@ -104,8 +104,8 @@ namespace Bit.Api.IdentityServer
|
|||||||
var httpContext = _httpContextAccessor.HttpContext;
|
var httpContext = _httpContextAccessor.HttpContext;
|
||||||
_userManager = httpContext.RequestServices.GetRequiredService<UserManager<User>>();
|
_userManager = httpContext.RequestServices.GetRequiredService<UserManager<User>>();
|
||||||
_identityOptions = httpContext.RequestServices.GetRequiredService<IOptions<IdentityOptions>>()?.Value ?? new IdentityOptions();
|
_identityOptions = httpContext.RequestServices.GetRequiredService<IOptions<IdentityOptions>>()?.Value ?? new IdentityOptions();
|
||||||
_jwtBearerOptions = httpContext.RequestServices.GetRequiredService<IOptions<JwtBearerOptions>>()?.Value;
|
|
||||||
_jwtBearerIdentityOptions = httpContext.RequestServices.GetRequiredService<IOptions<JwtBearerIdentityOptions>>()?.Value;
|
_jwtBearerIdentityOptions = httpContext.RequestServices.GetRequiredService<IOptions<JwtBearerIdentityOptions>>()?.Value;
|
||||||
|
_jwtBearerOptions = Core.Identity.JwtBearerAppBuilderExtensions.BuildJwtBearerOptions(_jwtBearerIdentityOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildSuccessResult(User user, ResourceOwnerPasswordValidationContext context)
|
private void BuildSuccessResult(User user, ResourceOwnerPasswordValidationContext context)
|
||||||
|
@ -23,7 +23,14 @@ namespace Bit.Core.Identity
|
|||||||
}
|
}
|
||||||
|
|
||||||
var jwtOptions = app.ApplicationServices.GetRequiredService<IOptions<JwtBearerIdentityOptions>>().Value;
|
var jwtOptions = app.ApplicationServices.GetRequiredService<IOptions<JwtBearerIdentityOptions>>().Value;
|
||||||
|
var options = BuildJwtBearerOptions(jwtOptions);
|
||||||
|
app.UseJwtBearerAuthentication(options);
|
||||||
|
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JwtBearerOptions BuildJwtBearerOptions(JwtBearerIdentityOptions jwtOptions)
|
||||||
|
{
|
||||||
var options = new JwtBearerOptions();
|
var options = new JwtBearerOptions();
|
||||||
|
|
||||||
// Basic settings - signing key to validate with, audience and issuer.
|
// Basic settings - signing key to validate with, audience and issuer.
|
||||||
@ -53,9 +60,7 @@ namespace Bit.Core.Identity
|
|||||||
OnMessageReceived = JwtBearerEventImplementations.MessageReceivedAsync
|
OnMessageReceived = JwtBearerEventImplementations.MessageReceivedAsync
|
||||||
};
|
};
|
||||||
|
|
||||||
app.UseJwtBearerAuthentication(options);
|
return options;
|
||||||
|
|
||||||
return app;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user