Closes ENG-1510.
First-party code used two JWT libraries: `go-jose/v4` (workspace apps,
jwtutils, tailnet resume, agent hooks, chats) and `golang-jwt/jwt/v4`
(licenses, Azure OIDC PKI, test signers, and `jwt.MapClaims` in
idpsync). This moves everything to go-jose and removes
`golang-jwt/jwt/v4` from `go.mod`.
- `enterprise/coderd/license`: verification uses `jwt.ParseSigned` with
an EdDSA allowlist and `kid` lookup. Time claims are validated with zero
leeway, matching golang-jwt's previous behavior instead of go-jose's 1
minute default. `ParseClaimsIgnoreNbf` still returns `ErrMultipleIssues`
for any verification or time-claim failure other than `nbf`. `Claims`
now embeds `jwtutils.RegisteredClaims`, so `ExpiresAt` becomes `Expiry`
and `NumericDate` uses `.Time()`.
- `coderd/oauthpki`: the Azure client assertion is signed with go-jose
and keeps the `typ: JWT` and `x5t` headers that the existing test
asserts.
- Test helpers (`coderdtest`, `oidctest`, `coderdenttest`) sign with
go-jose.
- `jwt.MapClaims` is replaced with `map[string]any`. No callers used its
methods.
- A depguard rule (`single_jwt_library`) rejects new
`github.com/golang-jwt/jwt` imports.
`golang-jwt/jwt/v5` stays as an indirect dependency through
`SherClockHolmes/webpush-go`.
<details>
<summary>Decision log</summary>
- **Why go-jose over golang-jwt:** `coderd/jwtutils/jwe.go` needs JWE,
which golang-jwt doesn't support, so only go-jose can be the single
library. go-jose was already used for the more security-sensitive token
paths, and `coreos/go-oidc` depends on it anyway. Its `ParseSigned`
requires an explicit algorithm allowlist. Moving the golang-jwt usages,
which were mostly `MapClaims`, was the smaller change.
- **Expiry edge case:** golang-jwt treated a license as expired at `now
>= exp`, and go-jose treats it as expired at `now > exp`. With
whole-second timestamps the difference is at most one second.
- **Not evaluated:** a comparison of CVE history or maintenance pace
between the two libraries.
</details>
Validation: `make pre-commit`. Tests: `enterprise/coderd/license`,
`enterprise/coderd` (license, trial, OIDC, and sync tests),
`enterprise/trialer`, `enterprise/coderd/usage`,
`enterprise/coderd/enidpsync`, `coderd/oauthpki`, `coderd/idpsync`,
`coderd/coderdtest/oidctest`, `coderd` (OIDC, login, Google instance
identity, and OAuth2 tests), `coderd/externalauth`,
`coderd/provisionerdserver`, `cli`. I confirmed the depguard rule flags
a `golang-jwt/jwt/v5` import.
> Generated with Coder Agents on behalf of @deansheather.
Group sync settings can contain group IDs that belong to another
organization or that no longer exist. At login, `SyncGroups` passed
mapped IDs straight through to `InsertUserGroupsByID`, which has no
organization filter, so the settings for one organization could cause a
user to be added to a group in a different organization.
`SyncGroups` now partitions each organization's expected groups with
`PartitionOutInvalidSettings` and only syncs those
inside the organization. Groups in another organization, and IDs that
match no group, are dropped and reported with one
warning per kind. Login and the rest of the sync proceed.
Generated by Claude Code under the direction of @eric-hughes-coder.
Fixes all our Go file imports to match the preferred spec that we've _mostly_ been using. For example:
```
import (
"context"
"time"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/xerrors"
"gopkg.in/natefinch/lumberjack.v2"
"cdr.dev/slog/v3"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/serpent"
)
```
3 groups: standard library, 3rd partly libs, Coder libs.
This PR makes the change across the codebase. The PR in the stack above modifies our formatting to maintain this state of affairs, and is a separate PR so it's possible to review that one in detail.
Upgrades to slog v3 which includes a small, but backward incompatible API change to the acceptible call arguments when logging. This change allows us to verify via compile time type checking that arguments are correct and won't cause a panic, as was possible in slog v1, which this replaces (v2 was tagged but never used in coder/coder).
It also updates dependencies that also use slog and were updated.
I've left the `aibridge` dependency as a commit SHA, under the assumption that the team there (cc @pawbana @dannykopping ) will tag and update the dependency soon and on their own schedule.
Other dependencies, I pushed new tags.
## Summary
In this pull request we're adding support for OIDC allowed groups in the
OSS version as part of work for
https://github.com/coder/coder/issues/17027.
### Changes
- Restored support for parsing group allow list in OSS code
### Testing
- Added tests for OSS code
- Tested allowed/prohibited group OIDC flows in premium and OSS
Adds a custom marshaler to handle some cases where nils were being
marshaled to nulls, causing the web UI to throw an error.
---------
Co-authored-by: Steven Masley <stevenmasley@gmail.com>