Jwks public parameters

openid
D4VID 1 month ago
parent a160c5e672
commit d3142bb021

@ -117,5 +117,18 @@ public class OAuthController(
return Ok(new { access_token = token, token_type = "bearer", id_token = token });
}
[Authorize]
[HttpGet("user")]
public ActionResult UserInfo() {
return Ok(new {
sub = "248289761001",
name = "Jane Doe",
// given_name = "Jane",
// family_name = "Doe",
// preferred_username = "j.doe",
email = "janedoe@example.com",
});
}
private record CodeObject(string ClientId, string RedirectUri, DateTime Expiry, string? Nonce);
}

@ -16,6 +16,7 @@ public class OpenIdController(
Issuer = "http://localhost:1234",
AuthorizationEndpoint = "http://localhost:1234/oauth/authorize",
TokenEndpoint = "http://localhost:1234/oauth/token",
UserInfoEndpoint = "http://localhost:1234/oauth/user",
JwksUri = "http://localhost:1234/.well-known/jwks.json",
ScopesSupported = ["openid"],
ResponseTypesSupported = ["code"],
@ -34,7 +35,7 @@ public class OpenIdController(
[HttpGet("/.well-known/jwks.json")]
public ActionResult<JwksResponse> GetJwks() {
var rsaSecurityKey = new RsaSecurityKey(jwtService.RsaKey) {
var rsaSecurityKey = new RsaSecurityKey(jwtService.RsaKey.ExportParameters(false)) {
KeyId = "TODO; keyid"
};
var jsonWebKey = JsonWebKeyConverter.ConvertFromRSASecurityKey(rsaSecurityKey);

@ -15,7 +15,6 @@ public class JwtService {
public static RSA GetSigningKey() {
RSA rsaKey = RSA.Create();
const string jwtKeyPath = ".aspnet/jwt-key";
const string jwtPubKeyPath = ".aspnet/jwt-key.pub";
string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
string fullPath = Path.Combine(home, jwtKeyPath);
if (File.Exists(fullPath)) {

Loading…
Cancel
Save