[−][src]Struct libreauth::oath::KeyUriBuilder
Creates the Key Uri Format according to the Google authenticator
specification by calling
key_uri_format()
on [HOTP
] or [TOTP
]. This value can be used to generete QR
codes which allow easy scanning by the end user.
WARNING: The finalized value contains the secret key of the authentication process and should only be displayed to the corresponding user!
Example
let key_ascii = "12345678901234567890".to_owned(); let mut totp = libreauth::oath::TOTPBuilder::new() .ascii_key(&key_ascii) .finalize() .unwrap(); let uri = totp .key_uri_format("Provider1", "alice@example.com") .finalize(); assert_eq!( uri, "otpauth://totp/Provider1:alice@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider1" );
Methods
impl<'a> KeyUriBuilder<'a>
[src]
pub fn parameters_visibility_policy(self, policy: ParametersVisibility) -> Self
[src]
Set the visibility policy for parameters.
Example
use libreauth::oath::{ParametersVisibility, TOTPBuilder }; let key_ascii = "12345678901234567890".to_owned(); let mut totp = TOTPBuilder::new() .ascii_key(&key_ascii) .finalize() .unwrap(); let uri = totp .key_uri_format("Provider1", "alice@example.com") .parameters_visibility_policy(ParametersVisibility::HideAll) .finalize(); assert_eq!( uri, "otpauth://totp/Provider1:alice@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" );
pub fn overwrite_label(self, label: &'a str) -> Self
[src]
Completely overwrite the default {issuer}:{account_name}
label with a custom one.
Example
let key_ascii = "12345678901234567890".to_owned(); let mut totp = libreauth::oath::TOTPBuilder::new() .ascii_key(&key_ascii) .finalize() .unwrap(); let uri = totp .key_uri_format("Provider1", "alice@example.com") .overwrite_label("Provider1Label") .finalize(); assert_eq!( uri, "otpauth://totp/Provider1Label?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider1" );
pub fn add_parameter(self, key: &'a str, value: &'a str) -> Self
[src]
Add a custom key/value parameter.
Example
let key_ascii = "12345678901234567890".to_owned(); let mut totp = libreauth::oath::TOTPBuilder::new() .ascii_key(&key_ascii) .finalize() .unwrap(); let uri = totp .key_uri_format("Provider1", "alice@example.com") .add_parameter("foo", "bar") .finalize(); assert_eq!( uri, "otpauth://totp/Provider1:alice@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider1&foo=bar" );
pub fn finalize(&self) -> String
[src]
Generate the final format.
Auto Trait Implementations
impl<'a> Unpin for KeyUriBuilder<'a>
impl<'a> Sync for KeyUriBuilder<'a>
impl<'a> Send for KeyUriBuilder<'a>
impl<'a> UnwindSafe for KeyUriBuilder<'a>
impl<'a> RefUnwindSafe for KeyUriBuilder<'a>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<T> Same<T> for T
type Output = T
Should always be Self