Spring boot 嘿I';我正在尝试将Rest服务与openAM和Oauth2.0集成。每次我';m使用rest端点-localhost:8084/greet

Spring boot 嘿I';我正在尝试将Rest服务与openAM和Oauth2.0集成。每次我';m使用rest端点-localhost:8084/greet,spring-boot,ldap,openam,spring-security-ldap,Spring Boot,Ldap,Openam,Spring Security Ldap,它显示错误-重定向\u uri\u不匹配提供的重定向uri与预先注册的值不匹配。 在这里我要实现- 我正在尝试将我的spring引导服务与openAM集成起来,以便对用户进行身份验证和授权 SpringBoot服务应与openAm连接,并使用授权对用户进行身份验证 存储在openAm中的所有用户都应该通过spring服务进行身份验证 Application.yml文件用于openAM与服务的连接 server: port: 8084 # HTTP (Tomcat) port #

它显示错误-重定向\u uri\u不匹配提供的重定向uri与预先注册的值不匹配。

在这里我要实现-

  • 我正在尝试将我的spring引导服务与openAM集成起来,以便对用户进行身份验证和授权
  • SpringBoot服务应与openAm连接,并使用授权对用户进行身份验证
  • 存储在openAm中的所有用户都应该通过spring服务进行身份验证
  • Application.yml文件用于openAM与服务的连接

        server:
      port: 8084   # HTTP (Tomcat) port
    #  context-path: /ldap-example
    
    openam:
      client:
        clientId: OAuth2Agent
        clientSecret: password
        accessTokenUri: http://openam.example.com:8080/openam/oauth2/access_token
        userAuthorizationUri: http://openam.example.com:8080/openam/oauth2/authorize
        tokenName: access_token
        authenticationScheme: query
        clientAuthenticationScheme: form
        scope: email
      resource:
        userInfoUri: http://openam.example.com:8080/openam/oauth2/userinfo
    
    logging:
      level:
        org.springframework.security: DEBUG
    
  • Forgerock配置OAuth 2.0/OpenID及服务
  • 4.1控制器文件

    @RestController
    public class HomeController {
        /**
         * Simple REST method without params
         * @return String representing the greeting
         */
        @RequestMapping(value="/greet", method=RequestMethod.GET)
        public ResponseEntity<String> greet() {
            String greeting = "Hello world!";
            return new ResponseEntity<String>(greeting, HttpStatus.OK);
        }
    
        @RequestMapping("/user")
        public Principal user(Principal principal) {
            return principal;
        }
    }
    
    
      [1]: https://i.stack.imgur.com/1ri6R.png
    
    @RestController
    公共类家庭控制器{
    /**
    *无参数的简单REST方法
    *@表示问候语的返回字符串
    */
    @RequestMapping(value=“/greet”,method=RequestMethod.GET)
    公众反应{
    字符串问候语=“你好,世界!”;
    返回新的响应(问候语,HttpStatus.OK);
    }
    @请求映射(“/user”)
    公共主要用户(主要用户){
    返还本金;
    }
    }
    [1]: https://i.stack.imgur.com/1ri6R.png
    
    您需要在OAuth2客户端配置中的OAuth2身份验证请求中添加Spring引导服务发送的
    重定向uri
    ,在OpenAM中配置客户端时,可能存在重定向uri的配置。这应该与SpringBoot应用程序的OAuth重定向url相匹配,这样OpenAM就知道它实际上是您的应用程序。
    @RestController
    public class HomeController {
        /**
         * Simple REST method without params
         * @return String representing the greeting
         */
        @RequestMapping(value="/greet", method=RequestMethod.GET)
        public ResponseEntity<String> greet() {
            String greeting = "Hello world!";
            return new ResponseEntity<String>(greeting, HttpStatus.OK);
        }
    
        @RequestMapping("/user")
        public Principal user(Principal principal) {
            return principal;
        }
    }
    
    
      [1]: https://i.stack.imgur.com/1ri6R.png