2using System.Threading.Tasks;
75 await
BadRequest(Response,
"invalid_request",
"Missing payload.");
93 if (!(Decoded.
Decoded is Dictionary<string, string> Form))
95 await
BadRequest(Response,
"invalid_request",
"Expected form data.");
100 Form.ContainsKey(
"client_secret") || Form.ContainsKey(
"password"))
102 await
BadRequest(Response,
"invalid_request",
"Multiple client credentials provided.");
106 if (!Form.TryGetValue(
"token", out
string Token) ||
string.IsNullOrEmpty(Token))
108 await
BadRequest(Response,
"invalid_request",
"Missing token.");
124 KeyValuePair<OAuthTokenType?, JwtToken?> P = await this.
Environment.
125 TokenResource.TryGetTokenType(Token);
128 ParsedToken = P.Value;
130 Active = TokenType.HasValue && (
131 TokenType == OAuthTokenType.AccessToken ||
135 Dictionary<string, object> Result =
new Dictionary<string, object>()
142 if (!(ParsedToken is
null))
144 foreach (KeyValuePair<string, object> P
in ParsedToken.
Claims)
146 Result[P.Key] = P.Value;
150 if (P.Value is
string UserName &&
151 !(await
this.Environment.UserSource.TryGetUser(UserName) is
null))
153 Result[
"username"] = UserName;
162 Result[
"token_type"] =
"Bearer";
165 Result[
"token_type"] =
"N_A";
168 await Response.
Return(Result);
Contains information about a response to a content request.
bool HasError
If an error occurred.
object Decoded
Decoded object.
Exception Error
Error response.
The server understood the request, but is refusing to fulfill it. Authorization will not help and the...
static ForbiddenException AccessDenied(string ObjectId, string ActorId)
Returns a ForbiddenException object, and logs a entry in the event log about the event.
Base class for all HTTP authentication schemes, as defined in RFC-7235: https://datatracker....
Represents an HTTP request.
HttpRequestHeader Header
Request header.
string RemoteEndPoint
Remote end-point.
bool HasData
If the request has data.
IUser User
Authenticated user, if available, or null if not available.
async Task< ContentResponse > DecodeDataAsync()
Decodes data sent in request.
string ResourceName
Name of resource.
Represets a response of an HTTP client request.
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
Task Return(Exception ex)
Returns an error to the client.
Manages the OAuth 2 environment.
void Register(OAuthAuthorizeResource? AuthorizeResource)
Registers an authorization resource.
bool HasTokenResource
If the environment has a registered token resource
OAUTH introspection resource, as defined in RFCs 7662. https://datatracker.ietf.org/doc/html/rfc7662
OAuthIntrospectionResource(OAuth2Environment Environment)
OAUTH introspection resource, as defined in RFCs 7662.
override? HttpAuthenticationScheme[] GetAuthenticationSchemes(HttpRequest Request)
Any authentication schemes used to authenticate users before access is granted to the corresponding r...
const string DefaultResourcePath
Default introspection resource path: /oauth/introspect
const string OAuthIntrospectionPrivilege
Privilege for OAUTH introspection.
bool AllowsPOST
If the POST method is allowed.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
OAuthIntrospectionResource(OAuth2Environment Environment, string ResourceName)
OAUTH introspection resource, as defined in RFCs 7662.
Abstract base class for OAUTH resources.
OAuth2Environment Environment
OAUTH2 environment, used to access clients, tokens, and other resources.
bool InitAuthentication()
Initializes authentication schemes, if not already initialized.
static Task BadRequest(HttpResponse Response, string ErrorCode, string ErrorDescription)
Returns a Bad Request error back to the client.
HttpAuthenticationScheme?[] AuthenticationSchemes
Available authentication schemes, if initialized.
Static class containing predefined JWT claim names.
const string Subject
Subject of the JWT (the user)
Contains information about a Java Web Token (JWT). JWT is defined in RFC 7519: https://tools....
IEnumerable< KeyValuePair< string, object > > Claims
Claims provided in token. For a list of public claim names, see: https://www.iana....
POST Interface for HTTP resources.
OAuthTokenType
Type of OAuth token.