From c84ff7aa2d347c45e1d350811e3a0c7404a6e1ad Mon Sep 17 00:00:00 2001 From: Andrey Yadryshnikov Date: Wed, 15 Nov 2023 10:31:53 +0500 Subject: [PATCH] Custom url for get token public keys --- FirebaseAdmin/FirebaseAdmin/AppOptions.cs | 6 ++++++ .../FirebaseAdmin/Auth/Jwt/FirebaseTokenVerifier.cs | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/FirebaseAdmin/FirebaseAdmin/AppOptions.cs b/FirebaseAdmin/FirebaseAdmin/AppOptions.cs index d7f28133..81ce9ca6 100644 --- a/FirebaseAdmin/FirebaseAdmin/AppOptions.cs +++ b/FirebaseAdmin/FirebaseAdmin/AppOptions.cs @@ -38,6 +38,7 @@ internal AppOptions(AppOptions options) this.ProjectId = options.ProjectId; this.ServiceAccountId = options.ServiceAccountId; this.HttpClientFactory = options.HttpClientFactory; + this.TokenCertUrl = options.TokenCertUrl; } /// @@ -66,5 +67,10 @@ internal AppOptions(AppOptions options) /// Gets or sets the HttpClientFactory to use when making Firebase requests. /// public HttpClientFactory HttpClientFactory { get; set; } + + /// + /// Gets or sets the TokenCertUrl to use custom public key url. + /// + public string TokenCertUrl { get; set; } } } diff --git a/FirebaseAdmin/FirebaseAdmin/Auth/Jwt/FirebaseTokenVerifier.cs b/FirebaseAdmin/FirebaseAdmin/Auth/Jwt/FirebaseTokenVerifier.cs index 50fad5f7..85ab9762 100644 --- a/FirebaseAdmin/FirebaseAdmin/Auth/Jwt/FirebaseTokenVerifier.cs +++ b/FirebaseAdmin/FirebaseAdmin/Auth/Jwt/FirebaseTokenVerifier.cs @@ -102,8 +102,11 @@ internal static FirebaseTokenVerifier CreateIdTokenVerifier( "Must initialize FirebaseApp with a project ID to verify ID tokens."); } + var tokenCertUrl = string.IsNullOrEmpty(app.Options.TokenCertUrl) + ? IdTokenCertUrl + : app.Options.TokenCertUrl; var keySource = new HttpPublicKeySource( - IdTokenCertUrl, SystemClock.Default, app.Options.HttpClientFactory); + tokenCertUrl, SystemClock.Default, app.Options.HttpClientFactory); var args = CreateIdTokenVerifierArgs(); args.ProjectId = projectId; args.TenantId = tenantId;