Skip to content
Snippets Groups Projects

Implementing Gitlab OAuth

All threads resolved!

Issue: #57 Implement Gitlab login with OAuth

Approach:

As per the use case of this project, I implemented Gitlab OAuth with PKCE. For this, we are not required to pass the Secret to the server and it will work with just the ClientID.

Note: The backend can also be deployed using a Socket, I am unable to configure OAuth with that. I did some research and it seems that OAuth can only work over HTTP/HTTPS. I have added a check that if Sockets are being used for deployment, I am skipping the OAuth Flow.

Note 2: I have added the OAuth support with unix socket as well, but it does require the proxy_port of the NGINX conf for building the callback url

I have added the OAuth check as a middleware in routing so it is being checked over all the routes. I am open to any changes to this approach.

Flow:

The general flow of the program is as per this

image.png

Edited by Achintya Singh

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Marvin Scholz
  • Marvin Scholz
  • Hi, thanks a lot for the contribution.

    I did a brief review of some things, not very in-depth but these are some things that need to be addressed, I think.

  • Achintya Singh added 1 commit

    added 1 commit

    • f1ac4fd1 - [feat] added token authentication via gitlab

    Compare with previous version

  • Achintya Singh resolved all threads

    resolved all threads

  • Achintya Singh added 1 commit

    added 1 commit

    • 5366b95f - [fix] added feature to generate the redirect url from config

    Compare with previous version

  • Achintya Singh added 1 commit

    added 1 commit

    • c1b278ce - [fix] Modified redirect url for server when deployed via socket

    Compare with previous version

  • Author Contributor

    Sorry for being a bit late, but I have tested the Gitlab OAuth as for both Unix Socket and Http Port and am adding a screen recording for better context.

    Screencast_from_2024-03-16_00-31-53

    The screen recording is for server being hosted on a unix socket. I am also Marking it as ready and removing from Draft.

    Edited by Achintya Singh
  • Achintya Singh marked this merge request as ready

    marked this merge request as ready

  • Achintya Singh changed the description

    changed the description

  • Marvin Scholz
  • Marvin Scholz
  • Marvin Scholz
  • Marvin Scholz
  • Achintya Singh resolved all threads

    resolved all threads

  • Achintya Singh added 1 commit

    added 1 commit

    • 79dbc416 - chore: implemented redirect url, path and oauth url to be configured by config

    Compare with previous version

  • Achintya Singh added 1 commit

    added 1 commit

    • 5fa887cd - feat: added paseto signing for gitlab token

    Compare with previous version

  • Regarding the encrypted cookie, maybe you can use https://github.com/gin-contrib/sessions?tab=readme-ov-file#cookie-based instead which seems to nicely integrate with gin.

    Additionally we need a way to only allow users that are member in a specific group with a specific role so that i.e. only VideoLAN maintainer group members can login.

  • Please register or sign in to reply
    Loading