Skip to content

Add GitLab controller support with OIDC auth and config file#10

Draft
welteki wants to merge 2 commits intoself-actuated:masterfrom
welteki:gitlab
Draft

Add GitLab controller support with OIDC auth and config file#10
welteki wants to merge 2 commits intoself-actuated:masterfrom
welteki:gitlab

Conversation

@welteki
Copy link
Copy Markdown
Member

@welteki welteki commented Mar 20, 2026

Description

Adds GitLab platform support to the CLI alongside GitHub. A new config file (~/.actuated/config.json) stores per-controller credentials keyed by URL, supporting both GitHub tokens and GitLab OIDC credentials (refresh token, client ID, OIDC provider URL).

GitLab authentication uses the Device Authorization Grant flow with OpenID Connect. The short-lived id_token (JWT, ~2min validity) is cached and reused when still valid (with 30s leeway), and automatically refreshed via the stored refresh_token when expired.

The runners and jobs commands have been implemented for GitLab, dispatching to platform-specific implementations based on the controller's platform in config. Commands not yet supported for GitLab return a clear error message, e.g. the "repair" command is not supported for platform "gitlab".

Example auth flow:

export ACTUATED_URL=https://gitlab-controller.example.com

# Authenticate with gitlab.com (default)
actuated-cli auth --platform gitlab --url $ACTUATED_URL

# Authenticate with a self-managed GitLab instance
actuated-cli auth --platform gitlab --url $ACTUATED_URL --gitlab-url https://gitlab.example.com

# Use commands as normal — token refresh is automatic
actuated-cli runners
actuated-cli jobs

Backward compatibility with --token/--token-value flags and the legacy PAT file is preserved.

Breaking change: GitHub users must re-authenticate with actuated-cli auth --url URL to store their token in the new config file, or continue using the --token/--token-value flags.

Motivation and context

Actuated is adding support for GitLab CI alongside GitHub Actions. The CLI needs to authenticate with GitLab controllers using OIDC and dispatch commands to platform-specific API endpoints with different request/response formats.

How has this been tested

  • go build ./... and go vet ./... pass.
  • Tested end-to-end against a local GitLab instance: auth, listing runners, and listing jobs.
  • The auth command has also been tested against public gitlab.com.
  • No regression testing against GitHub has been performed yet.

welteki added 2 commits March 20, 2026 18:52
Add GitLab platform support alongside GitHub. The CLI now detects the
platform from a config file (~/.actuated/config.json) keyed by controller
URL and dispatches runners/jobs commands to platform-specific implementations.

GitLab authentication uses the Device Authorization Grant flow with OIDC.
The short-lived id_token (~2min) is cached in config and reused when valid
(with 30s leeway); otherwise it is refreshed via the stored refresh_token.
Refresh tokens are rotated on each use and saved back to config.

Config and OIDC field names are kept generic (URL, IDToken, RefreshToken)
so the mechanism can be reused for other OIDC providers in the future.

All commands now resolve the controller URL via getControllerURL() and
token via getPat() which checks config before falling back to the legacy
PAT file. Backward compatibility with --token/--token-value flags and
the PAT file is preserved.

Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
Add checkGitHubOnly() guard to the 11 commands that only have GitHub
implementations. Running them with a GitLab controller now returns:
"the X command is not supported for platform gitlab".

Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
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