Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Custom OTP name #21

Closed
danieljausovec opened this issue May 9, 2020 · 7 comments
Closed

Custom OTP name #21

danieljausovec opened this issue May 9, 2020 · 7 comments

Comments

@danieljausovec
Copy link

Hi.

Is it possible to set custom dynamic otp label name?

@DarkGhostHunter
Copy link
Owner

Nope. Could had a config for that, though.

@danieljausovec
Copy link
Author

Yeah, that would be nice. Especially if someone want different names on environments.

@DarkGhostHunter
Copy link
Owner

DarkGhostHunter commented May 9, 2020

I figured out initially that the label should be the application name. It's non bc, so I'll add it later this weekend.

@DarkGhostHunter
Copy link
Owner

DarkGhostHunter commented May 9, 2020

Figured out you can override the label yourself by just changing the twoFactorLabel()

@danieljausovec
Copy link
Author

I didn't mean label. I want to change issuer.

This is example what need to be changed.

Add config:
'totp_issuer' => env('OTP_TOTP_ISSUER', '')

Change toUri function in SerializesSharedSecret trait like this:

$query = http_build_query([
    'issuer'    => $issuer = config('laraguard.totp_issuer'),
    'label'     => $this->attributes['label'],
    'secret'    => $this->shared_secret,
    'algorithm' => strtoupper($this->attributes['algorithm']),
    'digits'     => $this->attributes['digits'],
], null, '&', PHP_QUERY_RFC3986);

return "otpauth://totp/".rawurlencode($issuer)."%3A{$this->attributes['label']}?$query";

Can you please implement this? Thanks.

@DarkGhostHunter
Copy link
Owner

No prob, I'll add it.

@DarkGhostHunter
Copy link
Owner

Added in v1.13.0

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

No branches or pull requests

2 participants