Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Apr 27, 2025

Link issues

fixes #5911

Summary By Copilot

This pull request introduces significant changes to the BootstrapBlazor project, focusing on replacing the BootstrapBlazor.Authenticator component with a new ITotpService implementation. The changes include updates to project references, renaming files and classes, modifying localization files, and improving the TOTP service's API. Below is a summary of the most important changes grouped by theme.

Removal of BootstrapBlazor.Authenticator and Introduction of ITotpService:

  • Removed the BootstrapBlazor.Authenticator project reference from BootstrapBlazor.sln and replaced it with ITotpService functionality in the BootstrapBlazor.Server project. ([[1]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-870ac4a4b1c5ee4def744573119c9717970bba3b8d2a460723e46a16e6f94d39L81-L82), [[2]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-acda8ffd7b0362074afe236cb631a348f2c8a44568a1f235743982c2a0ad6416R24), [[3]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-acda8ffd7b0362074afe236cb631a348f2c8a44568a1f235743982c2a0ad6416L72-L81), [[4]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-8ec92a1c789bcd9f30e2bf5f32650e11512a8d9818d4bb826d144b69f96a5181L33-R34))
  • Replaced the Authenticator sample with a new OtpServices sample, including renaming the Razor and code-behind files, updating the implementation to use the new ITotpService, and adding a new demo page. ([[1]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-1870f0684661390279b8dabb1fc420f521ff8d2e98a9d30dbf973af1dbfa597cL1-L39), [[2]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-436a2abad2c2c0fe81cb6a4a49310b861d8a3656cda22a6e43016827dbb3bf92R1-R56), [[3]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-61a86a9cf933da975b47868eba7ec96cbb748ed2583f4c75789390c9a7f0da07L10-R16), [[4]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-61a86a9cf933da975b47868eba7ec96cbb748ed2583f4c75789390c9a7f0da07L37-R45), [[5]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-0da175523aa74d67c07cc125ac55664960a8e14e9b980fc8394ee1b9fff866f7R1541-R1546))

API Enhancements for TOTP Service:

  • Updated the ITotpService interface and its implementation to use more descriptive parameter names (stepperiod, totpSizedigits) and aligned the API with standard TOTP terminology. ([[1]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-ccc7650d5da806a4fcb0148dc7fde082c94c49c7492f681c1ae7b96a26e1a427L12-R12), [[2]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-bb486b36d893ea93119d3c1e13e85f33e2ba5c15ce6f093b18e51cd7ad8b110cL24-R29))

Localization Updates:

  • Updated the localization files (en-US.json and zh-CN.json) to reflect the changes from Authenticator to ITotpService, including new keys for the OtpServices demo. ([[1]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-790d42ebea731775f0fee88a92b20fadb044e53706fd6d3025dfa095df9b1b41L4923-R4923), [[2]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-790d42ebea731775f0fee88a92b20fadb044e53706fd6d3025dfa095df9b1b41L7106-R7110), [[3]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-746b8cc3c80dd10d0a1bf77b8d6571652e15bcc7c33dcac0954d93b1a728cc7fL4923-R4923), [[4]](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-746b8cc3c80dd10d0a1bf77b8d6571652e15bcc7c33dcac0954d93b1a728cc7fL7106-R7110))

Documentation and Versioning:

  • Updated the docs.json file to replace references to authenticator with otp-service. ([src/BootstrapBlazor.Server/docs.jsonL233-R233](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-7f22699a321cdff3a7bd4a3f85ae66d0fbe78560628329c39cca784d9d64dfb7L233-R233))
  • Incremented the version of BootstrapBlazor from 9.5.11-beta04 to 9.5.12. ([src/BootstrapBlazor/BootstrapBlazor.csprojL4-R4](https://github.com/dotnetcore/BootstrapBlazor/pull/5912/files#diff-07918ce1b66955e76da5cd0ffa38512cce984fa2a09735a60e0db37b45235527L4-R4))

These changes streamline the implementation of TOTP functionality, improve code clarity, and enhance the user experience with updated samples and documentation.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Introduce ITotpService and a corresponding sample page, replacing the previous Authenticator component and sample. Rename service API parameters for clarity.

Enhancements:

  • Rename ITotpService.Compute parameters (step to period, totpSize to digits) to align with standard TOTP terminology.
  • Replace the Authenticator sample page with a new OtpServices page demonstrating ITotpService usage.
  • Update service registration to use AddBootstrapBlazorTotpService instead of the previous AddBootstrapBlazorAuthenticator method.
  • Increment the package version in the project file.
  • Update documentation metadata and localization files to reflect the new OtpServices sample.

@bb-auto bb-auto bot added the documentation Improvements or additions to documentation label Apr 27, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Apr 27, 2025

Reviewer's Guide by Sourcery

This pull request replaces the existing BootstrapBlazor.Authenticator component/service with a new ITotpService implementation. The changes involve removing the old component, introducing the new service interface and default implementation, updating sample code, renaming files, modifying localization strings, updating documentation and project references, and refining the API parameter names.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Replaced the BootstrapBlazor.Authenticator component/service with a new ITotpService implementation.
  • Removed reference to old Authenticator project.
  • Added registration for the new ITotpService.
  • Defined the ITotpService interface.
  • Provided a default implementation for ITotpService.
BootstrapBlazor.sln
src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj
src/BootstrapBlazor.Server/Extensions/ServiceCollectionSharedExtensions.cs
src/BootstrapBlazor/Services/ITotpService.cs
src/BootstrapBlazor/Services/DefaultTotpService.cs
Replaced the existing Authenticator sample page with a new OtpServices sample page.
  • Renamed sample code-behind file.
  • Renamed sample Razor file.
  • Implemented the sample using the new ITotpService.
  • Added new sample page to the menu.
src/BootstrapBlazor.Server/Components/Samples/Authenticators.razor.cs
src/BootstrapBlazor.Server/Components/Samples/OtpServices.razor.cs
src/BootstrapBlazor.Server/Components/Samples/Authenticators.razor
src/BootstrapBlazor.Server/Components/Samples/OtpServices.razor
src/BootstrapBlazor.Server/Extensions/MenusLocalizerExtensions.cs
Refined the ITotpService API parameter names for clarity.
  • Renamed 'step' parameter to 'period'.
  • Renamed 'totpSize' parameter to 'digits'.
src/BootstrapBlazor/Services/ITotpService.cs
src/BootstrapBlazor/Services/DefaultTotpService.cs
Updated localization files and documentation to reflect the changes.
  • Added new localization keys for the OtpServices sample.
  • Updated existing localization strings.
  • Updated documentation references.
src/BootstrapBlazor.Server/Locales/en-US.json
src/BootstrapBlazor.Server/Locales/zh-CN.json
src/BootstrapBlazor.Server/docs.json
Incremented the project version.
  • Updated the version number in the project file.
src/BootstrapBlazor/BootstrapBlazor.csproj

Assessment against linked issues

Issue Objective Addressed Explanation
#5911 Add sample code for the ITotpService component.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto bot added this to the v9.5.0 milestone Apr 27, 2025
@ArgoZhang ArgoZhang requested a review from Copilot April 27, 2025 08:17
@ArgoZhang ArgoZhang enabled auto-merge (squash) April 27, 2025 08:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the BootstrapBlazor.Authenticator component with a new ITotpService implementation and updates the related samples, localization, and documentation accordingly.

  • Renamed and updated parameters in the ITotpService API (step → period, totpSize → digits).
  • Introduced an OtpServices sample and removed the old Authenticators sample.
  • Updated service registration, localization files, and docs to reflect the changes.

Reviewed Changes

Copilot reviewed 7 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/BootstrapBlazor/Services/ITotpService.cs Updated parameter names and documentation in the TOTP service interface
src/BootstrapBlazor/Services/DefaultTotpService.cs Updated parameter names and defaults in the TOTP service implementation
src/BootstrapBlazor.Server/Extensions/ServiceCollectionSharedExtensions.cs Updated service registration for the new ITotpService
src/BootstrapBlazor.Server/Extensions/MenusLocalizerExtensions.cs Added a new menu entry for TotpService
src/BootstrapBlazor.Server/Components/Samples/OtpServices.razor.cs Renamed sample class and updated service usage with new OtpOptions
src/BootstrapBlazor.Server/Components/Samples/OtpServices.razor Created a new sample page for ITotpService
src/BootstrapBlazor.Server/Components/Samples/Authenticators.razor Removed the old Authenticator sample
Files not reviewed (6)
  • BootstrapBlazor.sln: Language not supported
  • src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj: Language not supported
  • src/BootstrapBlazor.Server/Locales/en-US.json: Language not supported
  • src/BootstrapBlazor.Server/Locales/zh-CN.json: Language not supported
  • src/BootstrapBlazor.Server/docs.json: Language not supported
  • src/BootstrapBlazor/BootstrapBlazor.csproj: Language not supported
Comments suppressed due to low confidence (2)

src/BootstrapBlazor/Services/ITotpService.cs:29

  • The default value for 'period' is set to 6, which is non-standard given that TOTP periods are typically 30 seconds. Please verify and update the default if needed.
string Compute(string secretKey, int period = 6, OtpHashMode mode = OtpHashMode.Sha1, int digits = 6, DateTime? timestamp = null);

src/BootstrapBlazor.Server/Components/Samples/OtpServices.razor:30

  • The PackageTips component still references 'BootstrapBlazor.Authenticator'; update it to reference 'BootstrapBlazor.TotpService' to maintain consistency with the new implementation.
<PackageTips Name="BootstrapBlazor.Authenticator"></PackageTips>

sourcery-ai[bot]
sourcery-ai bot previously approved these changes Apr 27, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ArgoZhang - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider updating the PR title and description to better reflect the full scope, which includes replacing the Authenticator service with ITotpService rather than just adding sample code.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented Apr 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (a5803ed) to head (d44453f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #5912   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          665       665           
  Lines        30485     30485           
  Branches      4345      4345           
=========================================
  Hits         30485     30485           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ArgoZhang ArgoZhang disabled auto-merge April 27, 2025 08:21
@ArgoZhang ArgoZhang merged commit 20da007 into main Apr 27, 2025
4 checks passed
@ArgoZhang ArgoZhang deleted the doc-authenticator branch April 27, 2025 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc(ITotpService): add sample code

2 participants