Skip to content

Move AUTHORIZATION_KEY out of GrpcSecurity to avoid ClassNotFoundException#410

Open
therepanic wants to merge 2 commits into
spring-projects:mainfrom
therepanic:gh-409
Open

Move AUTHORIZATION_KEY out of GrpcSecurity to avoid ClassNotFoundException#410
therepanic wants to merge 2 commits into
spring-projects:mainfrom
therepanic:gh-409

Conversation

@therepanic
Copy link
Copy Markdown
Contributor

The problem is that we don’t include the spring-security module in the client's auto-configuration, which causes a ClassNotFoundException when we try to use any of its constants. In our case, this is GrpcSecurity#AUTHORIZATION_KEY, and since client modules use it, we need to move it out. In our case, I moved it to a separate internal class called GrpcMetadataKeys.

Closes: gh-409

…ption

The problem is that we don’t include the `spring-security` module in the
client's auto-configuration, which causes a `ClassNotFoundException`
when we try to use any of its constants. In our case, this is
`GrpcSecurity#AUTHORIZATION_KEY`, and since client modules use it, we
need to move it out. In our case, I moved it to a separate internal
class called `GrpcMetadataKeys`.

Closes: spring-projectsgh-409

Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
@therepanic therepanic changed the title Move AUTHORIZATION_KEY out of GrpcSecurity to avoid ClassNotFoundException Move AUTHORIZATION_KEY out of GrpcSecurity to avoid ClassNotFoundException May 16, 2026
Comment on lines +28 to +32
*/
public final class GrpcMetadataKeys {

private GrpcMetadataKeys() {
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If anyone has any good suggestions for what to call this class, that would be great. Honestly, I haven't come up with anything for the current one either.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How about GrpcHeaders? It mirrors Spring's own HttpHeaders convention — a well-known precedent for a constants class holding header key names. Since gRPC's Metadata is the equivalent of HTTP headers, the analogy feels natural. It's short, discoverable, and leaves room to add other standard headers later without the name feeling off. GrpcMetadataKeys isn't bad, but "Keys" is slightly redundant since all the fields are keys by definition.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Overall, it does look good - I was thinking the same thing myself. Thanks. I think it's definitely better than what we have now, though that’s debatable, but I still agree with you.

Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
Copy link
Copy Markdown

@bkmuraliext bkmuraliext left a comment

Choose a reason for hiding this comment

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

Thanks for the quick resolution!

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.

BasicAuthenticationInterceptor causes ClassNotFoundException when spring-security-config is absent (client-only starter)

2 participants