Skip to content

Add JWT authentication support with login and refresh endpoints - #38

Open
rh-gvincent wants to merge 1 commit into
mainfrom
jwt
Open

Add JWT authentication support with login and refresh endpoints#38
rh-gvincent wants to merge 1 commit into
mainfrom
jwt

Conversation

@rh-gvincent

Copy link
Copy Markdown
Contributor

Implements JWT-based authentication using Flask-JWT-Extended with login and token refresh functionality.
Access tokens expire after 1 hour while refresh tokens remain valid for 30 days.

This patch will be the replacement for basic authentication mechanism.

@rh-gvincent
rh-gvincent requested a review from fcharlier April 8, 2026 06:26
Comment thread dci/api/v1/auth.py Outdated
Implements JWT-based authentication using Flask-JWT-Extended with login and token refresh functionality.
Access tokens expire after 1 hour while refresh tokens remain valid for 30 days.

This patch will be the replacement for basic authentication mechanism.

Signed-off-by: Guillaume Vincent <gvincent@redhat.com>
fcharlier
fcharlier previously approved these changes Apr 8, 2026
Comment thread dci/decorators.py
auth_type = headers.get("Authorization").split(" ")[0]
if auth_type == "Bearer":
return am.OpenIDCAuth
elif auth_type == "JWTBearer":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it be possible to keep using Bearer for our own JWT auth and differentiate based on the issuer ?
E.g.:

  elif auth_type == "Bearer":
      # Decode without verification to check issuer                                           
      token = headers.get("Authorization").split(" ")[1]
      unverified = jwt.decode(token, options={"verify_signature": False})                     
      if unverified.get("iss") == "your-dci-server":                                          
          return am.JWTAuth                                                                   
      else:                                                                                   
          return am.OpenIDCAuth

@fcharlier fcharlier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See remark about JWTBearer /vs/ Bearer

@fcharlier
fcharlier dismissed their stale review April 10, 2026 14:30

Added some comments

@fcharlier

Copy link
Copy Markdown
Contributor

@rh-gvincent I continued this work by removing Basic auth and updating tests & scripts to use JWT auth in this branch: https://github.com/distributedci/dci-control-server/tree/jwt_nobasicauth

There's a question leftover about JWT invalidation (or not) on password change. Let's discuss this next week.

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