Add AuditTokenRequest extended API#645
Merged
Merged
Conversation
This was referenced Jun 4, 2026
4495da0 to
acd727b
Compare
acd727b to
08324e3
Compare
Adds a NatsCredentialRequest resource under identity.k8s.appscode.com that wraps the appscode.com Register endpoint, so in-cluster callers (e.g. the audit lib) can obtain NATS credentials via the Kubernetes API server when direct egress to appscode.com is blocked. Includes the deepcopy / openapi / clientset / fake-client glue and a GetNatsCredential method on the identity b3 client used by the extended API storage in ui-server. Signed-off-by: Tamal Saha <tamal@appscode.com>
Lets callers that already know the cluster UID hit the register endpoint without needing a controller-runtime client. The existing GetNatsCredential now resolves the cluster identity via c.kc and delegates. Signed-off-by: Tamal Saha <tamal@appscode.com>
Only the UID is needed; reading clustermeta.ClusterMetadata directly avoids building (and discarding) the ClusterIdentity object. Signed-off-by: Tamal Saha <tamal@appscode.com>
It no longer needed any of *Client's state once the caller supplies the cluster UID. Pulling baseURL, token, and *http.Client into the signature keeps callers like ui-server able to customise the hub endpoint without forcing audit (and similar one-shot callers) to construct a Client. Signed-off-by: Tamal Saha <tamal@appscode.com>
This reverts commit 6cc95eb. Signed-off-by: Tamal Saha <tamal@appscode.com>
A zero-arg constructor for the common case of "talk to the production appscode.com endpoint, no auth, no kc" — used by audit's registerWithAppsCode now that the explicit nil/empty args were getting noisy. Signed-off-by: Tamal Saha <tamal@appscode.com>
Renames the extended-API kind, the typed clientset, the fake client, the b3 helper methods (GetAuditToken / GetAuditTokenForCluster) and the internal register payload struct. JSON tags on the response (natsSubject, natsServer, credential) are unchanged because the appscode.com wire format hasn't moved. Signed-off-by: Tamal Saha <tamal@appscode.com>
08324e3 to
505ea46
Compare
Signed-off-by: Tamal Saha <tamal@appscode.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.
Summary
NatsCredentialRequestunderidentity.k8s.appscode.com/v1alpha1, modelled onInboxTokenRequest(create-only, cluster-scoped, request + response).GetNatsCredentialmethod to the b3 client inpkg/identity— it POSTs to the appscode.comapi/v1/registerendpoint and returns subject/server/credential.Motivation
The audit library (
go.bytebuilders.dev/audit) currently callsappscode.com/api/v1/registerdirectly from inside every controller it's vendored into to obtain its NATS credential. In disconnected clusters this fails. Wrapping the call in an extended API lets the in-cluster ui-server proxy the registration so individual controllers don't need their own egress path.Test plan
go build ./...go vet ./...ui-serverPR compiles against this branch (replace directive)