Repository navigation
Correct the README, doc comments and example against the code - #341
Merged
Merged
Conversation
Coverage Report for CI Build 45624553093Coverage decreased (-0.05%) to 88.549%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions2 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
The README named middleware, options and interface signatures that do not exist, several of its Go examples did not compile, its line anchors into the code had drifted, and many provider limits and requirements were not written down. It also did not say that the v1 module depends on golang-jwt/jwt v3, which has an advisory with no fixed v3 release. The example's Validator rejected users of six of the providers it registers, and its frontend sent the audience in a parameter no handler reads, so every example token had an empty audience.
Version updates are switched off, so only security updates open pull requests. v1.29.0 was published seconds after v2.5.0 and took the "Latest" mark, so AGENTS.md now says to publish v1 first when both lines are released together.
The verify message template now gets the service URL and a second token meant for a link, so the example uses them instead of a fixed host and the token meant for pasting.
paskal
force-pushed
the
audit-docs-fixes
branch
from
November 24, 2026 17:52
bc24b87 to
01833c6
Compare
umputun
requested changes
Nov 24, 2026
umputun
left a comment
Member
There was a problem hiding this comment.
the docs part is good to go after a few small corrections, and the Dependabot file should go.
README.md:174- "accepts tokens only from providers registered on this service" is too strong.isProviderAllowedalso accepts a token when the user id up to its first_(the whole id when it has none) names a registered provider, whateverAuthProvider.Namesays, so a service registering onlybitbucketacceptsbitbucket_devtokens. Fix: say the provider is matched by the signed provider name or by that id prefix.README.md:604-615- the new two-siteAudienceReaderexample sits under a section that promises one customer's tokens can't be used in another customer's subsystem. The reader is one allowlist for the whole service, so asite1token passes onsite2routes. Fix: one sentence that the list is service-wide and a per-tenant route has to compareUser.Audiencewith the tenant the request names.README.md:716-TokenDurationis not the lifetime of every JWT. A Telegram login setsExpiresAtto 30 minutes (provider/telegram.go:343, same in v2) andSetkeeps an explicit expiry, so the first Telegram token lives 30 minutes even with the example's one-minuteTokenDuration. Fix: say it applies to tokens issued without an explicit expiry and mention the Telegram case._example/README.md:11- "each provider below is enabled by its environment variables" reads as "set these and login works". Apple can't complete a login at the example'shttp://localhost:8080(https only, no localhost, andform_postneedsSameSiteNoneModewithSecureCookies), and X rejectslocalhostper the README's own X section. Fix: say the variables configure credentials and add one sentence for Apple and X.AGENTS.md:49- "The dev and custom server provider tests take their ports from the kernel" is true only after #340. On this branch they bind 8080, 9096, 18084 and 18085, and the port list leaves out 8080, 9096 and 18085. Fix: drop the sentence and list those ports, or leave it as is if #340 goes in first.AGENTS.md:13- pls keep the~/.claude/format.shrow. Adding the gofmt/goimports row next to it is fine.AGENTS.md:41- pls drop the "Releases" section. The release order is mine to set, and if v2 should show as Latest I'll mark it directly..github/dependabot.yml- pls drop it. The repo never had a config, so version updates were never on, and the Dependabot PRs in history for/,/v2and/_examplewere security updates from the repo settings, whichopen-pull-requests-limitdoesn't cover. The file changes nothing, and its first lines are GitHub's "get started with version updates" template.
The middleware also accepts a token whose user id prefix names a registered provider, the audience allowlist is shared by every tenant of a service, and a Telegram login sets its own 30-minute expiry, so the README claimed more than the code does. The example README read as if setting the variables was enough for Apple and X, which cannot complete a login on the example's localhost URL. The format.sh row stays in AGENTS.md next to the new one.
The repository never had version updates enabled, and the security updates it receives come from the repository settings, which the file does not affect. Release order is the maintainer's call.
Collaborator
Author
|
All points are addressed in b118b19 and da1b578:
|
The user and status routes now report the identity Auth accepts, basic credentials included, with a fixed 401 body, and the verify provider refuses an empty user or address and an address that would move the user::address split, so the README described the routes and checks as they were. The custom server snippet passed a logger the quick starts never set, and Run panics on a nil one. A refresh gives a persistent cookie its full CookieDuration again, so the option limits idle time. LoginAuth no longer names outlook.com, which accepts only OAuth2 for SMTP, SameSite Strict is scoped to providers on another site, and provider names have to be path-safe or are skipped.
A persistent cookie gets its full CookieDuration again whenever a refresh reissues it, so the quick-start comments now say the cookie expires a day after it was last issued.
umputun
reviewed
Nov 25, 2026
umputun
left a comment
Member
There was a problem hiding this comment.
all points from the last round are fixed, thx. #340 is merged now, and two sentences here describe the routes as they were before it, plus a few smaller corrections:
README.md:189- "Without a valid token/auth/useranswers 401 with{"error": "..."}... With one,/auth/useranswers thetoken.UserJSON" is not what #340 does. Basic credentials accepted byAdminPasswdorBasicAuthCheckerget 200 with that identity and no token, a valid token rejected by theValidatoror the provider check gets 401 and its cookie cleared, and the 401 body is always{"error":"unauthorized"}. It also contradicts the #340 line a few lines above it. Fix: say the routes report the identityAuthwould accept, and answer 401{"error":"unauthorized"}/ "not logged in" otherwise.README.md:311- "The library does not check the format ofaddress" is no longer true: after #340sendConfirmationanswers 400invalid addressfor an address that contains::or starts with:, and 400 for an emptyuseroraddress. Pls name those checks and keep the validate and rate-limit advice.README.md:497-505- the rewrittenCustomServerOptlist leaves outL, and the snippet passesoptions.Logger, which neither quick start sets.CustomServer.RuncallsLogfbefore it opens the listener, so a copy of this snippet panics on a nil logger at startup. Fix: markLas required and uselogger.Stdin the snippet.README.md:718- add that reissuing the cookie resets its fullCookieDuration. Each refresh reissues it, soCookieDurationlimits idle time, not session age, and the quick-start comments promising re-login after a day read wrong without it.README.md:376- personal outlook.com mailboxes accept only OAuth2 for SMTP since September 2024 (Microsoft), and the sender has no OAuth2. Pls describeLoginAuthas LOGIN for servers that offer only LOGIN, e.g. Office 365 while the tenant allows basic SMTP auth, and drop outlook.com.README.md:766- "http.SameSiteStrictModebreaks every provider" is too broad. Strict only drops the handshake cookie on a cross-site callback, so a provider on the same site, like the dev server on the app's host, still works. Pls scope it to providers on another site.README.md:463and:514- "any name is allowed" is not true.addProviderskips a name that failsisValidProviderName(spaces, reserved characters) and only logs an[ERROR]line, so the provider never shows up in/auth/list. Pls say the name has to be path-safe: letters, digits,-,.,_,~.
Collaborator
Author
|
All points are addressed in 7a10c91, and the cookie lifetime in db6d847:
|
umputun
added a commit
that referenced
this pull request
Nov 25, 2026
…in by id A cookie token whose refresh fails went through JWTService.Reset directly, which sets Content-Type text/plain, so under Trace a page that leaves the type to sniffing was served as text/plain. The refresh-failure branch now uses resetCookies like the Validator and provider rejections, in both modules. Only a cookie token reaches the refresh, so the cookies are expired as before. The example granted admin to any user named dev_admin, which an anonymous or email login can pick. It now matches the id, which only the dev provider leaves unprefixed. The godoc of Opts.VerifConfirmationStore and NewInMemoryVerifStore says a restart forgets redeemed tokens. The same note for the README and AGENTS.md waits in docs/backlog until #341 is merged, since it rewrites the lines next to both.
paskal
force-pushed
the
audit-docs-fixes
branch
from
November 25, 2026 13:31
db6d847 to
ebb5009
Compare
umputun
added a commit
that referenced
this pull request
Nov 25, 2026
The example's Validator matched user id prefixes before the dev name check. Dev ids are the bare typed names, so a dev user named email_alice or custom123_x passed the dev_ rule. The signed provider name now decides first. The bitbucket endpoint comes from golang.org/x/oauth2/bitbucket, the same URLs, which gosec read as hardcoded credentials. README and example README fixes: - a dev user without the dev_ prefix gets 401 and cleared cookies on the first authenticated request, not only on /private_data - User.Audience is filled by Get, not by Parse or the login response - TokenDuration applies to tokens issued through Set; a token signed with TokenService().Token gets no expiry unless ExpiresAt is set - the default custom server login page also asks for a password - an empty Telegram base URL selects the public API - the service's own hostname accepts any port even when Opts.URL names one - the reverse proxy case is labelled as not supported - a restart forgets redeemed verify tokens with the default in-memory store, in the README and AGENTS.md, which closes that backlog item The Opts.AudienceReader comment in both modules says nil allows any audience and an empty list rejects every token, as checkAuds does. New backlog items: aud from the login request is not proof of tenant membership, a self-built handler must set claims.ID for the XSRF check, and the LoginAuth comment still names outlook.com.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, the README named middleware, options and interface signatures that do not exist, several of its Go examples did not compile, its line anchors into the code had drifted, and many provider limits and requirements were not written down. It also did not say that the v1 module carries an unfixed golang-jwt advisory. After this change, the README, the doc comments,
AGENTS.mdand the example describe what the code does, and the changed Go code blocks compile against v2.Fixes:
github.com/golang-jwt/jwtv3, which has GO-2025-3553 (excessive memory allocation during header parsing) with no fixed v3 release, that v1 gets security fixes where its dependencies allow, and that v1 users should move to v2.AuthenticatormethodsAuth,AdminOnly,TraceandRBACunder the/v2import path;middleware.Admindoes not exist. A token is accepted when the provider name signed into it, or its user id prefix, names a registered provider.devAuthServer.Run(context.Background()), theGetEmailFnexample, which also checkederrtoo late, the basic auth example, and the email and Telegram examples, which uselogger.Std. The direct provider's JSON body example, in the README and theLoginHandlerdoc comment, loses a trailing comma that made it answer 400.bolt:///tmp/avatars.bdb(the old one opened a relative path), the Mongo URI example is corrected, the avatar link example uses a valid id,AvatarStoreis documented as optional with what nil andavatar.NoOpdo, and the size, format and identicon size limits are listed.SecretReader.Getreturns(string, error), per-site secrets needOpts.AudSecrets, andClaimsUpdateris also called with a nilclaims.User. The audience check isOpts.AudienceReader, one allowlist for the whole service. The token and cookie lifetimes default to 15 minutes and 31 days; a Telegram login sets its own 30-minute token expiry, and reissuing a persistent cookie on a refresh starts its fullCookieDurationagain./auth/userand/auth/statusreport the identityAuthwould accept, every logout path is served by the provider added first, and the XSRF section lists every route and middleware the check runs in and saysXSRFIgnoreMethodsentries are upper case.html/templatemessage template with an example confirmation link, the emptyuserandaddressand malformed address checks the library makes, and the validation and rate limiting left to the application, and the replay protection a hand-builtVerifyHandlerlacks.RunorProcessUpdateand the update formatProcessUpdateexpects, the single-instance limit and the persistent cookie.Host, its/authmount, its bare user ids and the host the application must be opened on; the custom server's required logger, its optional login page options, itsUserAuthorizationHandlerand the ids it returns; custom provider names have to be path-safe;BearerTokenHookFn,ContextSender,NewTelegramAPIWithBaseURLand the CSP on custom handlers.https://<your domain>/auth/apple/callbackand its name arrives only on the first authorisation; the effect ofSameSiteCookieon callbacks, Battle.net's EU endpoints, Patreon's paid subscriber flag and Microsoft avatars needing the avatar proxy are documented;NewTwitteris documented as an OAuth 1.0a provider.AGENTS.md: agofmt/goimportsformatting row, verify tokens are one-shot within oneServiceby default, and the test-port note lists the fixed ports in use.Behaviour changes, in the example only:
Validatoradmits users of every provider the example registers. Previously, Twitter, Apple, Bitbucket, anonymous, email and Telegram logins succeeded and then got 401 on/private_data.site, oraudfor the anonymous direct provider). Previously, it sentid, which nothing reads, so every token of the example had an empty audience.Housekeeping: the finished backlog entry about the dev provider host is removed.
The changed README Go code blocks compile and pass
go vetagainst v2 in a scratch module; on master the same check stops at the basic auth example. Tests pass with-racein both modules, the example builds,go mod tidyleaves no change, and golangci-lint v2.15.0 reports no issues in the root module and v2. No library code changes apart from doc comments.A v2 release is due after this is merged: master carries the fixes of #340, #338 and #339 and the OAuth 2.0 provider for X, none of them in a release since v2.5.0 (released 19 November 2026).