forked from juanfont/headscale
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow use of the preferred_username OIDC claim
Previously, Headscale would only use the `email` OIDC claim to set the Headscale user. In certain cases (self-hosted SSO), it may be useful to instead use the `preferred_username` to set the Headscale username. This also closes juanfont#938. This adds a config setting to use this claim instead. The OIDC docs have been updated to include this entry as well. In addition, this adds an Authelia OIDC example to the docs. Added OIDC claim integration tests. Updated the MockOIDC wrapper to take an environment variable that lets you set the username/email claims to return. Added two integration tests, TestOIDCEmailGrant and TestOIDCUsernameGrant, which check the username by checking the FQDN of clients. Updated the HTML template shown after OIDC login to show whatever username is used, based on the Headscale settings.
- Loading branch information
Showing
8 changed files
with
413 additions
and
13 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
.github/workflows/test-integration-v2-TestOIDCEmailGrant.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# DO NOT EDIT, generated with cmd/gh-action-integration-generator/main.go | ||
# To regenerate, run "go generate" in cmd/gh-action-integration-generator/ | ||
|
||
name: Integration Test v2 - TestOIDCEmailGrant | ||
|
||
on: [pull_request] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-$${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v34 | ||
with: | ||
files: | | ||
*.nix | ||
go.* | ||
**/*.go | ||
integration_test/ | ||
config-example.yaml | ||
- uses: cachix/install-nix-action@v18 | ||
if: ${{ env.ACT }} || steps.changed-files.outputs.any_changed == 'true' | ||
|
||
- name: Run general integration tests | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
run: | | ||
nix develop --command -- docker run \ | ||
--tty --rm \ | ||
--volume ~/.cache/hs-integration-go:/go \ | ||
--name headscale-test-suite \ | ||
--volume $PWD:$PWD -w $PWD/integration \ | ||
--volume /var/run/docker.sock:/var/run/docker.sock \ | ||
--volume $PWD/control_logs:/tmp/control \ | ||
golang:1 \ | ||
go test ./... \ | ||
-tags ts2019 \ | ||
-failfast \ | ||
-timeout 120m \ | ||
-parallel 1 \ | ||
-run "^TestOIDCEmailGrant$" | ||
- uses: actions/upload-artifact@v3 | ||
if: always() && steps.changed-files.outputs.any_changed == 'true' | ||
with: | ||
name: logs | ||
path: "control_logs/*.log" |
57 changes: 57 additions & 0 deletions
57
.github/workflows/test-integration-v2-TestOIDCUsernameGrant.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# DO NOT EDIT, generated with cmd/gh-action-integration-generator/main.go | ||
# To regenerate, run "go generate" in cmd/gh-action-integration-generator/ | ||
|
||
name: Integration Test v2 - TestOIDCUsernameGrant | ||
|
||
on: [pull_request] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-$${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v34 | ||
with: | ||
files: | | ||
*.nix | ||
go.* | ||
**/*.go | ||
integration_test/ | ||
config-example.yaml | ||
- uses: cachix/install-nix-action@v18 | ||
if: ${{ env.ACT }} || steps.changed-files.outputs.any_changed == 'true' | ||
|
||
- name: Run general integration tests | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
run: | | ||
nix develop --command -- docker run \ | ||
--tty --rm \ | ||
--volume ~/.cache/hs-integration-go:/go \ | ||
--name headscale-test-suite \ | ||
--volume $PWD:$PWD -w $PWD/integration \ | ||
--volume /var/run/docker.sock:/var/run/docker.sock \ | ||
--volume $PWD/control_logs:/tmp/control \ | ||
golang:1 \ | ||
go test ./... \ | ||
-tags ts2019 \ | ||
-failfast \ | ||
-timeout 120m \ | ||
-parallel 1 \ | ||
-run "^TestOIDCUsernameGrant$" | ||
- uses: actions/upload-artifact@v3 | ||
if: always() && steps.changed-files.outputs.any_changed == 'true' | ||
with: | ||
name: logs | ||
path: "control_logs/*.log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.