Skip to content

feat: added logout url to logout method #102

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

brettchaldecott
Copy link
Contributor

@brettchaldecott brettchaldecott commented Apr 16, 2025

Explain your changes

Added logout url to the log out methods. So it can be overidden at a code level.

Checklist

🛟 If you need help, consider asking for advice over in the Kinde community.

Copy link
Contributor

coderabbitai bot commented Apr 16, 2025

Walkthrough

A new overloaded logout(String logoutRedirectUri) method has been added to the KindeClientSession interface and implemented in KindeClientSessionImpl. The original parameterless logout() method now delegates to this new method using a configured redirect URI. The implementation validates the provided URI and constructs the logout URL accordingly. In the servlet, the logout logic is updated to optionally accept a redirect_uri parameter from the HTTP request, using it if present. Additional import statements were added in one implementation file to support these changes.

Changes

File(s) Change Summary
kinde-core/src/main/java/com/kinde/KindeClientSession.java Added overloaded logout(String logoutRedirectUri) method to the KindeClientSession interface.
kinde-core/src/main/java/com/kinde/session/KindeClientSessionImpl.java Implemented the new logout(String logoutRedirectUri) method; refactored logout() to delegate to the new method.
kinde-core/src/main/java/com/kinde/session/KindeClientKindeTokenSessionImpl.java Added import statements for KindeClientSession and AuthorizationUrl.
kinde-j2ee/src/main/java/com/kinde/servlet/KindeLogoutServlet.java Updated doGet method to accept an optional redirect_uri parameter and use it in logout if provided.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Servlet (KindeLogoutServlet)
    participant Session (KindeClientSession)
    participant Impl (KindeClientSessionImpl)

    User->>Servlet: HTTP GET /logout[?redirect_uri=...]
    Servlet->>Session: logout(redirect_uri) or logout()
    Session->>Impl: logout(redirect_uri) or logout()
    Impl->>Impl: Validate redirect_uri (if provided)
    Impl->>Impl: Build AuthorizationUrl with redirect_uri
    Impl-->>Session: AuthorizationUrl
    Session-->>Servlet: AuthorizationUrl
    Servlet->>User: Redirect to logout URL
Loading

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d3dc189 and 641d9fa.

📒 Files selected for processing (3)
  • kinde-core/src/main/java/com/kinde/KindeClientSession.java (1 hunks)
  • kinde-core/src/main/java/com/kinde/session/KindeClientKindeTokenSessionImpl.java (1 hunks)
  • kinde-core/src/main/java/com/kinde/session/KindeClientSessionImpl.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • kinde-core/src/main/java/com/kinde/session/KindeClientKindeTokenSessionImpl.java
  • kinde-core/src/main/java/com/kinde/KindeClientSession.java
  • kinde-core/src/main/java/com/kinde/session/KindeClientSessionImpl.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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
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

🧹 Nitpick comments (1)
kinde-core/src/main/java/com/kinde/session/KindeClientSessionImpl.java (1)

167-174: Proper implementation with input validation.

The implementation correctly validates that the logoutRedirectUri parameter is neither null nor empty before constructing the logout URL. This prevents potential null pointer exceptions or invalid URLs.

Consider adding JavaDoc documentation to explain the purpose of this method, its parameters, and the exceptions it can throw. This would enhance API usability.

+    /**
+     * Logs out the current user session and redirects to the specified URI.
+     *
+     * @param logoutRedirectUri The URI to redirect to after logout
+     * @return AuthorizationUrl containing the complete logout URL
+     * @throws Exception if logoutRedirectUri is null or empty
+     */
     @Override
     public AuthorizationUrl logout(String logoutRedirectUri) throws Exception {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c3efa12 and d3dc189.

📒 Files selected for processing (4)
  • kinde-core/src/main/java/com/kinde/KindeClientSession.java (1 hunks)
  • kinde-core/src/main/java/com/kinde/session/KindeClientKindeTokenSessionImpl.java (1 hunks)
  • kinde-core/src/main/java/com/kinde/session/KindeClientSessionImpl.java (1 hunks)
  • kinde-j2ee/src/main/java/com/kinde/servlet/KindeLogoutServlet.java (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
kinde-j2ee/src/main/java/com/kinde/servlet/KindeLogoutServlet.java (1)
kinde-j2ee/src/main/java/com/kinde/servlet/KindeSingleton.java (1)
  • KindeSingleton (7-32)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (4)
kinde-core/src/main/java/com/kinde/KindeClientSession.java (1)

27-28: Good addition of the overloaded logout method.

The new method signature allows for programmatically specifying a custom logout redirect URI, which aligns well with the PR objective.

kinde-core/src/main/java/com/kinde/session/KindeClientKindeTokenSessionImpl.java (1)

29-30: Appropriate addition of necessary imports.

These imports prepare the class to work with the enhanced logout mechanism, supporting the interface changes in KindeClientSession.

kinde-j2ee/src/main/java/com/kinde/servlet/KindeLogoutServlet.java (1)

30-43: Well-implemented logic for optional redirect URI parameter.

The implementation correctly:

  1. Extracts the redirect_uri parameter
  2. Checks if it's valid (not null and not empty)
  3. Calls the appropriate logout method based on parameter presence
  4. Maintains the existing session invalidation and redirection logic
kinde-core/src/main/java/com/kinde/session/KindeClientSessionImpl.java (1)

162-165: Good refactoring of the logout method.

The existing method now correctly delegates to the new overloaded method, passing the configured redirect URI from the configuration. This maintains backward compatibility while enabling the new functionality.

Copy link

codecov bot commented Apr 16, 2025

Codecov Report

Attention: Patch coverage is 22.22222% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ain/java/com/kinde/servlet/KindeLogoutServlet.java 0.00% 5 Missing ⚠️
...java/com/kinde/session/KindeClientSessionImpl.java 50.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Copy link

gitguardian bot commented Jun 25, 2025

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
17477796 Triggered JSON Web Token 641d9fa kinde-core/src/test/java/com/kinde/token/JwtValidatorTest.java View secret
17253219 Triggered JSON Web Token 641d9fa kinde-core/src/test/java/com/kinde/token/JwtValidatorTest.java View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

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.

1 participant