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

Dynamic Issuer and Server Name #142

Closed
rconstant opened this issue May 11, 2022 · 2 comments
Closed

Dynamic Issuer and Server Name #142

rconstant opened this issue May 11, 2022 · 2 comments
Labels

Comments

@rconstant
Copy link

Bundle version: 5.13
Symfony version: 5.4.8
PHP version: 7.2

Description

Hi, I setup Google Authenticator and everything is working fine but I have a question about Issuer and Server Name. I would like to define them dynamically per user. I extended \Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleTotpFactory but because it's a final class, we have maybe another to doing this without copy the original GoogleTotpFactory?

Thank you

@scheb
Copy link
Owner

scheb commented May 11, 2022

Easiest solution that comes to my mind would be to set placeholder values for Server Name and Issues, then replace those values in the generated QR code content with the values you want.

# config/packages/scheb_2fa.yaml
scheb_two_factor:
    google:
        server_name: SERVER_NAME
        issuer: ISSUER_NAME
$qrCodeContent = $container->get("scheb_two_factor.security.google_authenticator")->getQRContent($user);
$qrCodeContent = str_replace('SERVER_NAME', urlencode($myCustomServerName), $qrCodeContent);
$qrCodeContent = str_replace('ISSUER_NAME', urlencode($myCustomIssuerName), $qrCodeContent);
// Render QR code

@rconstant
Copy link
Author

Thank you very much for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants