tgstation-server 5.12.7
The /tg/station 13 server suite
Loading...
Searching...
No Matches
KeycloakOAuthValidator.cs
Go to the documentation of this file.
1using System;
2
3using Microsoft.Extensions.Logging;
4
8
10{
15 {
17 public override OAuthProvider Provider => OAuthProvider.Keycloak;
18
20 protected override Uri TokenUrl => new ($"{BaseProtocolPath}/token");
21
23 protected override Uri UserInformationUrl => new ($"{BaseProtocolPath}/userinfo");
24
28 string BaseProtocolPath => $"{OAuthConfiguration.ServerUrl}/protocol/openid-connect";
29
38 ILogger<KeycloakOAuthValidator> logger,
39 OAuthConfiguration oAuthConfiguration)
40 : base(httpClientFactory, logger, oAuthConfiguration)
41 {
42 }
43
45 protected override OAuthTokenRequest CreateTokenRequest(string code) => new (OAuthConfiguration, code, "openid");
46
48 protected override string DecodeTokenPayload(dynamic responseJson) => responseJson.access_token;
49
51 protected override string DecodeUserInformationPayload(dynamic responseJson) => responseJson.sub;
52 }
53}
IOAuthValidator for generic OAuth2 endpoints.
OAuthConfiguration OAuthConfiguration
The OAuthConfiguration for the GenericOAuthValidator.
readonly IAbstractHttpClientFactory httpClientFactory
The IHttpClientFactory for the GenericOAuthValidator.
override string DecodeUserInformationPayload(dynamic responseJson)
Decode the user information payload responseJson . The user ID on success, null otherwise.
override string DecodeTokenPayload(dynamic responseJson)
Decode the token payload responseJson . The OAuth2 bearer access token on success,...
KeycloakOAuthValidator(IAbstractHttpClientFactory httpClientFactory, ILogger< KeycloakOAuthValidator > logger, OAuthConfiguration oAuthConfiguration)
Initializes a new instance of the KeycloakOAuthValidator class.
override OAuthTokenRequest CreateTokenRequest(string code)
Create the OAuthTokenRequest for a given code . The OAuthTokenRequest to send to TokenUrl.
string BaseProtocolPath
Base path to the server's OAuth endpoint.
override OAuthProvider Provider
The OAuthProvider this validator is for.
OAuthProvider
List of OAuth providers supported by TGS.