Skip to content

Commit 5e3c7a1

Browse files
author
Fernando Cainelli
committed
add firebase.sign_in_second_factor claim to FirebaseInfo
Signed-off-by: Fernando Cainelli <[email protected]>
1 parent 87b867c commit 5e3c7a1

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Diff for: auth/auth.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,11 @@ type Token struct {
266266
//
267267
// This data is provided by the Firebase Auth service and is a reserved claim in the ID token.
268268
type FirebaseInfo struct {
269-
SignInProvider string `json:"sign_in_provider"`
270-
Tenant string `json:"tenant"`
271-
Identities map[string]interface{} `json:"identities"`
269+
SignInProvider string `json:"sign_in_provider"`
270+
Tenant string `json:"tenant"`
271+
Identities map[string]interface{} `json:"identities"`
272+
SignInSecondFactor string `json:"sign_in_second_factor"`
273+
SecondFactorIdentifier string `json:"second_factor_identifier"`
272274
}
273275

274276
// baseClient exposes the APIs common to both auth.Client and auth.TenantClient.

Diff for: auth/auth_test.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const (
4141
testVersion = "test-version"
4242
defaultIDToolkitV1Endpoint = "https://identitytoolkit.googleapis.com/v1"
4343
defaultIDToolkitV2Endpoint = "https://identitytoolkit.googleapis.com/v2"
44+
secondFactorIdentifier = "aaaaaaaa-1111-bbbb-2222-cccccccccccc"
4445
)
4546

4647
var (
@@ -466,6 +467,12 @@ func TestVerifyIDToken(t *testing.T) {
466467
if ft.UID != ft.Subject {
467468
t.Errorf("UID = %q; Sub = %q; want UID = Sub", ft.UID, ft.Subject)
468469
}
470+
if ft.Firebase.SignInSecondFactor != "totp" {
471+
t.Errorf("SignInSecondFactor = %q; want = %q", ft.Firebase.SignInSecondFactor, "totp")
472+
}
473+
if ft.Firebase.SecondFactorIdentifier != secondFactorIdentifier {
474+
t.Errorf("SecondFactorIdentifier = %q; want = %q", ft.Firebase.SecondFactorIdentifier, secondFactorIdentifier)
475+
}
469476
}
470477

471478
func TestVerifyIDTokenFromTenant(t *testing.T) {
@@ -1362,8 +1369,10 @@ func getIDTokenWithSignerAndKid(signer cryptoSigner, kid string, p mockIDTokenPa
13621369
"auth_time": testClock.Now().Unix() - 100,
13631370
"sub": "1234567890",
13641371
"firebase": map[string]interface{}{
1365-
"identities": map[string]interface{}{},
1366-
"sign_in_provider": "custom",
1372+
"identities": map[string]interface{}{},
1373+
"sign_in_provider": "custom",
1374+
"sign_in_second_factor": "totp",
1375+
"second_factor_identifier": secondFactorIdentifier,
13671376
},
13681377
"admin": true,
13691378
}

0 commit comments

Comments
 (0)