Esempio n. 1
0
        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.");
            }
        }
Esempio n. 2
0
        internal static FirebaseTokenVerifier CreateSessionCookieVerifier(
            string projectId,
            IPublicKeySource keySource,
            IClock clock = null)
        {
            var args = 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,
                PublicKeySource  = keySource,
                InvalidTokenCode = AuthErrorCode.InvalidSessionCookie,
                ExpiredTokenCode = AuthErrorCode.ExpiredSessionCookie,
            };

            return(new FirebaseTokenVerifier(args));
        }
Esempio n. 3
0
        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));
        }