Authorization Code Grantと、Implicit Grantと、Client Credentials Grantと、Resource Owner Password Credentials Grantが再現出来たので、Discoveryも再現しようと思います。
Discoveryコントローラーを作成します。
http://localhost:5000/op/.well-known/openid-configuration
Controllers/DiscoveryController.cs
usingSystem;usingSystem.IO;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Threading.Tasks;usingMicrosoft.AspNetCore.Http;usingMicrosoft.AspNetCore.Mvc;usingMicrosoft.EntityFrameworkCore;usingmyop.Models;namespacemyop.Controllers{publicclassDiscovery{publicstringissuer{get;set;}publicstring[]grant_types_supported{get;set;}publicstring[]response_types_supported{get;set;}publicstringauthorization_endpoint{get;set;}publicstringtoken_endpoint{get;set;}publicstringintrospection_endpoint{get;set;}}[Route("op/.well-known/openid-configuration")][ApiController]publicclassDiscoveryController:ControllerBase{privatereadonlymyopContext_context;publicDiscoveryController(myopContextcontext){_context=context;}// GET: op/.well-known/openid-configuration[HttpGet]publicasyncTask<ActionResult<Discovery>>doGet(){Discoverydiscovery=newDiscovery{issuer="http://localhost:5000/op",grant_types_supported=newstring[]{"authorization_code","implicit","client_credentials","password"},response_types_supported=newstring[]{"code"},authorization_endpoint="http://localhost:5000/op/auth",token_endpoint="http://localhost:5000/op/token",introspection_endpoint="http://localhost:5000/op/introspect"};returndiscovery;}}}
動作確認してみます。
$ curl http://localhost:5000/op/.well-known/openid-configuration
{"issuer":"http://localhost:5000/op","grant_types_supported":["authorization_code","implicit","client_credentials","password"],"response_types_supported":["code"],"authorization_endpoint":"http://localhost:5000/op/auth","token_endpoint":"http://localhost:5000/op/token","introspection_endpoint":"http://localhost:5000/op/introspect"}