Skip to content

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

@bkmuraliext

Description

@bkmuraliext

Bug Report
Summary
BasicAuthenticationInterceptor in spring-grpc-core imports GrpcSecurity, which extends AbstractConfiguredSecurityBuilder from spring-security-config. When using spring-grpc-client-spring-boot-starter (client-only), spring-security-config is not on the classpath, causing a ClassNotFoundException at runtime on every gRPC call.

Version
spring-grpc: 1.0.3 / Spring Boot: 4.0.6

Steps to Reproduce
Use spring-grpc-client-spring-boot-starter:1.0.3 (not the full spring-grpc-spring-boot-starter)
Configure BasicAuthenticationInterceptor as a @GlobalClientInterceptor
Make any outbound gRPC call

Actual Behaviour
java.lang.NoClassDefFoundError: org/springframework/security/config/annotation/AbstractConfiguredSecurityBuilder
at BasicAuthenticationInterceptor$1.start(BasicAuthenticationInterceptor.java:53)
Caused by: java.lang.ClassNotFoundException: ...AbstractConfiguredSecurityBuilder

Root Cause
BasicAuthenticationInterceptor uses GrpcSecurity.AUTHORIZATION_KEY. GrpcSecurity is a server-side class extending AbstractConfiguredSecurityBuilder from spring-security-config. Loading the interceptor's anonymous class triggers loading of GrpcSecurity, which fails without spring-security-config on the classpath.

Suggested Fix
Move AUTHORIZATION_KEY out of GrpcSecurity into a shared constants class with no Spring Security dependencies, or define it inline in BasicAuthenticationInterceptor:

private static final Metadata.Key AUTHORIZATION_KEY =
Metadata.Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions