Skip to content

frontend: implement GitLab PKCE OAuth flow - #27

Merged
MekDrop merged 1 commit into
mainfrom
feat/issue-7-gitlab-pkce
Apr 23, 2026
Merged

MekDrop merged 1 commit into
mainfrom
feat/issue-7-gitlab-pkce

Conversation

@MekDrop

@MekDrop MekDrop commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add frontend/src/services/gitlab.js with two exported functions:
    • startGitlabLogin(host, clientId) — generates a 48-byte hex code_verifier, derives code_challenge via crypto.subtle.digest('SHA-256') + base64url, stores verifier + host in sessionStorage, redirects to GitLab authorize endpoint with full PKCE params
    • exchangeGitlabCode(code) — reads and removes verifier/host from sessionStorage, POSTs application/x-www-form-urlencoded to /oauth/token, returns parsed JSON response
  • Supports both gitlab.com and self-hosted GitLab instances

Test plan

  • startGitlabLogin('gitlab.com', clientId) redirects to https://gitlab.com/oauth/authorize with response_type=code, scope=read_api, code_challenge_method=S256, correct redirect_uri
  • sessionStorage keys gitlab_verifier and gitlab_host are set before redirect
  • exchangeGitlabCode(code) POSTs to https://gitlab.com/oauth/token with correct body fields
  • sessionStorage keys are removed after exchangeGitlabCode is called
  • Works with a custom self-hosted GitLab host URL

Closes #7

@MekDrop
MekDrop merged commit 6e340cf into main Apr 23, 2026
1 check passed
@MekDrop
MekDrop deleted the feat/issue-7-gitlab-pkce branch April 23, 2026 00:21
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.

Frontend: GitLab PKCE OAuth flow (no Worker needed)

1 participant