implement the CAEP 1.0 event vocabulary#1
Merged
Merged
Conversation
Add typed payloads for all eight OpenID CAEP 1.0 event types and register their decoders with go-secevent, so a parsed Security Event Token's events decode to typed Go values and CAEP events can be built back into a SET. This is the substance of the library; the stub package becomes a real vocabulary. Each event embeds a common Base envelope carrying the optional CAEP §3.1 fields (event_timestamp as go-secevent's NumericDate, initiating_entity, reason_admin, reason_user); the subject stays the SET's sub_id and is not duplicated on the event. The eight types are SessionRevoked, TokenClaimsChange, CredentialChange, AssuranceLevelChange, DeviceComplianceChange, SessionEstablished, SessionPresented, and RiskLevelChange — the last of which the original scaffold brief's expected list omitted but CAEP 1.0 §3.9 defines. Registration follows go-secevent's documented idiom: a single init calls RegisterEventType once per event-type URI, so a side-effect import wires the whole vocabulary (the database/sql-driver pattern). A generic decoder keeps that to one function. Decoding is lenient — unknown enum values and unrecognized members are preserved, the latter as json.RawMessage that re-emits byte-stably, so an event from a future CAEP profile survives a decode/encode cycle. Strictness is opt-in via Validate, which checks the required-field MUSTs and returns errors.Is-matchable sentinels. Tests cover registration completeness, typed-field extraction, lenient enums, open-extension round-tripping, the producer/consumer path through a real SET (Put then Parse then Typed), malformed-payload errors, and the required-field MUSTs. A conformance suite round-trips a spec-shaped golden fixture for every event type (CAEP 1.0 ships no machine-readable vectors). Statement coverage is ~91%. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Brings go-caep from a stub to the full OpenID CAEP 1.0 event vocabulary.
What's here
SessionRevoked,TokenClaimsChange,CredentialChange,AssuranceLevelChange,DeviceComplianceChange,SessionEstablished,SessionPresented,RiskLevelChange— each embedding a commonBaseenvelope (event_timestampas go-secevent'sNumericDate,initiating_entity,reason_admin,reason_user). The subject stays the SET'ssub_id.init(oneRegisterEventTypeper URI), soimport _ "github.com/hstern/go-caep"wires the whole vocabulary.json.RawMessage, re-emitted byte-stably).Validatechecks the CAEP required-field MUSTs and returnserrors.Is-matchable sentinels.Putproducer helper;Example_*functions; a conformance suite round-tripping a spec-shaped golden fixture per event type.Notes
go-secevent v0.1.0(transitivelygo-subjectid).risk-level-change(CAEP 1.0 §3.9) is included — the original scaffold brief's expected list omitted it.go vet, race tests, and golangci-lint all clean locally.🤖 Generated with Claude Code