A callback that belongs to no sign-in of this browser is now ErrSignInState without contacting the provider (before, an unreachable provider turned it into a discovery error). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yetano-clients
Shared Go clients for the external services Yetano programs talk to.
This is a library module (yetano.dev/yetano/yetano-clients), imported
like core -- nothing here is built or published as a program.
Today it holds the Atlassian clients that yareco, yabaratla and
yamcp used to carry as three separate copies (owner decision
2026-11-01):
| Package | What |
|---|---|
atlassian |
Options, Auth, Deployment, TLS, the error types (APIError, StatusOf, ErrNotJSON, ErrResponseTooLarge, ErrInvalidArgument) |
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); 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.
yaiam signs a command-line program in at yaiam (device flow) and keeps
its tokens; see below.
Usage
c, err := jira.New(atlassian.Options{
BaseURL: "https://example.atlassian.net",
Deployment: atlassian.Cloud, // or atlassian.DataCenter
Auth: atlassian.Auth{Type: atlassian.AuthAPIToken, Username: email, Password: token},
Timeout: 60 * time.Second,
MaxRetries: 3,
})
issues, err := c.SearchAll(ctx, jira.SearchQuery{JQL: "project = DEV", Fields: []string{"summary"}})
New never sends a request. Every call takes a context; cancelling it
also ends a backoff or rate-limit wait.
Transport behaviour
One Options drives both clients:
- Auth:
api_token(e-mail + API token as basic auth, Cloud),basic,bearer/pat(Data Center personal access token),cookie(a raw Cookie header). The zeroTypepicks from the fields that are set. A type whose fields are empty sends no header at all. - TLS/proxy: optional CA bundle, explicit
InsecureSkipVerify,ProxyURLor the environment'sHTTPS_PROXY. - Redirects to another host drop
AuthorizationandCookie(also for downloads, e.g. a signed media URL). - Retries: 5xx and connection errors are retried
MaxRetriesattempts in total with backoff 2s, 4s, ... (cap 30s). 4xx is never retried. - 429: pauses every request of the client until
Retry-Afterand widens a shared minimum gap between requests, which narrows again on success; up to 10 such retries that do not count againstMaxRetries.DisableRateLimitRetryreturns the 429 at once instead. - APIDelay: fixed pause after every response.
- Bodies: an empty 2xx body reads as
{}; a non-JSON 2xx body (e.g. an SSO login page) isErrNotJSON, never an empty result.MaxResponseBytescaps what is read into memory. - Errors: a non-2xx answer is an
*atlassian.APIError(method, path, status, body;Message()extracts Atlassian's error text). Credentials never appear in an error or a log line; a download URL's query is dropped from errors and logs. - Pagination:
PaginatewalksstartAt/maxResultslistings and advances by the number of items actually returned (Jira may capmaxResults).
Jira
Typed calls: Myself, ServerInfo, ListProjects, Project,
ProjectVersions, Version, UpdateVersion, Fields, Issue,
Search/SearchAll (Cloud: /search/jql with nextPageToken; Data
Center: /search with offsets), SearchPage (one classic offset page),
CommentPage, Comments, Changelog, EditMeta, Transitions,
EditIssue/UpdateIssue, CreateIssue, AddComment, DoTransition,
AssignIssue, LinkIssues; TextBody encodes plain text as ADF on
Cloud and as a string on Data Center. Field helpers for custom fields:
OptionValues, SprintValues, CustomFieldNumber, Names.
Everything else goes through the raw Get/Post/Put/Delete/
Paginate/DownloadFile (paths are absolute, e.g.
/rest/agile/1.0/board).
Confluence
Search (CQL), Page, PageChildren, Space, ListSpaces,
CurrentUser, Ping, CreatePage, UpdatePage (re-reads the page and
returns *VersionConflictError instead of overwriting a newer version),
AddComment, AddLabel; StorageFromText turns plain text into an
escaped storage-format body. Kept small on purpose -- see TODO.md for
what is not covered.
Where the code came from
| Part | Origin |
|---|---|
retry/backoff, 429 throttle, APIDelay, Paginate, DownloadFile, cookie auth |
yabaratla/internal/jira (via yareco, which added contexts and log/slog) |
typed Jira reads, Search with nextPageToken, field helpers |
yareco/internal/jira |
| bearer/PAT/basic auth, CA file, proxy, redirect hardening, response cap, Atlassian error messages, Cloud/Data Center split, Jira writes, the Confluence client | yamcp/internal/provider/atlassian |
Program-specific parts stayed in the programs: yareco's German operator messages and field resolution, yamcp's error taxonomy and MCP output types, yabaratla's Confluence site-backup client.
Checks
make # fmt + vet + test (-race) + vulncheck
make test
yaiam
A command-line program signs its user in at yaiam -- or any OpenID Connect provider with the device flow -- and keeps the tokens:
c := &yaiam.Client{Issuer: "https://login.example.org/t/default", ClientID: id}
store := yaiam.FileStore{Path: filepath.Join(stateDir, "token.json")}
c.Login(ctx, store, func(d *yaiam.DeviceAuth) error {
fmt.Printf("Open %s and enter %s\n", d.VerificationURI, d.UserCode)
return nil
})
err := c.Authorize(ctx, store, req) // Bearer header; refreshes when needed
c.Logout(ctx, store) // revokes at the provider, forgets them
- Only standards: discovery, device authorization, token endpoint (device code, refresh token), revocation (RFC 7009), UserInfo. A public client, no secret.
FileStorekeeps the tokens in a 0600 file and refuses one others may read. A stored token is used only for its own issuer and client; a refused refresh token removes it (ErrLoginRequired).- Every endpoint must be https (http only on a loopback host), the
discovery document must name exactly the issuer, redirects are never
followed, answers are capped at 1 MiB. Tokens appear in no error, and
fmtprints aTokenwithout them. - Checking tokens on the server side is not here: yaiam's
pkg/httpauth(JWT against the issuer's keys, optional introspection).
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):
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)
SignInkeeps a fresh state, nonce and PKCE verifier in a ten-minute cookie of the browser (HttpOnly, SameSite=Lax,__Host-and Secure on https);Callbackchecks 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. - Any OpenID Connect provider works, not only yaiam: set
Scopesto what it offers (e.g.openid email profile; the default asks for yaiam's groups, roles and attributes).EmailVerifiedis true only for the JSON booleantrue(some providers send the string). PublicIssuer: when the application reaches the provider under another name than the browser does (a container network), the browser is sent to the endpoints on the public origin; the server keepsIssuer.AllowInsecure(onClient) accepts plain http off loopback, for a test installation on a closed network only.
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;
consumers require that tag. Never force-move a tag -- always cut a new
one, even for a one-line fix (see the meta-repository's AGENTS.md).
License
Proprietary, see LICENSE.