Documentation
¶
Overview ¶
Package otpauth handles the URL format used to specify OTP parameters.
This package conforms to the specification at: https://github.com/google/google-authenticator/wiki/Key-Uri-Format
The general form of an OTP URL is:
otpauth://TYPE/LABEL?PARAMETERS
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type URL ¶
type URL struct { Type string // normalized to lowercase, e.g., "totp" Issuer string // also called "provider" in some docs Account string // without provider prefix RawSecret string // base32-encoded, no padding Algorithm string // normalized to uppercase; default is "SHA1" Digits int // default is 6 Period int // in seconds; default is 30 Counter uint64 }
A URL contains the parsed representation of an otpauth URL.
func ParseMigrationURL ¶ added in v0.5.0
ParseMigrationURL parses an otpauth-migration URL in the format generated by the Google Authenticator for "exported" configurations. Typically these URLs are embedded as QR codes, encoding a proprietary URL in this format:
otpauth-migration://offline?data=<content>
The content is a protocol buffer message encoded as base64 in standard encoding. Note that a single migration URL may encode multiple OTP settings; on success this function returns all the otpauth URLs encoded by the content. It will always return at least one URL, or report an error.
func ParseURL ¶
ParseURL parses s as a URL in the otpauth scheme.
The input may omit a scheme, but if present the scheme must be otpauth://. The parser will report an error for invalid syntax, including unknown URL parameters, but does not otherwise validate the results. In particular, the values of the Type and Algorithm fields are not checked.
Fields of the URL corresponding to unset parameters are populated with default values as described on the URL struct. If a different issuer is set on the label and in the parameters, the parameter takes priority.
func (*URL) MarshalText ¶ added in v0.3.2
MarshalText implemens the encoding.TextMarshaler interface. It emits the same URL string produced by the String method.
func (*URL) UnmarshalText ¶ added in v0.3.2
UnmarshalText implements the encoding.TextUnmarshaler interface. It expects its input to be a URL in the standard encoding.