-
-
Notifications
You must be signed in to change notification settings - Fork 363
doc(MFA): add enable 2FA sample code #5994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
070277f
chore: bump version 9.6.1-beta04
ArgoZhang 5b10f8e
test: bump version 9.6.1-beta05
ArgoZhang 9637d2f
chore: test push auto
ArgoZhang 3f7aa6c
style: 更新样式
ArgoZhang 06ed32f
doc: 更新 MFA 示例
ArgoZhang eee6b1e
chore: bump version 9.6.1-beta04
ArgoZhang 8e30f12
Merge branch 'fix-otp' into doc-mfa
ArgoZhang c3a0c0c
Merge remote-tracking branch 'gitee.com/test-js' into doc-mfa
ArgoZhang 4c403f5
chore: bump version 9.6.1-beta03
ArgoZhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
| <div class="bb-sign-body"> | ||
| <div class="mb-2">Username or email address</div> | ||
| <input type="text" class="form-control mb-3" value="[email protected]" /> | ||
| <div class="d-flex mb-2"> | ||
| <div class="d-flex justify-content-between mb-2"> | ||
| <div>Password</div> | ||
| <div>Forgot password?</div> | ||
| </div> | ||
|
|
||
58 changes: 58 additions & 0 deletions
58
src/BootstrapBlazor.Server/Components/Samples/Tutorials/MFA/Register.razor
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| @page "/tutorials/mfa/two-factor/register" | ||
| @inject IOptionsMonitor<WebsiteOptions> WebsiteOption | ||
| @inject ITotpService TotpService | ||
|
|
||
| <div class="bb-sign"> | ||
| <div class="text-center"> | ||
| <img src="@WebsiteOption.CurrentValue.GetAssetUrl("images/logo.png")" /> | ||
| <h3>Two-factor methods</h3> | ||
| </div> | ||
| <div class="bb-sign-body"> | ||
| <div class="mb-2"><b>Authenticator app</b></div> | ||
| <div class="mb-3"> | ||
| Authenticator apps and browser extensions like <code>1Password</code>, <code>Authy</code>, <code>Microsoft Authenticator</code>, <code>Google Authenticator</code>, etc. generate one-time passwords that are used as a second factor to verify your identity when prompted during sign-in. | ||
| </div> | ||
| <div class="mb-2"><b>Scan the QR code</b></div> | ||
| <div class="mb-3"> | ||
| Use an authenticator app or browser extension to scan. Learn more about enabling 2FA. | ||
| </div> | ||
| <div class="bb-sign-qr"> | ||
| <QRCode Content="@_content" Width="190"></QRCode> | ||
| </div> | ||
| <div class="mb-3"><b>Verify the code from the app</b></div> | ||
| <input type="password" class="form-control" @bind="@_code" /> | ||
| <button type="button" class="form-control bg-success text-white mt-3" @onclick="OnRegister">Save</button> | ||
| </div> | ||
| </div> | ||
|
|
||
| @code { | ||
| [Inject, NotNull] | ||
| private NavigationManager? NavigationManager { get; set; } | ||
|
|
||
| private string? _content; | ||
|
|
||
| private string? _code; | ||
|
|
||
| protected override void OnInitialized() | ||
| { | ||
| base.OnInitialized(); | ||
|
|
||
| _content = TotpService.GenerateOtpUri(new OtpOptions() | ||
| { | ||
| AccountName = "BootstrapBlazor", | ||
| IssuerName = "BootstrapBlazor", | ||
| UserName = "Simulator", | ||
| SecretKey = "OMM2LVLFX6QJHMYI", | ||
| Algorithm = OtpHashMode.Sha1, | ||
| Type = OtpType.Totp | ||
| }); | ||
| } | ||
|
|
||
| private void OnRegister() | ||
| { | ||
| if (_code == TotpService.Compute("OMM2LVLFX6QJHMYI")) | ||
| { | ||
| NavigationManager.NavigateTo("/tutorials/mfa/two-factor/app"); | ||
| } | ||
| } | ||
| } | ||
51 changes: 51 additions & 0 deletions
51
src/BootstrapBlazor.Server/Components/Samples/Tutorials/MFA/Register.razor.css
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| .bb-sign { | ||
| margin: 0 auto; | ||
| width: 640px; | ||
| padding: 0 1rem; | ||
| } | ||
|
|
||
| .bb-sign img { | ||
| background-color: var(--bb-primary-color); | ||
| border-radius: 50%; | ||
| margin-block: 2rem; | ||
| } | ||
|
|
||
| .bb-sign h1 { | ||
| font-size: 24px; | ||
| font-weight: 300; | ||
| letter-spacing: -0.5px; | ||
| margin-block-end: 1rem; | ||
| } | ||
|
|
||
| .bb-sign-body { | ||
| background-color: #f6f8fa; | ||
| border: 1px solid var(--bs-border-color); | ||
| border-radius: var(--bs-border-radius); | ||
| padding: 1rem; | ||
| } | ||
|
|
||
| .bb-sign-body img { | ||
| width: 32px; | ||
| height: auto; | ||
| margin: 0; | ||
| margin-block-end: 1rem; | ||
| } | ||
|
|
||
| .bb-sign-body h3 { | ||
| font-size: 20px; | ||
| font-weight: 400; | ||
| } | ||
|
|
||
| .bb-sign-qr { | ||
| margin-top: 1rem; | ||
| margin-bottom: 1rem; | ||
| } | ||
|
|
||
| ::deep .qrcode { | ||
| padding: .5rem; | ||
| border: 1px solid var(--bs-border-color); | ||
| border-radius: var(--bs-border-radius); | ||
| display: inline-flex; | ||
| align-items: center; | ||
| justify-items: center; | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.