This commit is contained in:
@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.HttpOverrides;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
|
using Microsoft.IdentityModel.Protocols;
|
||||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||||
using ProofOfConcept.Models;
|
using ProofOfConcept.Models;
|
||||||
using ProofOfConcept.Services;
|
using ProofOfConcept.Services;
|
||||||
@@ -86,6 +87,8 @@ builder.Services
|
|||||||
o.Configuration.ClaimsSupported.Add("sub");
|
o.Configuration.ClaimsSupported.Add("sub");
|
||||||
o.Configuration.ClaimsSupported.Add("aud");
|
o.Configuration.ClaimsSupported.Add("aud");
|
||||||
|
|
||||||
|
o.ConfigurationManager =
|
||||||
|
|
||||||
// Standard OIDC web app settings
|
// Standard OIDC web app settings
|
||||||
o.ResponseType = OpenIdConnectResponseType.Code;
|
o.ResponseType = OpenIdConnectResponseType.Code;
|
||||||
o.UsePkce = true;
|
o.UsePkce = true;
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ public sealed class TeslaOIDCConfigurationManager : IConfigurationManager<OpenId
|
|||||||
|
|
||||||
public TeslaOIDCConfigurationManager(string metadataAddress)
|
public TeslaOIDCConfigurationManager(string metadataAddress)
|
||||||
{
|
{
|
||||||
_inner = new ConfigurationManager<OpenIdConnectConfiguration>(metadataAddress, new OpenIdConnectConfigurationRetriever());
|
OpenIdConnectConfigurationRetriever openIDConfigurationRetriever = new OpenIdConnectConfigurationRetriever();
|
||||||
|
_inner = new ConfigurationManager<OpenIdConnectConfiguration>(metadataAddress, new OpenIdConnectConfigurationRetriever(), new HttpDocumentRetriever());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OpenIdConnectConfiguration> GetConfigurationAsync(CancellationToken cancel)
|
public async Task<OpenIdConnectConfiguration> GetConfigurationAsync(CancellationToken cancel)
|
||||||
@@ -34,3 +35,19 @@ public sealed class TeslaOIDCConfigurationManager : IConfigurationManager<OpenId
|
|||||||
|
|
||||||
public void RequestRefresh() => _inner.RequestRefresh();
|
public void RequestRefresh() => _inner.RequestRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class TeslaDocumentRetriever : IDocumentRetriever
|
||||||
|
{
|
||||||
|
private readonly HttpDocumentRetriever httpDocumentRetriever;
|
||||||
|
|
||||||
|
public TeslaDocumentRetriever(HttpDocumentRetriever httpDocumentRetriever)
|
||||||
|
{
|
||||||
|
this.httpDocumentRetriever = httpDocumentRetriever;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string> GetDocumentAsync(string address, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
string document = await this.httpDocumentRetriever.GetDocumentAsync(address, cancel);
|
||||||
|
return document.Replace("https://fleet-auth.tesla.com/oauth2/v3", "https://fleet-auth.prd.vn.cloud.tesla.com/oauth2/v3");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user