FusionAuth / fusionauth-spring-security

FusionAuth OpenID Connect Library for Spring Security
https://fusionauth.io
MIT License
4 stars 1 forks source link

Integrating fusionAuth (Oauth) with Spring cloud gateway (Reactive) #10

Open najafian opened 1 year ago

najafian commented 1 year ago

_I've got a problem to integrate fusionAuth with spring cloud gateway. can you help me on this issue?

this is my application.properties_

spring.security.oauth2.resourceserver.jwt.issuer-uri=${domain.oauth}/oauth/token

spring.security.oauth2.client.provider.global.issuer-uri=${domain.oauth}/oauth/token
spring.security.oauth2.client.provider.global.authorizationUri=${domain.oauth}/oauth/authorize
spring.security.oauth2.client.provider.global.jwk-set-uri=${domain.oauth}/token_keys
spring.security.oauth2.client.provider.global.user-name-attribute=user_name

spring.security.oauth2.client.provider.fusion.issuer-uri=http://localhost:9011/oauth2/token
spring.security.oauth2.client.provider.fusion.authorizationUri=http://localhost:9011/oauth2/authorize

spring.security.oauth2.client.registration.global.client-name=global-gateway
spring.security.oauth2.client.registration.global.scope=openid, any
spring.security.oauth2.client.registration.global.client-secret=ID
spring.security.oauth2.client.registration.global.client-id=secret

spring.security.oauth2.client.registration.fusion.scope=openid, email
spring.security.oauth2.client.registration.fusion.client-id=ID
spring.security.oauth2.client.registration.fusion.client-secret=secret    
najafian commented 1 year ago

When I run the application It shows me the error:

_Error creating bean with name 'authorizedClientService' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/reactive/ReactiveOAuth2ClientConfigurations$ReactiveOAuth2ClientConfiguration.class]: Unsatisfied dependency expressed through method 'authorizedClientService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientRegistrationRepository' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/reactive/ReactiveOAuth2ClientConfigurations$ReactiveClientRegistrationRepositoryConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.client.registration.InMemoryReactiveClientRegistrationRepository]: Factory method 'clientRegistrationRepository' threw exception; nested exception is java.lang.IllegalArgumentException: Unable to resolve Configuration with the provided Issuer of "http://localhost:9011/oauth2/token"_

najafian commented 1 year ago

I added Below Dependencies:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-security</artifactId>
            <version>2.2.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>
najafian commented 1 year ago

when I add your dependency:

        <dependency>
            <groupId>io.fusionauth</groupId>
            <artifactId>fusionauth-spring-security</artifactId>
            <version>1.0.5</version>
        </dependency>

It gives the below error:

***************************
APPLICATION FAILED TO START
***************************

Description:

Web application could not be started as there was no org.springframework.boot.web.servlet.server.ServletWebServerFactory bean defined in the context.

Action:

Check your application's dependencies for a supported servlet web server.
Check the configured web application type.

Disconnected from the target VM, address: '127.0.0.1:44667', transport: 'socket'

Process finished with exit code 1
mooreds commented 1 year ago

@najafian This example is pretty old and I'm not sure exactly what is going wrong. We are working on a new one. I will share it with you when it is done (should be in the next few weeks).