feat: initialize loyalty agent service structure, security configuration, and campaign MCP service orchestration
This commit is contained in:
@@ -2,7 +2,6 @@ package dev.sonpx.loyalty.agent.config;
|
||||
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.chat.model.ChatModel;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -18,39 +17,10 @@ public class AgentConfig {
|
||||
2. When a tool result contains an `agent_instruction`, you MUST strictly follow its formatting rules when presenting the relevant data to the user. Do not output raw JSON data unless explicitly asked.
|
||||
""";
|
||||
|
||||
@Value("${loyalty.core.base-url}")
|
||||
private String coreBaseUrl;
|
||||
|
||||
@Bean
|
||||
public ChatClient loyaltyChatClient(ChatModel chatModel) {
|
||||
return ChatClient.builder(chatModel)
|
||||
.defaultSystem(AGENT_SYSTEM_PROMPT)
|
||||
.build();
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// public RestClient coreRestClient(OAuth2AuthorizedClientManager authorizedClientManager) {
|
||||
// return RestClient.builder()
|
||||
// .baseUrl(coreBaseUrl)
|
||||
// .requestInterceptor((request, body, execution) -> {
|
||||
// org.springframework.security.core.Authentication principal =
|
||||
// new org.springframework.security.authentication.AnonymousAuthenticationToken(
|
||||
// "key", "loyalty-agent-service",
|
||||
// org.springframework.security.core.authority.AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));
|
||||
// OAuth2AuthorizeRequest authorizeRequest = OAuth2AuthorizeRequest
|
||||
// .withClientRegistrationId("keycloak")
|
||||
// .principal(principal)
|
||||
// .build();
|
||||
// try {
|
||||
// OAuth2AuthorizedClient authorizedClient = authorizedClientManager.authorize(authorizeRequest);
|
||||
// if (authorizedClient != null && authorizedClient.getAccessToken() != null) {
|
||||
// request.getHeaders().setBearerAuth(authorizedClient.getAccessToken().getTokenValue());
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return execution.execute(request, body);
|
||||
// })
|
||||
// .build();
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -12,33 +12,13 @@ import org.springframework.security.web.SecurityFilterChain;
|
||||
public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) {
|
||||
http
|
||||
.csrf(AbstractHttpConfigurer::disable)
|
||||
.authorizeHttpRequests(authz -> authz
|
||||
.requestMatchers("/api/v1/agent/**", "/api/v1/conversations/**", "/ws/**", "/error").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
);
|
||||
// .oauth2Login(Customizer.withDefaults())
|
||||
// .oauth2Client(Customizer.withDefaults());
|
||||
return http.build();
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// public OAuth2AuthorizedClientManager authorizedClientManager(
|
||||
// ClientRegistrationRepository clientRegistrationRepository,
|
||||
// OAuth2AuthorizedClientService authorizedClientService) {
|
||||
//
|
||||
// OAuth2AuthorizedClientProvider authorizedClientProvider =
|
||||
// OAuth2AuthorizedClientProviderBuilder.builder()
|
||||
// .clientCredentials()
|
||||
// .build();
|
||||
//
|
||||
// AuthorizedClientServiceOAuth2AuthorizedClientManager authorizedClientManager =
|
||||
// new AuthorizedClientServiceOAuth2AuthorizedClientManager(
|
||||
// clientRegistrationRepository, authorizedClientService);
|
||||
// authorizedClientManager.setAuthorizedClientProvider(authorizedClientProvider);
|
||||
//
|
||||
// return authorizedClientManager;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -23,21 +23,6 @@ spring:
|
||||
connections:
|
||||
loyalty:
|
||||
url: ${MCP_SERVER_URL:http://localhost:9331}
|
||||
# security:
|
||||
# oauth2:
|
||||
# client:
|
||||
# registration:
|
||||
# keycloak:
|
||||
# client-id: ols-cli
|
||||
# client-secret: ${KEYCLOAK_CLIENT_SECRET:1jV8NSAeybIqmUK0AWhI8hgdo1q5itj7}
|
||||
# authorization-grant-type: client_credentials
|
||||
# provider:
|
||||
# keycloak:
|
||||
# token-uri: ${KEYCLOAK_TOKEN_URI:http://192.168.99.235/auth/realms/ols-cn-sit/protocol/openid-connect/token}
|
||||
|
||||
#loyalty:
|
||||
# core:
|
||||
# base-url: ${LOYALTY_CORE_BASE_URL:http://192.168.99.242:8081}
|
||||
|
||||
logging:
|
||||
pattern:
|
||||
|
||||
Reference in New Issue
Block a user