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

Fixed some issue with the QR URL ..... #21

Open
rjsoph opened this issue Oct 12, 2018 · 0 comments
Open

Fixed some issue with the QR URL ..... #21

rjsoph opened this issue Oct 12, 2018 · 0 comments

Comments

@rjsoph
Copy link

rjsoph commented Oct 12, 2018

Issues Addressed:

  1. Added Issuer parameter to match the spec, separate from user
  2. Proper encoding to handle spaces in Issuer name
  3. made width and height optional parameters

Note: this may not be backward compatible given the way $domain was specified, but it does follow the Google spec located here........

https://github.com/google/google-authenticator/wiki/Key-Uri-Format

public function getUrl($issuer, $user, $secret, $width = 200, $height = 200) {
    $url =  sprintf("otpauth://totp/%s:%s?secret=%s&issuer=%s", rawurlencode($issuer), $user, $secret, rawurlencode($issuer));
    $encoder = sprintf("https://www.google.com/chart?chs=%dx%d&chld=M|0&cht=qr&chl=",$width,$height);
    $encoderURL = sprintf( "%s%s",$encoder, rawurlencode($url));

    return $encoderURL;

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

No branches or pull requests

1 participant