feat(ciba): RFC 9509 backchannel authentication (Poll + Ping modes) - #66
Merged
Conversation
Contributor
Benchmark regression reportThreshold: 25% Generated by the bench workflow. A |
thegdsks
force-pushed
the
feat/ciba-2026-06-22
branch
from
June 22, 2026 20:34
5b3e5b0 to
c098003
Compare
Implements CIBA (OpenID Client-Initiated Backchannel Authentication) for the authorization server. Adds POST /oauth/bc-authorize, extends POST /oauth/token with grant_type=urn:openid:params:grant-type:ciba, and provides ApproveBackchannelAuth / DenyBackchannelAuth service methods. Key additions: - AuthenticationDevice interface for out-of-band push notifications (FCM/APNs/SMS) - CIBAStorage optional interface; CIBA auto-disables when storage omits it - CIBAConfig in AuthorizationServerConfig with sensible defaults - Memory and Postgres storage implementations; migration 0016 - AS metadata advertising CIBA endpoints and delivery modes - DCR updated: redirect_uris not required for CIBA-only clients - 7 E2E tests covering happy path, slow_down, access_denied, expired_token, login_hint validation, binding_message propagation, and missing storage
thegdsks
force-pushed
the
feat/ciba-2026-06-22
branch
from
June 22, 2026 20:58
c098003 to
cebfca0
Compare
5 tasks
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.
Summary
POST /oauth/bc-authorizeendpoint and extendsPOST /oauth/tokenwithgrant_type=urn:openid:params:grant-type:ciba; exposesApproveBackchannelAuth/DenyBackchannelAuthservice methods on the rootTheAuthtypeCIBAStorageas an optional duck-typed interface; CIBA auto-disables at startup when the configured storage does not satisfy it, keeping deployments that do not need CIBA unaffectedChanges
New files
ciba.goAuthenticationDevice,CIBAConfig,CIBANotification, approve/deny methodsstorage_ciba.goCIBAStorageinterface aliasinternal/as/ciba.goBackchannelAuthenticate,PollBackchannelToken,ApproveBackchannelRequest,DenyBackchannelRequestinternal/as/config_ciba.goCIBAConfig,AuthenticationDeviceinterface,CIBANotification, defaultsinternal/as/storage_ciba.goCIBAStorageinterface (5 methods)internal/as/token_ciba.goMintCIBATokenshelper delegating to existingmintAccessAndRefreshinternal/as/handlers/handlers_ciba.gobc-authorize; error mapping for CIBA token errorsinternal/as/e2e_ciba_test.gointernal/models/models_ciba.goBackchannelRequeststruct and status/grant-type constantsinternal/models/errors_ciba.goauthorization_pending,slow_down,access_denied,expired_token, etc.storage/memory/memory_ciba.goCIBAStorageimplementationstorage/postgres/postgres_ciba.goCIBAStorageimplementation using pgx/v5storage/postgres/migrations/0016_backchannel_requests.{up,down}.sqlModified files
internal/as/config.go: addedCIBA *CIBAConfigfield; validation callsapplyCIBADefaultsinternal/as/dcr.go:redirect_urisno longer required for CIBA-only or client-credentials clients; addedGrantTypeCIBA/GrantTypeClientCredentials/GrantTypeTokenExchangeto the allowed setinternal/as/metadata.go:ASMetadataDocandgrantTypesAdvertisedconditionally populate CIBA discovery fieldsinternal/as/handlers/handlers.go: mounts/oauth/bc-authorizewhen CIBA enabled; dispatches CIBA grant inhandleTokenas.go,wiring.go,models.go,errors.go: thin wiring and re-exportsstorage/memory/memory.go: addsciba *cibaStateto in-memory storestoragetest/helpers.go: formatting fixE2E test coverage
TestCIBAPollHappyPath: full round-trip: register, bc-authorize, pending poll, approve, token poll returns access tokenTestCIBASlowDown: rapid consecutive polls triggerslow_down(400)TestCIBAAccessDenied:DenyBackchannelAuthcauses next poll to returnaccess_deniedTestCIBAExpiredToken: request with 2s TTL returnsexpired_tokenafter expiryTestCIBARequiresLoginHint: bc-authorize with no hint returnsinvalid_request(400)TestCIBABindingMessageInNotification: binding_message is forwarded toAuthenticationDevice.NotifyTestCIBAStorageMissing: storage that does not implementCIBAStoragecauses 404 on bc-authorizeTest plan
gofmt -l .returns empty (verified clean)go vet ./...passes (verified)go test -race -count=3 ./...passes (verified with 300s timeout; sleep-heavy CIBA tests need ~180s per count on CI).gofile (verified)mcpresource/is untouched (verified viagit diff origin/main -- mcpresource/)