public async Task TenantId() { var tenantConfig = TestConfig.ForTenantAwareFirebaseAuth("test-tenant"); var idTokenWithTenant = await tenantConfig.CreateIdTokenAsync(); FirebaseAuth auth = (FirebaseAuth)TestConfig.ForFirebaseAuth().CreateAuth(); var decoded = await auth.VerifyIdTokenAsync(idTokenWithTenant); tenantConfig.AssertFirebaseToken(decoded); Assert.Equal("test-tenant", decoded.TenantId); }
public async Task UseAfterDelete() { var app = FirebaseApp.Create(new AppOptions() { Credential = mockCredential }); FirebaseAuth auth = FirebaseAuth.DefaultInstance; app.Delete(); await Assert.ThrowsAsync <InvalidOperationException>( async() => await auth.CreateCustomTokenAsync("user")); await Assert.ThrowsAsync <InvalidOperationException>( async() => await auth.VerifyIdTokenAsync("user")); }
public async Task <string> CheckFireBaseUserToken(string idToken) { string ret = ""; try { FirebaseToken decodedToken = await authInstance.VerifyIdTokenAsync(idToken); ret = decodedToken.Uid; } catch (Exception ex) { SaveLog($"[Error] FireBaseHandler::CheckFireBaseUserToken, Catch Error, Msg:{ex.Message}"); } return(ret); }
public async Task <string> VerifyIdTokenAsync(string token) { FirebaseToken decoded; try { decoded = await _firebase.VerifyIdTokenAsync(token); } catch (FirebaseAuthException ex) { throw new Exception($"ID {token} not authorized at Firebase", ex); } catch (Exception ex) { throw new Exception("Exception calling _firebase.VerifyIdTokenAsync", ex); } return(decoded.Uid); }
public async Task UseAfterDelete() { var app = FirebaseApp.Create(new AppOptions() { Credential = MockCredential }); FirebaseAuth auth = FirebaseAuth.DefaultInstance; app.Delete(); await Assert.ThrowsAsync <InvalidOperationException>( async() => await auth.CreateCustomTokenAsync("user")); await Assert.ThrowsAsync <InvalidOperationException>( async() => await auth.VerifyIdTokenAsync("user")); await Assert.ThrowsAsync <InvalidOperationException>( async() => await auth.SetCustomUserClaimsAsync("user", null)); await Assert.ThrowsAsync <InvalidOperationException>( async() => await auth.GetOidcProviderConfigAsync("oidc.provider")); }
public async Task <ClaimsDto> VerifyTokenAsync(string jwt) { try { var token = await _firebaseApp.VerifyIdTokenAsync(jwt); var claimsDto = new ClaimsDto { Subject = token.Subject, Audience = token.Audience, Issuer = token.Issuer, ExpirationTimeSeconds = token.ExpirationTimeSeconds, IssuedAtTimeSeconds = token.IssuedAtTimeSeconds, Claims = token.Claims }; return(claimsDto); } catch (Exception e) { Console.WriteLine(e); throw; } }
public async Task <string> GetUid(string accessToken) { FirebaseToken decodedToken = await _auth.VerifyIdTokenAsync(accessToken); return(decodedToken.Uid); }
public async Task <FirebaseToken> VerifyIdToken(string idToken) { return(await auth.VerifyIdTokenAsync(idToken)); }