TheHive-Project / TheHive-Project/Cortex

Feature Request: Add optional PKCE support for OAuth2 / SSO Authentication

Open
#493 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
1.6k
Forks
264
PR merge metrics
No merged PRs in 30d

Description

Description

Currently, the OAuth2 authentication module in Cortex supports the standard Authorization Code flow. However, many modern Identity Providers (IdPs) now strictly require or strongly recommend using PKCE (Proof Key for Code Exchange) for enhanced security.

Without PKCE support, integrating Cortex with these modern SSO environments can be problematic or completely blocked by strict enterprise security policies.

Proposed Solution

I propose adding PKCE support to the existing OAuth2 flow in Cortex, while keeping it 100% backward compatible for existing installations.

The implementation would include:

  1. Adding a new configuration boolean parameter auth.oauth2.pkce (defaulting to false) for Cortex application.conf.
  2. If enabled, dynamically generating a code_verifier and its hashed code_challenge (S256).
  3. Appending the code_challenge to the initial authorization URL.
  4. Retrieving the code_verifier from the session and sending it in the payload during the final token exchange request.
Alternatives Considered

Leaving the implementation as-is forces administrators to lower their IdP security requirements. Forcing PKCE for everyone might break integrations with older IdPs that do not tolerate unknown parameters. Making it configurable solves both issues.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Cortex's OAuth2 authentication module and the application.conf configuration entry point; trace the authorization URL, session handling, and final token exchange. Done means an optional auth.oauth2.pkce setting preserves the existing default flow while adding S256 verifier and challenge handling when enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
authentication, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.