internal FirebaseTokenVerifier(FirebaseTokenVerifierArgs args) { this.ProjectId = args.ProjectId.ThrowIfNullOrEmpty(nameof(args.ProjectId)); this.shortName = args.ShortName.ThrowIfNullOrEmpty(nameof(args.ShortName)); this.operation = args.Operation.ThrowIfNullOrEmpty(nameof(args.Operation)); this.url = args.Url.ThrowIfNullOrEmpty(nameof(args.Url)); this.issuer = args.Issuer.ThrowIfNullOrEmpty(nameof(args.Issuer)); this.clock = args.Clock ?? SystemClock.Default; this.keySource = args.PublicKeySource.ThrowIfNull(nameof(args.PublicKeySource)); this.invalidTokenCode = args.InvalidTokenCode; this.expiredIdTokenCode = args.ExpiredTokenCode; if ("aeiou".Contains(this.shortName.ToLower().Substring(0, 1))) { this.articledShortName = $"an {this.shortName}"; } else { this.articledShortName = $"a {this.shortName}"; } this.TenantId = args.TenantId; if (this.TenantId == string.Empty) { throw new ArgumentException("Tenant ID must not be empty."); } }
internal static FirebaseTokenVerifierArgs ForIdTokens( string projectId, IPublicKeySource keySource, IClock clock = null) { return(new FirebaseTokenVerifierArgs() { ProjectId = projectId, ShortName = "ID token", Operation = "VerifyIdTokenAsync()", Url = "https://firebase.google.com/docs/auth/admin/verify-id-tokens", Issuer = "https://securetoken.google.com/", Clock = clock ?? SystemClock.Default, PublicKeySource = keySource, }); }
internal static FirebaseTokenVerifierArgs ForSessionCookies( string projectId, IPublicKeySource keySource, IClock clock = null) { return(new FirebaseTokenVerifierArgs() { ProjectId = projectId, ShortName = "session cookie", Operation = "VerifySessionCookieAsync()", Url = "https://firebase.google.com/docs/auth/admin/manage-cookies", Issuer = "https://session.firebase.google.com/", Clock = clock ?? SystemClock.Default, PublicKeySource = keySource, InvalidTokenCode = AuthErrorCode.InvalidSessionCookie, ExpiredTokenCode = AuthErrorCode.ExpiredSessionCookie, }); }
public FirebaseTokenVerifier(FirebaseTokenVerifierArgs args) { ProjectId = args.ProjectId.ThrowIfNullOrEmpty(nameof(args.ProjectId)); _shortName = args.ShortName.ThrowIfNullOrEmpty(nameof(args.ShortName)); _operation = args.Operation.ThrowIfNullOrEmpty(nameof(args.Operation)); _url = args.Url.ThrowIfNullOrEmpty(nameof(args.Url)); _issuer = args.Issuer.ThrowIfNullOrEmpty(nameof(args.Issuer)); _clock = args.Clock.ThrowIfNull(nameof(args.Clock)); _keySource = args.PublicKeySource.ThrowIfNull(nameof(args.PublicKeySource)); if ("aeiou".Contains(_shortName.ToLower().Substring(0, 1))) { _articledShortName = $"an {_shortName}"; } else { _articledShortName = $"a {_shortName}"; } }
internal FirebaseTokenVerifier(FirebaseTokenVerifierArgs args) { this.ProjectId = args.ProjectId.ThrowIfNullOrEmpty(nameof(args.ProjectId)); this.shortName = args.ShortName.ThrowIfNullOrEmpty(nameof(args.ShortName)); this.operation = args.Operation.ThrowIfNullOrEmpty(nameof(args.Operation)); this.url = args.Url.ThrowIfNullOrEmpty(nameof(args.Url)); this.issuer = args.Issuer.ThrowIfNullOrEmpty(nameof(args.Issuer)); this.clock = args.Clock.ThrowIfNull(nameof(args.Clock)); this.keySource = args.PublicKeySource.ThrowIfNull(nameof(args.PublicKeySource)); if ("aeiou".Contains(this.shortName.ToLower().Substring(0, 1))) { this.articledShortName = $"an {this.shortName}"; } else { this.articledShortName = $"a {this.shortName}"; } }
internal static FirebaseTokenVerifier CreateIdTokenVerifier( string projectId, IPublicKeySource keySource, IClock clock = null, string tenantId = null) { var args = new FirebaseTokenVerifierArgs { ProjectId = projectId, TenantId = tenantId, ShortName = "ID token", Operation = "VerifyIdTokenAsync()", Url = "https://firebase.google.com/docs/auth/admin/verify-id-tokens", Issuer = "https://securetoken.google.com/", Clock = clock, PublicKeySource = keySource, InvalidTokenCode = AuthErrorCode.InvalidIdToken, ExpiredTokenCode = AuthErrorCode.ExpiredIdToken, }; return(new FirebaseTokenVerifier(args)); }