Spring OID C с OpenAM - PullRequest
       27

Spring OID C с OpenAM

1 голос
/ 31 марта 2020

Я бы хотел обработать поток предоставления кода авторизации с помощью Spring.

Он «работает» для перенаправлений, когда он поступает в мое приложение, правильно перенаправляется в openam, authN и предоставляет authZ, отправлять, перенаправлять to redirectUri.

Но когда я возвращаюсь в redirectUri, кажется, что Spring не go внутри моего метода (не останавливается на моей точке останова), и контекст безопасности, вероятно, пуст, так что нет аутентифицированы, поэтому перенаправлены обратно в auth.

Вот мой конфиг, я что-то упустил?

REST API в Springboot, с angular frontend

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
        <relativePath />
    </parent>
...
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-client</artifactId>
        </dependency>
@Configuration
@EnableWebSecurity
public class SecurityConfigOAuth2 extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
            .and()
                .authorizeRequests()
                    .antMatchers("/REST/v1/authorization-code/**").permitAll()
                    .anyRequest()
                        .authenticated()
            .and()
                .csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
            .and()
                .oauth2Login()
            .and()
                .oauth2Client()
        ;
    }
}
server:
  port: 8080
  servlet:
    context-path: /OAuth2Client

spring:
  application:
    name: OAuth2Client

  security:
    basic:
      enabled: false
    oauth2:
      client:
        registration:
          openam:
            clientId: MyClientId
            scope:
              - openid
              - profile
              - email
            authorizationGrantType: authorization_code

---

spring:
  profiles: dev

  security:
    oauth2:
      client:
        provider:
          openam:
            tokenUri: {openam-dev}/access_token
            authorizationUri: {openam-dev}/authorize
            userInfoUri: {openam-dev}/userinfo
            tokenInfoUri: {openam-dev}/tokeninfo
            jwkSetUri: {openam-dev}/jwk_uri
        registration:
          openam:
            clientSecret: MyClientSecret-dev
            redirectUri: "{baseUrl}/REST/v1/authorization-code/callback"

  logging:
    level:
      org.springframework.security: DEBUG
      org.springframework.web.client.RestTemplate: DEBUG
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...