yaiam: web sign-in (Web) and admin API reads (Admin)

Web signs the users of a web application in with the code flow and
PKCE: state, nonce and verifier in a short-lived __Host- cookie, the ID
token checked per OIDC Core 3.1.3.7, profile, groups and roles from
UserInfo, and the RP-initiated logout URL. Admin reads users, groups
and group members from yaiam's admin API with a client credentials
token. Toolchain go1.27.4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
terminarandClaude Opus 5.5 committed 2026-11-17 10:54:53 +01:00
1 parent 4bff8798e5
commit a3e8f9bb3b
10 files changed
+1183 -16

No files matched your search

+36 -1
View File
@@ -14,7 +14,7 @@ Today it holds the Atlassian clients that `yareco`, `yabaratla` and
| `atlassian/jira` | Jira REST API client (Cloud v3 and Server/Data Center v2) |
| `atlassian/confluence` | small Confluence REST API client (classic content API) |
| `atlassian/internal/transport` | the HTTP machinery both share; not importable from outside |
| `yaiam` | sign a command-line program in at yaiam (device flow, RFC 8628) and keep its tokens (YAIAM-710, 2026-11-09) |
| `yaiam` | sign a command-line program in at yaiam (device flow, RFC 8628) and keep its tokens (YAIAM-710, 2026-11-09); sign a web application's users in (code flow with PKCE) and read users and groups from yaiam's admin API (2026-11-17) |
Standard library only, no third-party dependencies.
@@ -144,6 +144,41 @@ c.Logout(ctx, store) // revokes at the provider, forgets them
The user's guide is yaiam's `docs/manual/yetano-programme.md`; an
example program is yaiam's `examples/device-login`.
### Web applications
A web application signs its users in with `Web` (authorization code
flow with PKCE, a confidential or a public client):
```go
web := &yaiam.Web{
Client: yaiam.Client{Issuer: "https://login.example.org/t/default", ClientID: id},
ClientSecret: secret,
RedirectURL: "https://app.example.org/callback",
}
web.SignIn(ctx, w, r, "/after") // GET /login: redirect to yaiam
u, err := web.Callback(ctx, w, r) // GET /callback: u.Subject, u.Groups, u.Roles, u.ACR ...
out, _ := web.LogoutURL(ctx, u.IDToken)
```
- `SignIn` keeps a fresh state, nonce and PKCE verifier in a ten-minute
cookie of the browser (HttpOnly, SameSite=Lax, `__Host-` and Secure
on https); `Callback` checks the state against it and removes it.
The return path is a local path only.
- The ID token comes straight from the token endpoint over TLS, so its
signature is not checked (OpenID Connect Core 3.1.3.7) -- no crypto
here: iss, aud (and azp), exp, iat and the nonce are. Profile, groups
and roles come from UserInfo, which must name the same subject.
- The application keeps its own session and its own data under
`Subject` -- it stays when the user is renamed.
`Admin` reads a tenant's users, groups and group members from yaiam's
admin API with a service client's token (client credentials, cached
until a minute before it runs out; a refused one is fetched once more).
An example web application is yaiam's `examples/webapp`; an end-to-end
test against a real yaiam-authd is yaiam's
`internal/oidcprovider/weblogin_test.go`.
## Versioning
A release is a plain semver git tag (`v0.1.0`, ...) on this repository;