Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add a tech note on API authn/authz #96427

Merged
merged 1 commit into from
Feb 13, 2023

Conversation

knz
Copy link
Contributor

@knz knz commented Feb 2, 2023

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@knz knz force-pushed the 20230202-api-authn-tech-note branch 12 times, most recently from c778230 to f501c46 Compare February 2, 2023 18:18
craig bot pushed a commit that referenced this pull request Feb 3, 2023
96451: server: only forward the SQL identity in gRPC metadata r=andreimatei a=knz

Requested by `@andreimatei` .
Informs #96427.
Informs #45018.

Prior to this patch, we were forwarding any and all gRPC metdata during a RPC fanout. This was creating doubt and confusion, about how much data is really important/useful to forward.

Analysis suggests we only care about the SQL user identity resulting from HTTP authentication. So this patch limits the forwarding to just that information.

This specialization makes the forwarding logic easier to understand.


This patch additionally renames functions as follows:

| Old name                        | New name                              |
|---------------------------------|---------------------------------------|
| `userFromContext`               | `userFromIncomingRPCContext`          |
| `getSQLUsername`                | `userFromHTTPAuthInfoContext`         |
| `apiToOutgoingGatewayCtx`       | `forwardHTTPAuthInfoToRPCCalls`       |
| `forwardAuthenticationMetadata` | `translateHTTPAuthInfoToGRPCMetadata` |
| `propagateGatewayMetadata`      | `forwardSQLIdentityThroughRPCCalls`   |


Release note: None
Epic: None

Co-authored-by: Raphael 'kena' Poss <[email protected]>
@knz knz force-pushed the 20230202-api-authn-tech-note branch from f501c46 to b7f2729 Compare February 3, 2023 14:11
Copy link
Contributor

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

good note

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @dhartunian and @knz)


docs/tech-notes/api_authentication.md line 47 at r1 (raw file):

### Unauthenticated pure HTTP handler

HTTP -> direct HTTP handler

could you explain how come authenticationV2Mux is not in the call chain here? Where's the distinction being made between handlers that want auth and those who don't?

Copy link
Collaborator

@dhartunian dhartunian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: thankyou Raphael.

Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @andreimatei and @knz)

Copy link
Contributor Author

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @andreimatei and @dhartunian)


docs/tech-notes/api_authentication.md line 47 at r1 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

could you explain how come authenticationV2Mux is not in the call chain here? Where's the distinction being made between handlers that want auth and those who don't?

it's just health and vars. We opted them out, because they don't leak state out of the cluster.

@knz
Copy link
Contributor Author

knz commented Feb 13, 2023

@dhartunian Andrei's question raises a good point: the prometheus vars endpoint is currently exposed without authentication (for reasons that can be pulled back from the git history).

What do you think will happen if we start exposing more "intelligent" labels for metrics? I remember your project to annotate metrics using statement fingerprints. Maybe tenant labels as well. Do we want this data to be scrapable without authentication? This might need followup issues to investigate further.

@knz knz force-pushed the 20230202-api-authn-tech-note branch from b7f2729 to c9521be Compare February 13, 2023 05:06
@knz
Copy link
Contributor Author

knz commented Feb 13, 2023

bors r=andreimatei,dhartunian

@craig
Copy link
Contributor

craig bot commented Feb 13, 2023

Build succeeded:

@craig craig bot merged commit 3e26d85 into cockroachdb:master Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants