Configuration of spring-addons-starter-oidc to match default spring-boot-starter-oauth2-client behaviour #245
-
Following #244 Hello @ch4mpy , As you're suggesting, I'll keep the configuration for the property What about property Do not answer 302 Redirect to login to unauthorized requests in a REST APII saw the documentation about this part. I've been experimenting with the properties :
but I've noticed that for testing login process with the browser it was a bit more difficult, as it didn't handle the redirection automatically. I'll set this back on the final configuration. And if I understand correctly, it would be the front-end app responsibility to handle the post-login redirection, but only in case the first call answers 401 ? Do not make
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
You shouldn't have to set it, the defaults are fine.
Without the help of a Single-Page Application framework (Angular, React, Vue, ...), browsers are bad REST clients. Use a tool like Postman instead. You'll be able to send any kind of request in addition to
If the load for this service is low and will always be, yes it could be acceptable. But honestly, a Spring Cloud Gateway packaged as a native image has such a small impact on a production environment, that I'd probably use one in any case, unless the production environment has absolutely nothing to monitor and keep a healthy instance automatically. Be aware that in this situation, the requests to your REST API will require a cookie for a valid session to be authorized. If using a REST client like Postman, this can be tricky.
This database loop for each request is a waste of resources. It would be much better if the authorization server did this DB query and added all the data necessary for access control to token claims.
This is bad news for performance: opaque tokens must be introspected, which means a round-trip to the authorization server for each request to a resource server. This adds more latency to requests processing than decoding a JWT. Worse, if the authorization server is shared by many apps and if the global traffic increases, introspection can become a bottleneck (it can sort of DDoS the authorization server). What is your authorization server? Why does it issue opaque access tokens? What have you tried to get JWTs instead? |
Beta Was this translation helpful? Give feedback.
Access to
/login
should be allowed for anonymous requests (added topermitAll
). But again, this is something you should need only when building a server-side rendered application (Thymeleaf, JSP, etc.).If using
spring-addons-starter-oidc
,spring-boot-starter-oauth2-client
, andspring-boot-starter-oauth2-resource-server
, be careful that you have twoSecurityFilterChain
beans. As you probably want this/login
endpoint to be processed by the "client" filter chain, make sure that it is added to thesecurity-matchers
andpermit-all
properties undercom.c4-soft.springaddons.oidc.client
.Last the default template is provided by Spring only if no explicit configuration is provided for the
login-uri