Skip to content

Commit dc14799

Browse files
authored
Merge pull request #5 from linuxfoundation/ems/megalinter
Add MegaLinter; module updates
2 parents 562417f + e821108 commit dc14799

File tree

17 files changed

+220
-118
lines changed

17 files changed

+220
-118
lines changed

.github/workflows/license-header-check.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ name: License Header Check
1111
branches:
1212
- main
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
license-header-check:
1619
name: License Header Check

.github/workflows/mega-linter.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
# Copyright The Linux Foundation and each contributor to LFX.
3+
# SPDX-License-Identifier: MIT
4+
5+
name: MegaLinter
6+
7+
"on":
8+
pull_request: null
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: ${{ github.ref }}-${{ github.workflow }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
megalinter:
19+
name: MegaLinter
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
# Git Checkout
24+
- name: Checkout Code
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
# MegaLinter
30+
- name: MegaLinter
31+
id: ml
32+
# Use the Go flavor.
33+
uses: oxsecurity/megalinter/flavors/go@v7

.github/workflows/publish.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ name: Publish
99
- main
1010
workflow_dispatch:
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
publish:
1417
name: Publish
1518
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
1622
steps:
1723
- uses: actions/checkout@v4
1824
- uses: actions/setup-go@v4

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
# SPDX-License-Identifier: MIT
33

44
.env
5-
bin/
6-
sbom/
5+
go.work
6+
/bin/
7+
/sbom/
8+
9+
/megalinter-reports/

.mega-linter.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright The Linux Foundation and each contributor to LFX.
2+
# SPDX-License-Identifier: MIT
3+
---
4+
DISABLE_LINTERS:
5+
# Revive covers this, plus golangci-lint has trouble with newer go toolchains
6+
# in go.mod.
7+
- GO_GOLANGCI_LINT
8+
# cspell is laughably bad at code/comments/etc.
9+
- SPELL_CSPELL
10+
# Link checking more likely to cause false positives than be useful for us.
11+
- SPELL_LYCHEE
12+
# yamllint is sufficient for us.
13+
- YAML_PRETTIER
14+
DISABLE_ERRORS_LINTERS:
15+
# These are informative but don't need to break the build.
16+
- COPYPASTE_JSCPD
17+
GITHUB_COMMENT_REPORTER: false

.trivyignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# No free access to Chainguard versioned labels.
2+
AVD-DS-0001
3+
4+
# Allow no health check: Docker-built container is for local development only
5+
# (ko-build is used for build artifact).
6+
AVD-DS-0026

0_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright The Linux Foundation and its contributors.
22
// SPDX-License-Identifier: MIT
33

4+
// The auth0-cas-service-go service.
45
package main
56

67
import (

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Copyright The Linux Foundation and its contributors.
22
# SPDX-License-Identifier: MIT
33

4+
# checkov:skip=CKV_DOCKER_7:No free access to Chainguard versioned labels.
5+
# hadolint global ignore=DL3007
6+
47
FROM --platform=$BUILDPLATFORM cgr.dev/chainguard/go:latest AS builder
58

69
# Set necessary environment variables needed for our image. Allow building to
@@ -24,6 +27,9 @@ RUN go build -o /go/bin/auth0-cas-server-go -trimpath -ldflags="-w -s" github.co
2427
# Run our go binary standalone
2528
FROM cgr.dev/chainguard/static:latest
2629

30+
# Implicit with base image: setting explicitly for linters.
31+
USER nonroot
32+
2733
EXPOSE 8080
2834

2935
COPY --from=builder /go/bin/auth0-cas-server-go /auth0-cas-server-go

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ bin/auth0-cas-server-go: *.go go.mod go.sum
1212
@mkdir -p bin
1313
go build -o bin/auth0-cas-server-go github.com/linuxfoundation/auth0-cas-server-go
1414

15+
all: bin/auth0-cas-server-go docker-build
16+
17+
lint:
18+
docker pull --platform linux/amd64 oxsecurity/megalinter-go:v7
19+
docker run --rm --platform linux/amd64 -v '$(CURDIR):/tmp/lint:rw' oxsecurity/megalinter-go:v7
20+
21+
test:
22+
@echo "No tests to run ... would you like to 'make lint'?"
23+
1524
# Build and label a local Docker container of auth0-cas-server-go.
1625
docker-build:
1726
docker build -t $(IMAGE_NAME):$(GIT_HASH) -t $(IMAGE_NAME):latest .

README.md

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,89 @@
22

33
## Overview
44

5-
This service was inspired by Auth0, through their example at https://github.com/auth0-samples/auth0-cas-server. It is a simple authentication redirector which wraps an OpenID Connect authentication flow to expose it as server implementing the Central Authentication Service (CAS) SSO protocol. The service leverages configuration stored within Auth0 client metadata, which it reads using a privileged connection to the Auth0 API, in order to emulate multiple different clients dynamically per login session.
5+
This service was inspired by Auth0, through their example at
6+
[auth0-samples/auth0-cas-server](https://github.com/auth0-samples/auth0-cas-server).
7+
It is a simple authentication redirector which wraps an OpenID Connect
8+
authentication flow to expose it as server implementing the Central
9+
Authentication Service (CAS) SSO protocol. The service leverages configuration
10+
stored within Auth0 client metadata, which it reads using a privileged
11+
connection to the Auth0 API, in order to emulate multiple different clients
12+
dynamically per login session.
613

714
Notable differeces with this implementation:
815

9-
- Rewritten in Go, including OpenTelemetry instrumentation and multi-arch build outputs including SPDX SBOMs.
10-
- Supports several additional CAS protocol endpoints implementing multiple CAS versions.
16+
- Rewritten in Go, including OpenTelemetry instrumentation and multi-arch build
17+
outputs including SPDX SBOMs.
18+
- Supports several additional CAS protocol endpoints implementing multiple CAS
19+
versions.
1120
- Implements CAS single-logout.
12-
- Implements CAS "gateway mode" to test for authentication without prompting the user.
21+
- Implements CAS "gateway mode" to test for authentication without prompting
22+
the user.
1323
- Supports both XML and JSON CAS response formats.
14-
- Allows for path wildcards and multiple, comma-separated CAS service definitions in `client_metadata.cas_service` configuration.
24+
- Allows for path wildcards and multiple, comma-separated CAS service
25+
definitions in `client_metadata.cas_service` configuration.
1526

1627
## Linux Foundation specific changes
1728

18-
The following hardcoded behavior is specific to the Linux Foundation's Auth0 environment:
29+
The following hardcoded behavior is specific to the Linux Foundation's Auth0
30+
environment:
1931

20-
- LF-namespaced OIDC claims used for username and group attributes coming from IdP.
21-
- Custom CAS attributes: `uid`, `field_lf_*` and `profile_name_*` added to match our reference implementation.
32+
- LF-namespaced OIDC claims used for username and group attributes coming from
33+
IdP.
34+
- Custom CAS attributes: `uid`, `field_lf_*` and `profile_name_*` added to
35+
match our reference implementation.
2236

23-
Porting these into a dynamic configuration system would be useful for generalizing this tool. For instance, a toml file could map upstream OIDC claims to both required CAS fields as well as optional additional CAS attributes, and provide per-attribute customization of the mb4-filtering feature.
37+
Porting these into a dynamic configuration system would be useful for
38+
generalizing this tool. For instance, a toml file could map upstream OIDC
39+
claims to both required CAS fields as well as optional additional CAS
40+
attributes, and provide per-attribute customization of the mb4-filtering
41+
feature.
2442

2543
## Deploying and running the server
2644

2745
You can pull the latest image from the GitHub Container Registry:
2846

29-
```
47+
```bash
3048
docker pull ghcr.io/linuxfoundation/auth0-cas-server-go:latest
3149
```
3250

33-
Pinning your deployments to a release label (rather than ":latest") is recommended for production use.
51+
Pinning your deployments to a release label (rather than ":latest") is
52+
recommended for production use.
3453

35-
Please see `env-example` for a list of required and optional environment variables that can be used to configure the server. For local development, you can copy this file to `.env` and modify it to suit your needs.
54+
Please see `env-example` for a list of required and optional environment
55+
variables that can be used to configure the server. For local development, you
56+
can copy this file to `.env` and modify it to suit your needs.
3657

3758
## Auth0 client configuration
3859

3960
To create a CAS-enabled Auth0 application, specify the follow settings:
4061

4162
- Application Type: Regular Web Application
4263
- Allowed Callback URLs: `https://<auth0-cas-server-go>/cas/oidc_callback`
43-
- Allowed Logout URLs (optional): the CAS logout return URL of your application, if passed by the CAS client ("service" for v3 logout, or "url" for v2 logout).
44-
- Advanced -> Application Metadata: add Key "cas\_service" with Value of one-or-more (comma-separated) URLs which match the "service" parameter of the CAS application's login request. A `*` will match any subdomain or a single path component, while `**` matches anything (including `/`).
64+
- Allowed Logout URLs (optional): the CAS logout return URL of your
65+
application, if passed by the CAS client ("service" for v3 logout, or "url"
66+
for v2 logout).
67+
- Advanced -> Application Metadata: add Key "cas\_service" with Value of
68+
one-or-more (comma-separated) URLs which match the "service" parameter of the
69+
CAS application's login request. A `*` will match any subdomain or a single
70+
path component, while `**` matches anything (including `/`).
4571
- Advanced -> OAuth -> OIDC Conformant: Enabled
4672

47-
Multiple apps CAS can be created for different sites: each will have the same callback URL, but they will have different `cas_service` URLs (and logout URLs, if needed).
73+
Multiple apps CAS can be created for different sites: each will have the same
74+
callback URL, but they will have different `cas_service` URLs (and logout URLs,
75+
if needed).
4876

49-
Auth0 client configurations read by this service are cached for performance. New apps should work automatically, but changes to `cas_service` URL patterns for existing apps may require a restart of the service to take effect.
77+
Auth0 client configurations read by this service are cached for performance.
78+
New apps should work automatically, but changes to `cas_service` URL patterns
79+
for existing apps may require a restart of the service to take effect.
5080

5181
## License
5282

5383
Copyright The Linux Foundation and its contributors.
5484

55-
This project's source code is licensed under the MIT License. A copy of the license is available in LICENSE.
85+
This project's source code is licensed under the MIT License. A copy of the
86+
license is available in LICENSE.
5687

57-
This project's documentation is licensed under the Creative Commons Attribution 4.0 International License (CC-BY-4.0). A copy of the license is available in LICENSE-docs.
88+
This project's documentation is licensed under the Creative Commons Attribution
89+
4.0 International License (CC-BY-4.0). A copy of the license is available in
90+
LICENSE-docs.

0 commit comments

Comments
 (0)