Proposal for AuthN/Z API Refactor#119
Open
tomncooper wants to merge 2 commits into
Open
Conversation
Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Thomas Cooper <code@tomcooper.dev>
Signed-off-by: Thomas Cooper <code@tomcooper.dev>
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.
This PR contains a proposal to extract the
SubjectandPrincipalconcepts fromkroxylicious-apiinto a new lightweight module,kroxylicious-authentication-api, so thatkroxylicious-authorizer-apican be consumed independently of the full proxy API and its transitive dependencies (kafka-clients, jackson-annotations, compression codecs).The authorizer API was designed for general-purpose reuse, but its dependency on
kroxylicious-apimakes adoption impractical for non-Kroxylicious projects. Apicurio Registry, for example, has resorted to copying the authorizer API source into their own module to avoid the dependency tree. This refactor removes that barrier.The proposed
kroxylicious-authentication-apimodule will contain three types in theio.kroxylicious.authenticationpackage:Principalinterface with a singlename()methodSubjectinterface with a singleprincipals()method@UniqueannotationThe proposed package avoids a split-package situation that would block JPMS adoption.
The existing concrete
Subjectrecord inkroxylicious-apiwill be renamed toProxySubjectand will implement the proposedSubjectinterface. This rename avoids ambiguity when both the interface and the concrete type are in scope.ProxySubjectwill retain all existing behavior includingUser-principal validation,uniquePrincipalOfType,allPrincipalsOfType, andisAnonymous.The
kroxylicious-authorizer-apimodule will switch its compile dependency fromkroxylicious-apitokroxylicious-authentication-api.Authorizer.authorize()andAuthorizeResultwill reference theSubjectinterface rather than the concrete type. Method signatures inFilterContext,RouterContext,TransportSubjectBuilder, andSaslSubjectBuilderwill be updated to useProxySubjectwhere the concrete type is required.These are binary-incompatible and in some cases source-incompatible changes. The project is at 0.x where breaking changes carry lower migration cost, and the authorizer API was introduced recently with minimal external adoption. Downstream changes will follow two mechanical patterns: renaming
SubjecttoProxySubjectand updatingPrincipal/@Uniqueimports fromio.kroxylicious.proxy.authenticationtoio.kroxylicious.authentication.A PoC branch containing these proposed changes is available on my fork: https://github.com/tomncooper/kroxylicious/tree/auth-api-refactor