Skip to content

#24 AgentCore Identity integration support#48

Open
MatejNedic wants to merge 6 commits intospring-ai-community:mainfrom
MatejNedic:#24-agentcore-identity-impl
Open

#24 AgentCore Identity integration support#48
MatejNedic wants to merge 6 commits intospring-ai-community:mainfrom
MatejNedic:#24-agentcore-identity-impl

Conversation

@MatejNedic
Copy link
Copy Markdown

@MatejNedic MatejNedic commented Mar 15, 2026

I have introduced integration test to showcase how it would look on user side.

Implements #24

@MatejNedic MatejNedic changed the title AgentCore Identity integration support #24 AgentCore Identity integration support Mar 17, 2026
* @param context which holds headers.
* @return conversationId based on userId and sessionId from header
*/
default String resolveConversationId(AgentCoreContext context) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I am not sure tbh if we should have default method. I took this from example Yuriy Bezsonov provided


@Bean
@ConditionalOnMissingBean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
Copy link
Copy Markdown
Author

@MatejNedic MatejNedic Mar 23, 2026

Choose a reason for hiding this comment

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

I would move this to user provided configuration with documenting recommended config tho.

I have introduced in PR so we can comment over how solution would look.

@Bean
@ConditionalOnMissingBean
public AgentCorePrincipalProvider agentCorePrincipalProvider() {
return new JwtAgentCorePrincipalProvider();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As I understand, for JwtAgentCorePrincipalProvider to work, users must configure SecurityFilterChain with oauth2ResourceServer().jwt() in their own code. This creates a split
responsibility where part of the security setup is hidden in the starter while the rest must be implemented by the user.

This partial abstraction can be confusing - users may not realize the starter's JWT support won't work without their own configuration.

Proposal: Extract all Spring Security-related functionality into a separate spring-ai-agentcore-security-starter that:

  1. Depends on the base spring-ai-agentcore-runtime-starter
  2. Provides complete, working security configuration (including SecurityFilterChain)
  3. Makes the security dependency explicit and opt-in

This would:

  • Keep the core starter lightweight (no Spring Security dependencies)
  • Provide a complete, working solution for users who need JWT authentication
  • Make the security requirements explicit rather than implicit
  • Follow Spring Boot's pattern of separate security starters"

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
<optional>true</optional>
</dependency>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am not very happy with this dependency in runtime starter, as suggested: perhaps move all spring security related code to separate security starter will be cleaner

* @param workloadName the workloadName
* @return the opaque workload access token
*/
public String getWorkloadAccessToken(String jwt, String workloadName) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It is nice to have an opportunity to get workload token, but calling AgentCore client from the agent code is quite rarely use case from my perspective. I think it is also candidate for separate security starter / utiity

*
* @author Matej Nedic
*/
public class HeaderAgentCorePrincipalProvider implements AgentCorePrincipalProvider {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would keep this one (the header based) in basic runtime starter and move spring security related in special one

import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@SpringBootTest(classes = { IdentityAgentServiceIT.TestApp.class, IdentityAgentServiceIT.TestConfig.class })
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would be nice to add two examples:

  • with AgentCore Identity inbound authorizer
  • without without AgentCore Identity inbound authorizer
    into examples subfloder

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.

2 participants