You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.5 KiB

using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using OAuthServer.Responses;
using OAuthServer.Services;
namespace OAuthServer.Controllers;
[ApiController]
public class OpenIdController(
JwtService jwtService
) : ControllerBase {
[HttpGet("/.well-known/openid-configuration")]
public ActionResult<OpenIdConfiguration> GetOpenIdConfiguration() {
return Ok(new OpenIdConfiguration {
Issuer = "http://localhost:1234",
AuthorizationEndpoint = "http://localhost:1234/oauth/authorize",
TokenEndpoint = "http://localhost:1234/oauth/token",
JwksUri = "http://localhost:1234/.well-known/jwks.json",
ScopesSupported = ["openid"],
ResponseTypesSupported = ["code"],
GrantTypesSupported = ["authorization_code"],
SubjectTypesSupported = ["public"],
IdTokenSigningAlgValuesSupported = ["RS256"],
ClaimsSupported = [
"aud",
"exp",
"iat",
"iss",
"sub"
]
});
}
[HttpGet("/.well-known/jwks.json")]
public ActionResult<JwksResponse> GetJwks() {
var rsaSecurityKey = new RsaSecurityKey(jwtService.RsaKey) {
KeyId = "TODO; keyid"
};
var jsonWebKey = JsonWebKeyConverter.ConvertFromRSASecurityKey(rsaSecurityKey);
return Ok(new JwksResponse {
Keys = [jsonWebKey]
});
}
}