tgstation-server 6.19.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
KeycloakOAuthValidator.cs
Go to the documentation of this file.
1using System;
2using System.Net.Http;
3
4using Microsoft.Extensions.Logging;
5
8
10{
15 {
17#pragma warning disable CS0618 // Type or member is obsolete
18 public override OAuthProvider Provider => OAuthProvider.Keycloak;
19#pragma warning restore CS0618 // Type or member is obsolete
20
22 protected override Uri TokenUrl => new($"{BaseProtocolPath}/token");
23
25 protected override Uri UserInformationUrl => new($"{BaseProtocolPath}/userinfo");
26
30 string BaseProtocolPath => $"{OAuthConfiguration.ServerUrl}/protocol/openid-connect";
31
39 IHttpClientFactory httpClientFactory,
40 ILogger<KeycloakOAuthValidator> logger,
41 OAuthConfiguration oAuthConfiguration)
42 : base(httpClientFactory, logger, oAuthConfiguration)
43 {
44 }
45
47 protected override OAuthTokenRequest CreateTokenRequest(string code) => new(OAuthConfiguration, code, "openid");
48
50 protected override string DecodeTokenPayload(dynamic responseJson) => responseJson.access_token;
51
53 protected override string DecodeUserInformationPayload(dynamic responseJson) => responseJson.sub;
54 }
55}
OAuthConfiguration OAuthConfiguration
The OAuthConfiguration for the GenericOAuthValidator.
readonly IHttpClientFactory httpClientFactory
The IHttpClientFactory for the GenericOAuthValidator.
override string DecodeUserInformationPayload(dynamic responseJson)
override string DecodeTokenPayload(dynamic responseJson)
override OAuthTokenRequest CreateTokenRequest(string code)
KeycloakOAuthValidator(IHttpClientFactory httpClientFactory, ILogger< KeycloakOAuthValidator > logger, OAuthConfiguration oAuthConfiguration)
Initializes a new instance of the KeycloakOAuthValidator class.
string BaseProtocolPath
Base path to the server's OAuth endpoint.
override OAuthProvider Provider
The OAuthProvider this validator is for.
OAuthProvider
List of OAuth2.0 providers supported by TGS that do not support OIDC.