-
-
Notifications
You must be signed in to change notification settings - Fork 363
feat(ITotpService): add ITotpService interface #5900
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
+435
−7
Merged
Changes from 16 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
82aabaa
refactor: 增加 IAuthenticatorService 接口
ArgoZhang 1d825b7
doc: 增加示例
ArgoZhang 2250a78
refactor: 更改为 ITOTPService 服务
ArgoZhang c451e8b
refactor: 增加菜单
ArgoZhang b2c9c03
doc: 增加源码映射
ArgoZhang b92217c
feat: 增加 OtpInput 组件
ArgoZhang 81b679d
doc: 更新示例
ArgoZhang 861592b
refactor: 增加空检查
ArgoZhang 5ef4ef0
chore: 增加工程引用
ArgoZhang efcd3fe
Merge branch 'main' into doc-authenticator
ArgoZhang 908a7e7
refactor: 代码格式化
ArgoZhang c83b2de
refactor: 增加模板
ArgoZhang 5046145
refactor: 更新脚本错误
ArgoZhang c75b2de
doc: 更新样式
ArgoZhang 2994a85
Revert "refactor: 增加模板"
ArgoZhang 94944fb
doc: 更新示例
ArgoZhang 57db277
refactor: 增加样式文件扩展名
ArgoZhang 06c01c0
feat: 增加 OtpInput 组件
ArgoZhang 55fc6e4
refactor: 增加样式文件扩展名
ArgoZhang f618846
refactor: 增加 Readonly 功能
ArgoZhang d6b62af
Merge branch 'refactor-otp' into doc-authenticator
ArgoZhang f7c49ff
feat: 增加禁用只读功能
ArgoZhang 5330d41
doc: 增加示例
ArgoZhang 720d2a4
chore: 更新字典
ArgoZhang 66c5176
feat: 增加 MaxLength 属性
ArgoZhang 0cf0cd3
refactor: 增加脚本
ArgoZhang 669ac78
doc: 增加示例
ArgoZhang ab8c23b
refactor: 更新示例
ArgoZhang d34bbd1
Merge branch 'main' into doc-authenticator
ArgoZhang 9f027cb
refactor: 增加默认实现
ArgoZhang 5e1cac0
refactor: 增加默认服务逻辑
ArgoZhang 403ff5d
chore: 更新字典
ArgoZhang f796495
test: 增加单元测试
ArgoZhang 53ba55f
test: 增加单元测试
ArgoZhang a130a33
chore: 更新字典
ArgoZhang e7db3cd
refactor: 更新接口
ArgoZhang ce27f07
chore: bump version 9.5.11-beta04
ArgoZhang 9ce3f35
chore: bump version 9.5.11-beta02
ArgoZhang 6c9fc9f
Merge branch 'chore-bump' into doc-authenticator
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
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
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
39 changes: 39 additions & 0 deletions
39
src/BootstrapBlazor.Server/Components/Samples/Authenticators.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,39 @@ | ||
| @page "/authenticator" | ||
|
|
||
| <HeadContent> | ||
| <style> | ||
| .qrcode { | ||
| display: flex; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| .progress { | ||
| max-width: 500px; | ||
| margin: 0 auto; | ||
| } | ||
|
|
||
| .opt-progress-label { | ||
| position: absolute; | ||
| top: 50%; | ||
| left: 50%; | ||
| transform: translate(-50%, -50%); | ||
| font-size: 0.75rem; | ||
| color: var(--bs-body-color); | ||
| } | ||
| </style> | ||
| </HeadContent> | ||
|
|
||
| <h3>@Localizer["Title"]</h3> | ||
|
|
||
| <h4>@Localizer["SubTitle"]</h4> | ||
|
|
||
| <PackageTips Name="BootstrapBlazor.Authenticator"></PackageTips> | ||
|
|
||
| <DemoBlock Title="@Localizer["BaseUsageText"]" Introduction="@Localizer["IntroText1"]" Name="Normal"> | ||
| <QRCode Content="@_content" Width="190" class="mb-3"></QRCode> | ||
| <OtpInput Value="@_code" class="text-center mb-3"></OtpInput> | ||
| <div class="position-relative"> | ||
| <BootstrapBlazor.Components.Progress Value="@_progress" IsShowValue="false"></BootstrapBlazor.Components.Progress> | ||
| <span class="opt-progress-label">@_remain</span> | ||
| </div> | ||
| </DemoBlock> |
56 changes: 56 additions & 0 deletions
56
src/BootstrapBlazor.Server/Components/Samples/Authenticators.razor.cs
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,56 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the Apache 2.0 License | ||
| // See the LICENSE file in the project root for more information. | ||
| // Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone | ||
|
|
||
|
|
||
| namespace BootstrapBlazor.Server.Components.Samples; | ||
|
|
||
| /// <summary> | ||
| /// Authenticators sample | ||
| /// </summary> | ||
| public partial class Authenticators | ||
| { | ||
| [Inject] | ||
| [NotNull] | ||
| private IStringLocalizer<Anchors>? Localizer { get; set; } | ||
|
|
||
| [Inject] | ||
| [NotNull] | ||
| private ITotpService? TotpService { get; set; } | ||
|
|
||
| private string _content = ""; | ||
|
|
||
| private string? _code; | ||
|
|
||
| private double _progress = 0; | ||
|
|
||
| private int _remain = 0; | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc/> | ||
| /// </summary> | ||
| protected override void OnInitialized() | ||
| { | ||
| base.OnInitialized(); | ||
|
|
||
| _content = TotpService.GenerateOtpUri(); | ||
| _code = TotpService.Compute("OMM2LVLFX6QJHMYI"); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc/> | ||
| /// </summary> | ||
| /// <param name="firstRender"></param> | ||
| /// <returns></returns> | ||
| protected override async Task OnAfterRenderAsync(bool firstRender) | ||
| { | ||
| await base.OnAfterRenderAsync(firstRender); | ||
|
|
||
| await Task.Delay(1000); | ||
| _code = TotpService.Compute("OMM2LVLFX6QJHMYI"); | ||
| _remain = TotpService.Instance.GetRemainingSeconds(); | ||
| _progress = (30d - _remain) * 100 / 30d; | ||
| StateHasChanged(); | ||
| } | ||
| } |
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
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
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
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
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,12 @@ | ||
| @namespace BootstrapBlazor.Components | ||
| @inherits ValidateBase<string> | ||
|
|
||
| <div @attributes="AdditionalAttributes" id="@Id" class="@ClassString"> | ||
| @for (var index = 0; index < Digits; index++) | ||
| { | ||
| if (index < _values.Length) | ||
| { | ||
| <span class="@SpanClassString">@_values[index]</span> | ||
| } | ||
| } | ||
| </div> | ||
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,44 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the Apache 2.0 License | ||
| // See the LICENSE file in the project root for more information. | ||
| // Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone | ||
|
|
||
| namespace BootstrapBlazor.Components; | ||
|
|
||
| /// <summary> | ||
| /// OTP input component | ||
| /// </summary> | ||
| public partial class OtpInput | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the length of the OTP input. Default is 6. | ||
| /// </summary> | ||
| [Parameter] | ||
| public int Digits { get; set; } = 6; | ||
|
|
||
| /// <summary> | ||
| /// | ||
| /// </summary> | ||
| [Parameter] | ||
| public OtpInputType Type { get; set; } | ||
|
|
||
| private string? ClassString => CssBuilder.Default("bb-opt-input") | ||
| .AddClassFromAttributes(AdditionalAttributes) | ||
| .Build(); | ||
|
|
||
| private string? SpanClassString => CssBuilder.Default("bb-opt-span") | ||
| .AddClass(ValidCss) | ||
| .Build(); | ||
|
|
||
| private char[] _values = []; | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc/> | ||
| /// </summary> | ||
| protected override void OnParametersSet() | ||
| { | ||
| base.OnParametersSet(); | ||
|
|
||
| _values = Value?.ToCharArray() ?? []; | ||
| } | ||
| } |
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,11 @@ | ||
| .bb-opt-span { | ||
| display: inline-block; | ||
| border: 1px solid var(--bs-border-color); | ||
| font-size: 3em; | ||
| padding: 0 .5em; | ||
| border-radius: var(--bs-border-radius); | ||
|
|
||
| &:not(:last-child) { | ||
| margin-right: .5rem; | ||
| } | ||
| } |
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,27 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the Apache 2.0 License | ||
| // See the LICENSE file in the project root for more information. | ||
| // Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone | ||
|
|
||
| namespace BootstrapBlazor.Components; | ||
|
|
||
| /// <summary> | ||
| /// OTP input type | ||
| /// </summary> | ||
| public enum OtpInputType | ||
| { | ||
| /// <summary> | ||
| /// Number OTP Input | ||
| /// </summary> | ||
| Number, | ||
|
|
||
| /// <summary> | ||
| /// Text OTP Input | ||
| /// </summary> | ||
| Text, | ||
|
|
||
| /// <summary> | ||
| /// Password OTP Input | ||
| /// </summary> | ||
| Password | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.