spring-authorization-server icon indicating copy to clipboard operation
spring-authorization-server copied to clipboard

How-to: Use Spring Authorization server behind Spring Cloud Gateway

Open rcbandit111 opened this issue 3 years ago • 32 comments

Publish a guide on How-to: Implement the core services behind Spring Cloud Gateway:

rcbandit111 avatar Jan 02 '22 19:01 rcbandit111

Related #499

sjohnr avatar Jan 03 '22 16:01 sjohnr

When I can expect this guide?

rcbandit111 avatar Jan 06 '22 01:01 rcbandit111

Kind remind guys. I will appreciate it if someone write me some configuration steps before official documentation is ready.

rcbandit111 avatar Jan 27 '22 00:01 rcbandit111

@rcbandit111 It will be a while before we get to this as there are a few higher priority tasks we need to work on first.

If someone in the community can help that would be great. cc @spencergibb

jgrandja avatar Jan 27 '22 20:01 jgrandja

@jgrandja Thank you for the response. I will wait further information.

rcbandit111 avatar Jan 27 '22 21:01 rcbandit111

No additional configuration is required if it is only used behind a gateway. However, in the case of load balancing, spring session support is required, because the server uses session to associate authentication actions.

jacko9et avatar Jun 28 '22 09:06 jacko9et

Is this suit your needs #807

salutonmondo avatar Jul 22 '22 01:07 salutonmondo

@salutonmondo I believe this issue is addressing using Spring Authorization Server behind Spring Cloud Gateway, whereas the sample you submitted treats SAS as an identity provider but does not route the requests to it. When we look more deeply at this issue, we'll have to think about what use cases make sense for putting SAS behind the gateway. One that I can think of, for example, is rate limiting to protect the authorization server or specific endpoints from malicious clients.

sjohnr avatar Jul 22 '22 18:07 sjohnr

@salutonmondo Thanks for your demo, I added some comments there in your https://github.com/spring-projects/spring-authorization-server/pull/807, could you shed some light?

uniquejava avatar Sep 14 '22 13:09 uniquejava

use database to share data between auth servers, this can reslove load balancing problem.

zhoyq-work avatar Feb 21 '23 09:02 zhoyq-work

any update recently?

zhenhe avatar Mar 07 '23 01:03 zhenhe

Hi, any update?

maradanasai avatar Mar 11 '23 02:03 maradanasai

I once needed this, after some research, I found what I really need is how to use spring cloud gateway as resource server and verify token from this single point. Finally I managed to do this, and I don't think I need the auth server sit behind spring cloud gateway now. Here is my current demo architecture.

image

The benefit: I just verify token from spring cloud gateway and pass the resolved user id as http header to my downstream micro-services and all my microservices now don't even have a dependency on spring security.

I once used spring cloud gateway as oauth2 client, --- almost each tutorial on the internet do this, and I think that is too academic/complex and not feasible at all in a real large application.

uniquejava avatar Mar 14 '23 02:03 uniquejava

I once needed this, after some research, I found what I really need is how to use spring cloud gateway as resource server and verify token from this single point. Finally I managed to do this, and I don't think I need the auth server sit behind spring cloud gateway now. Here is my current demo architecture.

image

The benefit: I just verify token from spring cloud gateway and pass the resolved user id as http header to my downstream micro-services and all my microservices now don't even have a dependency on spring security.

I once used spring cloud gateway as oauth2 client, --- almost each tutorial on the internet do this, and I think that is too academic/complex and not feasible at all in a real large application.

good advice,how scg do both verify token and then pass request ? use filter?

zhenhe avatar Mar 15 '23 02:03 zhenhe

@zhenhe Yes, a single UserHeaderFilter will do the job, and here is an example: https://stackoverflow.com/a/71485398/2497876

uniquejava avatar Mar 17 '23 06:03 uniquejava

I once needed this, after some research, I found what I really need is how to use spring cloud gateway as resource server and verify token from this single point. Finally I managed to do this, and I don't think I need the auth server sit behind spring cloud gateway now. Here is my current demo architecture.

image

The benefit: I just verify token from spring cloud gateway and pass the resolved user id as http header to my downstream micro-services and all my microservices now don't even have a dependency on spring security.

I once used spring cloud gateway as oauth2 client, --- almost each tutorial on the internet do this, and I think that is too academic/complex and not feasible at all in a real large application.

Hi. Can you make a sample repo? Many thanks.

dangfsix avatar Apr 19 '23 19:04 dangfsix