Skip to content

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

Description

@rjsoph

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;

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions