Skip to content

grpc: combine client and server SecurityInfo - #2798

Open
dfawley wants to merge 3 commits into
grpc:masterfrom
dfawley:security_context
Open

grpc: combine client and server SecurityInfo#2798
dfawley wants to merge 3 commits into
grpc:masterfrom
dfawley:security_context

Conversation

@dfawley

@dfawley dfawley commented Aug 11, 2026

Copy link
Copy Markdown
Member

Also, rename SecurityContext to ValidateAuthority since that's what it does.

My plan is to add the common SecurityInfo into the upcoming PeerInfo struct.

@dfawley dfawley added this to the grpc-next milestone Aug 11, 2026
@dfawley
dfawley requested a review from arjan-bal August 11, 2026 21:38
Also, rename SecurityContext to ValidateAuthority since that's what it does.

@arjan-bal arjan-bal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, with few minor comments.

Comment thread grpc/src/client/transport/tonic/test.rs Outdated
Box::new(MockConnectionSecurityContext),
Attributes::new(),
),
security_info: SecurityInfo::new("mock").with_security_level(SecurityLevel::NoSecurity),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Since NoSecurity is the default level, the call to with_security_level can be omitted.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for catching this.

Comment thread grpc/src/credentials/mod.rs Outdated
}

impl SecurityInfo {
/// Creates a new SecurityInfo with ajdfskjklfdsjklsdfajklsfdajk

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ajdfskjklfdsjklsdfajklsfdajk seems like a keymash, please remove.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Argh, sorry, I forgot to fix this.

Comment thread grpc/src/inmemory/mod.rs Outdated
use std::sync::Mutex;
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
use std::task::{Context, Poll};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: The imports can be ungrouped for consistency.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed

@arjan-bal

Copy link
Copy Markdown
Contributor

/gemini review

@arjan-bal arjan-bal assigned dfawley and unassigned arjan-bal Aug 12, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the gRPC security credentials layer by consolidating client and server security info into a unified SecurityInfo struct and renaming ChannelSecurityContext to ValidateAuthority. The review feedback is highly constructive, pointing out a placeholder gibberish string in the documentation of SecurityInfo::new and outdated doc comments on LocalConnectionAuthorityValidator and ClientTlsAuthorityValidator that still refer to the old security context naming.

Comment thread grpc/src/credentials/mod.rs Outdated
/// connections.
#[derive(Debug, Clone)]
pub struct LocalConnectionSecurityContext;
pub struct LocalConnectionAuthorityValidator;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The doc comment above LocalConnectionAuthorityValidator still refers to ClientConnectionSecurityContext (which was renamed/removed). Consider updating the doc comment to refer to ValidateAuthority or LocalConnectionAuthorityValidator.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed

/// Security context for [`rustls`]-based gRPC [`ChannelCredentials`].
pub struct ClientTlsSecurityContext {
#[derive(Debug)]
pub struct ClientTlsAuthorityValidator {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The doc comment above ClientTlsAuthorityValidator still refers to it as a 'Security context' instead of an authority validator. Consider updating the doc comment to match the new name and purpose.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants