-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix/yesdk 1071 oath credential (#556)
* Reorganized tests, and added tests to cover bugs related to the handling of optional credential properties. * Issuer property uses null when there is no issuer. * Issuer handles white space. * Constructors accept null issuer, and parser returns a nullable string. * Strings are trimmed, null used only as a default value on optional properties, updated property validation checks, updated name builder and length calculation. * Cleaned up formatting. * Fixed asserts on non-nullable property. * Converted GetName() into expression-bodied member, Name, to preserve existing API. * Rolled back changes not directly related to the optional Issuer property and Name construction. Updated URI parsing to pass existing unit test and added test to check correct handling of URI without Issuer. * Small cosmetic changes. * Updated documentation. * Removed white space trimming of issuer and account properties.
- Loading branch information
Showing
12 changed files
with
671 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,34 +26,34 @@ The credential has a set of parameters. | |
|
||
| Name | Description | | ||
| :--- | :--- | | ||
| Issuer | The issuer parameter is a string value indicating the provider or service this account is associated with. | | ||
| Issuer | The issuer parameter is an optional string value indicating the provider or service this account is associated with. | | ||
| Account Name | The account name is a string that usually is the user's email address. | | ||
| Type | Indicates the type of the credential as either HOTP or TOTP. | | ||
| Algorithm | The hash algorithm used by the credential. | | ||
| Secret | The secret parameter is an arbitrary key value encoded in Base32 according to RFC 3548. | | ||
| Digits | The number of digits in a one-time password (OTP). | | ||
| Requires Touch | The credential requires the user to touch the key to generate a one-time password (OTP). | | ||
| Name | Only get property witch serves as the unique identifier for the credential.| | ||
| Name | Only get property which serves as the unique identifier for the credential. | | ||
|
||
The Name is created from Period, Issue and Account Name with the following format: | ||
|
||
``` | ||
"period/issuer:account" | ||
``` | ||
|
||
If period is a default value - 30 seconds, or the credential's type is HOTP, then the format will be: | ||
If the credential is TOTP with the default period (30 seconds) or the credential's type is HOTP, then the format will be: | ||
|
||
``` | ||
"issuer:account" | ||
``` | ||
|
||
Also, if Issuer is not specified, the format will be: | ||
If Issuer is not specified, the format will be: | ||
|
||
``` | ||
"period/account" | ||
``` | ||
|
||
Or just an Account Name for TOTP with default period or HOTP credentials: | ||
Or just an Account Name for TOTP with default period (30 seconds) or HOTP credentials: | ||
|
||
``` | ||
"account" | ||
|
@@ -121,12 +121,12 @@ The URI specification [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). | |
|
||
2. Specifying each parameter | ||
|
||
If you are unable to capture the QR code and use a URI string, you can manually create the credential by adding the account information, the provider (Amazon, Google, Microsoft, etc.) and the shared secret. | ||
If you are unable to capture the QR code and use a URI string, you can manually create the credential by adding the account information. The Issuer is recommended, but not required. | ||
|
||
``` | ||
// create TOTP credential | ||
var credential = new Credential { | ||
Issuer = Yubico, | ||
Issuer = "Yubico", | ||
AccountName = "[email protected]", | ||
Type = Totp, | ||
Period = 30, | ||
|
@@ -137,12 +137,11 @@ var credential = new Credential { | |
// create HOTP credential | ||
var credential = new Credential { | ||
Issuer = Yubico, | ||
Issuer = "Yubico", | ||
AccountName = "[email protected]", | ||
Type = Hotp, | ||
Period = 0, | ||
Digits = 6, | ||
Counter = | ||
Counter = 0, | ||
Secret = "HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ", | ||
RequireTouch = false | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,6 @@ var credentialHotp = new Credential | |
Issuer = "Yubico", | ||
AccountName = "[email protected]", | ||
Type = Hotp, | ||
Period = 0, | ||
Algorithm = Sha256, | ||
Digits = 8, | ||
Counter = 10, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,9 +55,11 @@ The label is created from: | |
|
||
| Name | Description | | ||
| :--- | :--- | | ||
| Issuer | A string value indicating the provider or service this account is associated with. It can be absent. | | ||
| Issuer | An optional string value indicating the provider or service this account is associated with. | | ||
| Account Name | A URI-encoded string that usually is the user's email address. | | ||
|
||
It is formatted as "Issuer:Account" when both parameters are present. It is formatted as "Account" when there is no Issuer. | ||
|
||
The label prevents collisions between different accounts with different providers that might be identified using the same account name, e.g. the user's email address. | ||
|
||
The issuer and account name should be separated by a literal or url-encoded colon, and optional spaces may precede the account name. Neither issuer nor account name may themselves contain a colon. According to [RFC 5234](https://www.rfc-editor.org/rfc/rfc5234.txt) a valid label might look like: | ||
|
@@ -67,6 +69,7 @@ Example:[email protected] | |
ACME%20Co:[email protected] | ||
``` | ||
|
||
## Parameters | ||
|
||
### Secret | ||
|
@@ -81,7 +84,7 @@ There is Base32 helper class in the Yubico.Core library. | |
|
||
### Issuer | ||
|
||
The issuer parameter is a string value indicating the provider or service the credential is associated with. It is URL-encoded according to [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). | ||
The issuer parameter is an optional string value indicating the provider or service the credential is associated with. It is URL-encoded according to [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). | ||
|
||
Valid values corresponding to the label examples above would be: | ||
|
||
|
13 changes: 11 additions & 2 deletions
13
Yubico.YubiKey/src/Resources/ExceptionMessages.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.