Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AuthorizationServerMetaData.cs
2using System.Text;
3using System.Threading.Tasks;
7
9{
15 {
19 public const string WellKnowResourcePath = "/.well-known/oauth-authorization-server";
20
27 {
29 }
30
34 public bool AllowsGET => true;
35
42 public async Task GET(HttpRequest Request, HttpResponse Response)
43 {
44 StringBuilder sb = ProtectedResourceMetaData.GenerateServerUrl(Request, out _);
45 string ServerUrl = sb.ToString();
46
48 string AuthorizeUri = sb.ToString();
49 string TokenUri = ServerUrl + OAuthTokenResource.DefaultResourcePath;
50
51 ChunkedList<string> GrantTypesSupported = new ChunkedList<string>(6)
52 {
53 "authorization_code",
54 "implicit",
55 "client_credentials",
56 "password",
57 "refresh_token"
58 };
59
62
63 Dictionary<string, object> MetaData = new Dictionary<string, object>()
64 {
65 { "issuer", ServerUrl },
66 { "authorization_endpoint", AuthorizeUri },
67 { "token_endpoint", TokenUri },
68 { "scopes_supported", OAuthScopesSupportedAttribute.RegisteredScopes },
69 { "token_endpoint_auth_methods_supported", new string[]
70 {
71 "client_secret_basic",
72 "client_secret_post"
73 }
74 },
75 { "token_endpoint_auth_signing_alg_values_supported", JwsAlgorithm.GetAlgorithmNames() },
76 { "response_types_supported", new string[] { "code", "token" } },
77 { "code_challenge_methods_supported", new string[] { "plain", "S256" } },
78 { "authorization_response_iss_parameter_supported", this.JwtFactory.HasIssuer },
79 { "grant_types_supported", GrantTypesSupported.ToArray() }
80 };
81
83 MetaData["registration_endpoint"] = ServerUrl + this.Environment.RegistrationResource.ResourceName;
84
86 MetaData["device_authorization_endpoint"] = ServerUrl + this.Environment.DeviceAuthorizationResource.ResourceName;
87
89 {
90 MetaData["introspection_endpoint"] = ServerUrl + this.Environment.IntrospectionResource.ResourceName;
91 MetaData["introspection_endpoint_auth_methods_supported"] = new string[]
92 {
93 "client_secret_basic",
94 "client_secret_post"
95 };
96 }
97
98 await Response.Return(MetaData);
99 }
100 }
101}
Represents an HTTP request.
Definition: HttpRequest.cs:22
string ResourceName
Name of resource.
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:23
Task Return(Exception ex)
Returns an error to the client.
Provides OAUTH authorization server meta-data, as defined in RFC 8414. https://datatracker....
AuthorizationServerMetaData(OAuth2Environment Environment)
Provides OAUTH authorization server meta-data, as defined in RFC 8414.
async Task GET(HttpRequest Request, HttpResponse Response)
Executes the GET method on the resource.
bool HasIntrospectionResource
If the environment has a registered introspection resource
OAuthIntrospectionResource IntrospectionResource
Registered introspection resource
OAuthDeviceAuthorizationResource DeviceAuthorizationResource
Registered device authorization resource
OAuthAuthorizeResource AuthorizeResource
Registered authorization resource
OAuthRegistrationResource RegistrationResource
Registered registration resource
void Register(OAuthAuthorizeResource? AuthorizeResource)
Registers an authorization resource.
bool HasRegistrationResource
If the environment has a registered registration resource
bool HasDeviceAuthorizationResource
If the environment has a registered device authorization resource
OAUTH device authorization resource, as defined in RFC 8628. https://datatracker.ietf....
const string GrantType
Grant Type for device authorization flow.
Abstract base class for OAUTH resources.
OAuth2Environment Environment
OAUTH2 environment, used to access clients, tokens, and other resources.
OAUTH token resource, as defined in RFC 6749. https://datatracker.ietf.org/doc/html/rfc6749
const string DefaultResourcePath
Default token resource path: /oauth/token
Provides OAUTH resource meta-data, as defined in RFC 9728. https://datatracker.ietf....
static StringBuilder GenerateServerUrl(HttpRequest Request, out int Port)
Generates a server URL, based on the request.
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54
void Add(T Item)
Adds an item to the collection.
Definition: ChunkedList.cs:272
T[] ToArray()
Returns an array containing all elements of the collection.
Abstract base class for JWS algorithm.
Definition: JwsAlgorithm.cs:15
static string[] GetAlgorithmNames()
Gets the names of available JWS algorithms.
GET Interface for HTTP resources.
Definition: ImplTypes.g.cs:58