Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: add sign_in_second_factor claim to FirebaseInfo #619

Open
cainelli opened this issue May 16, 2024 · 0 comments
Open

FR: add sign_in_second_factor claim to FirebaseInfo #619

cainelli opened this issue May 16, 2024 · 0 comments

Comments

@cainelli
Copy link

cainelli commented May 16, 2024

Environment

  • Firebase SDK version: v4.13.0
  • Firebase Product: auth

Describe the problem

I would like to have access to sign_in_second_factor to perform extra authorization based on this claim. It would be much cleaner if given by the SDK already instead of the workaround I'm using:

type FirebaseInfo struct {
	auth.FirebaseInfo
	SignInSecondFactor string `json:"sign_in_second_factor,omitempty"`
}

func verifyMFA(claims map[string]any) error {
	b, err := json.Marshal(claims["firebase"])
	if err != nil {
		return fmt.Errorf("could not marshal firebase info: %w", err)
	}
	var firebaseInfo FirebaseInfo
	if err := json.Unmarshal(b, &firebaseInfo); err != nil {
		return fmt.Errorf("could not unmarshal firebase info: %w", err)
	}
	if firebaseInfo.SignInSecondFactor == "" {
		return fmt.Errorf("2FA enforced but not enrolled")
	}
        return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants