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

feat: invite code in guardian auth #431

Merged
merged 4 commits into from
Jul 1, 2024

Conversation

Kodylow
Copy link
Member

@Kodylow Kodylow commented May 31, 2024

Was working on this today and not putting the inviteCode in the auth means you have to separately connect as a client then auth as a guardian.

Summary by CodeRabbit

  • New Features

    • Updated the DangerZone component to accept an inviteCode for improved user authentication and configuration handling.
  • Improvements

    • Enhanced the GuardianAuthenticationCode component to use a more detailed GuardianAuth type, enhancing security and functionality.
  • Refactor

    • Modified internal logic for DangerZone and GuardianAuthenticationCode components to align with new prop and type structures.

@Kodylow Kodylow requested a review from a team as a code owner May 31, 2024 00:59
Copy link
Contributor

coderabbitai bot commented May 31, 2024

Walkthrough

Walkthrough

The recent changes refactor the DangerZone and related components within the guardian-ui application. The primary adjustment is the replacement of the config prop with an inviteCode prop, along with related logic updates. This affects the FederationAdmin, DangerZone, and GuardianAuthenticationCode components, ensuring a more streamlined and coherent way of managing invite-related functionality across the application.

Changes

File Path Summary of Changes
apps/guardian-ui/src/admin/FederationAdmin.tsx Updated DangerZone component call to include an inviteCode prop instead of config.
apps/guardian-ui/src/components/DangerZone.tsx Modified DangerZone to accept inviteCode prop, updating prop types and logic.
apps/guardian-ui/src/components/dashboard/danger/... Updated GuardianAuthenticationCode component to use inviteCode and refactored the authentication code logic.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 482ea3d and 0e38412.

Files ignored due to path filters (2)
  • apps/guardian-ui/src/assets/svgs/chevron-down.svg is excluded by !**/*.svg
  • apps/guardian-ui/src/assets/svgs/chevron-up.svg is excluded by !**/*.svg
Files selected for processing (1)
  • apps/guardian-ui/src/components/dashboard/danger/DangerZone.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/guardian-ui/src/components/dashboard/danger/DangerZone.tsx

Tip

Early access features: disabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are currently opted into early access features by default.
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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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
Contributor

@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: 0

Outside diff range and nitpick comments (1)
apps/guardian-ui/src/admin/FederationAdmin.tsx (1)

Line range hint 31-31: Replace parseInt with Number.parseInt for better clarity and consistency.

- parseInt(id, 10)
+ Number.parseInt(id, 10)

Also applies to: 34-34

Copy link
Contributor

@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: 2


const password = sessionStorage.getItem('guardian-ui-key');
if (password) {
params.append('password', password);
params.password = password;
Copy link
Contributor

@coderabbitai coderabbitai bot Jun 3, 2024

Choose a reason for hiding this comment

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

Consider encrypting the password before storing it in sessionStorage for enhanced security.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah... probably okay, but it's just a lil bit sketchy

Copy link
Contributor

Choose a reason for hiding this comment

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

@alexlwn123, you're right to point out the potential security issues with storing passwords in sessionStorage. While it provides convenience, it's indeed vulnerable to client-side attacks such as cross-site scripting (XSS). A more secure approach would be to avoid storing sensitive information directly in the browser's storage. Instead, consider using server-side sessions or encrypted tokens that can be validated without directly exposing sensitive details. Let me know if you'd like a deeper dive into these alternatives or help with implementing them.

}

return `guardian:authenticate?${params.toString()}`;
console.log(`fedimint:guardian:${JSON.stringify(params)}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove or replace the console log with a proper logging mechanism.

alexlwn123
alexlwn123 previously approved these changes Jun 26, 2024
Copy link
Collaborator

@alexlwn123 alexlwn123 left a comment

Choose a reason for hiding this comment

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

couple non-blocking things, otherwise LGTM. feel free to merge

}

export const DangerZone: React.FC<DangerZoneProps> = ({ config, ourPeer }) => {
export const DangerZone: React.FC<DangerZoneProps> = ({
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Would it make sense to collapse these options by default?
Just thinking the buttons should be hidden from the main dashboard


const password = sessionStorage.getItem('guardian-ui-key');
if (password) {
params.append('password', password);
params.password = password;
Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah... probably okay, but it's just a lil bit sketchy

@alexlwn123 alexlwn123 merged commit 4018d02 into fedimint:master Jul 1, 2024
1 check passed
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.

2 participants