Skip to content
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

Improve Boilerplate social sign-in (#9620) #9621

Conversation

ysmoradi
Copy link
Member

@ysmoradi ysmoradi commented Jan 4, 2025

closes #9620

Summary by CodeRabbit

  • New Features

    • Added platform-specific handling for social sign-in local HTTP server functionality
    • Introduced new method to determine local HTTP server usage across different platforms
  • Improvements

    • Enhanced logging capabilities in MAUI application
    • Updated WebView version checking and error handling
  • Configuration Changes

    • Modified social sign-in configuration for Android, iOS, Windows, and macOS
    • Updated asset links for web and Android applications to include login credential permissions

@ysmoradi ysmoradi requested a review from msynk January 4, 2025 19:47
Copy link

coderabbitai bot commented Jan 4, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces modifications to the social sign-in functionality across multiple platforms. The changes primarily focus on enhancing the local HTTP server handling for social authentication, with updates to the ILocalHttpServer interface and its implementations. A new method UseLocalHttpServerForSocialSignIn() has been added to determine platform-specific behavior for social sign-in. The modifications affect sign-in and sign-up pages, local HTTP server implementations for different platforms, and include updates to web application asset links.

Changes

File Change Summary
.../SignInPage.razor.cs Modified SocialSignIn method to conditionally set local HTTP server port
.../SignUpPage.razor.cs Updated SocialSignUp method with conditional local HTTP server port logic
.../ILocalHttpServer.cs Added new UseLocalHttpServerForSocialSignIn() method to interface
.../NoopLocalHttpServer.cs Updated Start method to throw NotImplementedException and added new method
.../App.xaml.cs Added logging capabilities and WebView version check
.../MauiProgram.Services.cs Removed platform-specific ILocalHttpServer registration condition
.../MauiLocalHttpServer.cs Added logging and UseLocalHttpServerForSocialSignIn() method
.../WindowsLocalHttpServer.cs Added UseLocalHttpServerForSocialSignIn() method
.../assetlinks.json Updated login credential permissions for web and Android

Assessment against linked issues

Objective Addressed Explanation
Improve social sign-in functionality
Platform-specific local HTTP server handling

Sequence Diagram

sequenceDiagram
    participant Client
    participant LocalHttpServer
    participant IdentityController
    participant SocialProvider

    Client->>LocalHttpServer: UseLocalHttpServerForSocialSignIn()
    LocalHttpServer-->>Client: Return platform-specific result
    Client->>IdentityController: GetSocialSignInUri
    IdentityController->>SocialProvider: Request Authorization
    SocialProvider-->>Client: Redirect with Authorization Code
    Client->>LocalHttpServer: Start(CancellationToken)
    LocalHttpServer-->>Client: Return Local Port
Loading

Poem

🐰 A rabbit's tale of sign-in delight,
Where ports and servers dance just right,
Platforms unite with clever grace,
Social login finds its perfect space!
Code hops forward, authentication sings! 🔐


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/NoopLocalHttpServer.cs (1)

5-5: Consider preserving no-op behavior or clarifying intent.

Currently, the Start method throws a NotImplementedException. If the intended behavior is to do nothing (as implied by this class’ name), returning a sentinel value (e.g., -1) or logging a warning might be more appropriate. If throwing is intentional, consider clarifying this is a placeholder for future implementation.

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/Services/MauiLocalHttpServer.cs (2)

4-4: Unused import.

System.Net.Sockets might not be considered an unused import if you’re explicitly calling TcpListener. However, confirm whether all references in this scope are necessary. If not, consider removing it for clarity.


91-98: Clarify intent of UseLocalHttpServerForSocialSignIn.

Returning AppPlatform.IsAndroid is false could be confusing. This negative check might reduce readability. Consider renaming or inverting the logic to explicitly communicate your intent, e.g. return !AppPlatform.IsAndroid;.

-    return AppPlatform.IsAndroid is false;
+    return !AppPlatform.IsAndroid;
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/App.xaml.cs (1)

79-81: Keep documentation minimal but helpful.

Including download links for specific Android WebView versions can be useful during development. However, consider referencing official documentation or a more general solution for maintaining compatibility to avoid link rot over time.

Also applies to: 87-89

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 379603e and d8515a8.

📒 Files selected for processing (9)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Identity/SignIn/SignInPage.razor.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Identity/SignUp/SignUpPage.razor.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/Contracts/ILocalHttpServer.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/NoopLocalHttpServer.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/App.xaml.cs (5 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/MauiProgram.Services.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/Services/MauiLocalHttpServer.cs (2 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/wwwroot/.well-known/assetlinks.json (2 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Windows/Services/WindowsLocalHttpServer.cs (1 hunks)
🔇 Additional comments (10)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/NoopLocalHttpServer.cs (1)

7-10: Document potential implications of returning false.

Returning false from UseLocalHttpServerForSocialSignIn() indicates that no local HTTP server is used for social sign-in. Ensure that all calling code handles this scenario (e.g., it sets the port to -1 and handles that gracefully). The logic seems consistent, but confirm there's no accidental requirement for a real server.

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/Contracts/ILocalHttpServer.cs (1)

6-17: Excellent documentation of multi-platform sign-in flow.

The newly added documentation provides a clear breakdown of how different platforms handle local HTTP servers and universal deep links. This helps maintainers and users of this interface understand its usage. Great job!

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Windows/Services/WindowsLocalHttpServer.cs (1)

71-75: Platform alignment confirmed.

Returning true in UseLocalHttpServerForSocialSignIn() aligns with Windows supporting a local HTTP server for social sign-in. This is consistent with the documentation in the interface comments. No concerns here.

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Identity/SignUp/SignUpPage.razor.cs (1)

78-78: Ensure consistent exception handling.

While you handle KnownException inside the try...catch, the Start method in NoopLocalHttpServer throws a NotImplementedException. If the “no-op” server is used unexpectedly here, it might propagate an unhandled exception. Confirm usage is limited to the correct platform or add handling for unexpected exceptions (like a fallback path).

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/MauiProgram.Services.cs (1)

42-42: Ensure platform compatibility for ILocalHttpServer.

Registering MauiLocalHttpServer as a singleton service for all platforms might raise compatibility issues where certain platforms do not support the local server. If this is intentional, confirm that MauiLocalHttpServer includes fallback or no-op behavior for unsupported platforms (e.g., Android).

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/App.xaml.cs (3)

5-5: New logging import is good.

This import is necessary for the newly introduced logging usage. No issues identified.


19-19: Injecting and storing ILogger<App> is correct.

The logger injection is properly implemented. Logging app lifecycle events with a typed logger enriches diagnostic data. Be sure to keep log messages minimal and relevant to avoid log inundation.

Also applies to: 29-29, 34-34


98-98: Good caution about unsupported WebView versions.

The warning log is prudent. Confirm that the overall user flow remains coherent after displaying the alert and redirecting users to update. Use a more specific severity level (e.g., logger.LogError) if outdated WebView versions break major functionality.

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Identity/SignIn/SignInPage.razor.cs (1)

99-99: Validate port usage fallback.

Passing -1 for the port when UseLocalHttpServerForSocialSignIn() is false may require additional handling downstream. Confirm that the route calculation or other sign-in flows gracefully handle a negative port, to avoid confusion or runtime errors.

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/wwwroot/.well-known/assetlinks.json (1)

24-25: Verify the SHA256 fingerprint configuration

Both Android apps (AdminPanel.Template and Todo.Template) are using the same SHA256 fingerprint. Please verify if this is intentional or if each app should have its own unique fingerprint.

Run the following script to check for other occurrences of this fingerprint in the codebase:

Also applies to: 19-21

@msynk msynk merged commit 8f55391 into bitfoundation:develop Jan 5, 2025
3 checks passed
@ysmoradi ysmoradi deleted the 9620-boilerplate-project-template-social-sign-in-needs-improvements branch January 7, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Boilerplate project template social sign-in needs improvements
2 participants