Skip to content

Commit fb00038

Browse files
committed
Update docs and spell-check linting
- Upgrade to v8 of MegaLinter - Uncomment cspell checks and build out dictionary, including exclusions for non-inclusive language. - Fix typos - Add M2M client config notes to README (are otherwise buried in env-example). Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
1 parent d3d3ee7 commit fb00038

15 files changed

Lines changed: 185 additions & 93 deletions

.cspell.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"language": "en",
3+
"dictionaries": ["companies", "filetypes", "fullstack", "softwareTerms"],
4+
"words": [
5+
"trufflehog",
6+
"golangci",
7+
"godotenv",
8+
"doublestar",
9+
"clientcredentials",
10+
"logrus",
11+
"nosniff",
12+
"tcsh",
13+
"jasig",
14+
"linuxfoundation",
15+
"jaegertracing",
16+
"pprof",
17+
"zpages",
18+
"fluentbit",
19+
"chainguard",
20+
"hadolint",
21+
"GOARCH",
22+
"trimpath",
23+
"ldflags",
24+
"nonroot",
25+
"otelhttp",
26+
"vhost",
27+
"hostmetrics",
28+
"otelcol",
29+
"otlptracegrpc",
30+
"sdktrace",
31+
"tracecontext",
32+
"semconv",
33+
"securecookie",
34+
"zoneinfo",
35+
"chardata"
36+
],
37+
"flagWords": [
38+
"abort",
39+
"abortion",
40+
"blackhat",
41+
"black-hat",
42+
"whitehat",
43+
"white-hat",
44+
"cripple",
45+
"crippled",
46+
"master",
47+
"slave",
48+
"tribe",
49+
"sanity-check",
50+
"whitelist",
51+
"white-list",
52+
"blacklist",
53+
"black-list"
54+
],
55+
"ignorePaths": [
56+
".cspell.json",
57+
"LICENSE",
58+
"LICENSE-docs",
59+
"megalinter-reports"
60+
]
61+
}

.github/workflows/mega-linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ jobs:
3030
- name: MegaLinter
3131
id: ml
3232
# Use the Go flavor.
33-
uses: oxsecurity/megalinter/flavors/go@v7
33+
uses: oxsecurity/megalinter/flavors/go@v8

.mega-linter.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ DISABLE_LINTERS:
55
# Revive covers this, plus golangci-lint has trouble with newer go toolchains
66
# in go.mod.
77
- GO_GOLANGCI_LINT
8-
# cspell is laughably bad at code/comments/etc.
9-
- SPELL_CSPELL
108
# Link checking more likely to cause false positives than be useful for us.
119
- SPELL_LYCHEE
1210
# yamllint is sufficient for us.

0_config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// The auth0-cas-service-go service.
55
package main
66

7+
// spell-checker:disable
78
import (
89
"fmt"
910
"os"
@@ -13,6 +14,8 @@ import (
1314
"github.com/sirupsen/logrus"
1415
)
1516

17+
// spell-checker:enable
18+
1619
type config struct {
1720
Auth0Tenant string
1821
Auth0Domain string

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
FROM --platform=$BUILDPLATFORM cgr.dev/chainguard/go:latest AS builder
88

9-
# Set necessary environment variables needed for our image. Allow building to
10-
# other architectures via cross-compliation build-arg.
9+
# Set necessary environment variables needed for our image. Allow cross-compile
10+
# builds to other architectures via build-arg.
1111
ARG TARGETARCH
1212
ENV CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH
1313

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ bin/auth0-cas-server-go: *.go go.mod go.sum
1515
all: bin/auth0-cas-server-go docker-build
1616

1717
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
18+
docker pull --platform linux/amd64 oxsecurity/megalinter-go:v8
19+
docker run --rm --platform linux/amd64 -v '$(CURDIR):/tmp/lint:rw' oxsecurity/megalinter-go:v8
2020

2121
test:
2222
@echo "No tests to run ... would you like to 'make lint'?"

README.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@
44

55
This service was inspired by Auth0, through their `auth0-cas-server` service
66
formerly hosted at `github.com/auth0-samples/auth0-cas-server` (link now dead).
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.
7+
Like that service, it uses HTTP redirects to wrap an OpenID Connect
8+
authentication flow with the Central Authentication Service (CAS) SSO protocol,
9+
emulating multiple CAS clients from a single instance of the service. It does
10+
this by using a privileged connection to the Auth0 Management API to find
11+
clients tagged with CAS metadata, and dynamically adopting their client
12+
credentials.
1313

14-
Notable differeces with this implementation:
14+
Notable differences include:
1515

1616
- Rewritten in Go, including OpenTelemetry instrumentation and multi-arch build
1717
outputs including SPDX SBOMs.
18-
- Supports several additional CAS protocol endpoints implementing multiple CAS
19-
versions.
18+
- Additional HTTP endpoints to implement additional CAS protocol versions.
2019
- Implements CAS single-logout.
2120
- Implements CAS "gateway mode" to test for authentication without prompting
2221
the user.
@@ -55,7 +54,19 @@ Please see `env-example` for a list of required and optional environment
5554
variables that can be used to configure the server. For local development, you
5655
can copy this file to `.env` and modify it to suit your needs.
5756

58-
## Auth0 client configuration
57+
## Auth0 API client configuration
58+
59+
This service requires a non-interactive (machine-to-machine) client that
60+
supports the `client_credentials` grant type and is authorized for the
61+
following scopes on the Auth0 Management API:
62+
63+
- `read:clients`
64+
- `read:client_keys`
65+
66+
The client ID and client secret for this API client must be passed as
67+
environmental variables to the service.
68+
69+
## Auth0 CAS client configuration
5970

6071
To create a CAS-enabled Auth0 application, specify the follow settings:
6172

auth0_clients.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// The auth0-cas-service-go service.
55
package main
66

7+
// spell-checker:disable
78
import (
89
"context"
910
"encoding/json"
@@ -22,6 +23,8 @@ import (
2223
"golang.org/x/oauth2/clientcredentials"
2324
)
2425

26+
// spell-checker:enable
27+
2528
var (
2629
auth0Client *http.Client
2730
auth0Cache = cache.New(60*time.Minute, 5*time.Minute)
@@ -171,7 +174,7 @@ func getAuth0ClientByService(ctx context.Context, serviceURL string) (*auth0Clie
171174
}
172175

173176
// There is a match
174-
appLogger(ctx).WithFields(logrus.Fields{"service": serviceURL, "glob": glob, "auth0_client": client.Name}).Debugln("matched service in glob cache")
177+
appLogger(ctx).WithFields(logrus.Fields{"service": serviceURL, "glob": glob, "auth0_client": client.Name}).Debug("matched service in glob cache")
175178
auth0Cache.Set("cas-service-url/"+url.PathEscape(serviceURL), client, cache.NoExpiration)
176179
return &client, nil
177180
}
@@ -204,7 +207,7 @@ func getAuth0ClientByService(ctx context.Context, serviceURL string) (*auth0Clie
204207

205208
serviceGlobs := strings.Split(client.ClientMetadata["cas_service"], ",")
206209

207-
// Iterate over any comma-delimeted cas_service globs in the
210+
// Iterate over any comma-delimited cas_service globs in the
208211
// client_metadata.
209212
for _, glob := range serviceGlobs {
210213
match, err := doublestar.Match(glob, serviceURL)
@@ -222,7 +225,7 @@ func getAuth0ClientByService(ctx context.Context, serviceURL string) (*auth0Clie
222225
continue
223226
}
224227

225-
appLogger(ctx).WithFields(logrus.Fields{"service": serviceURL, "glob": glob, "auth0_client": client.Name}).Debugln("matched service")
228+
appLogger(ctx).WithFields(logrus.Fields{"service": serviceURL, "glob": glob, "auth0_client": client.Name}).Debug("matched service")
226229
// If the glob matches, save the match, but keep processing remaining
227230
// comma-delimited globs AND clients to complete the glob-to-client cache
228231
// update.

cas.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// The auth0-cas-service-go service.
55
package main
66

7+
// spell-checker:disable
78
import (
89
"context"
910
"crypto/rand"
@@ -21,6 +22,8 @@ import (
2122
"golang.org/x/oauth2"
2223
)
2324

25+
// spell-checker:enable
26+
2427
var store *sessions.CookieStore
2528

2629
type userAttributes struct {

check-headers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Exits with a 1 if one or more source files are missing a license header
99

1010
# Exclude code coming from a third-party. Typically these won't be checked into
11-
# source control, but occassionally "vendored" code is committed.
11+
# source control, but occasionally "vendored" code is committed.
1212
exclude_pattern='^(.*/)?(node_modules|vendor)/'
1313

1414
# Include build definitions.

0 commit comments

Comments
 (0)