Replies: 2 comments
-
|
For any async work that you are doing inside the data fetchers, you'll need to handle this with a special task executor that propagates the context. Please refer to the Spring Security docs here: https://docs.spring.io/spring-security/reference/features/integrations/concurrency.html |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your quick response. But, my current issue is the data fetcher cannot access the SecurityContext. How can I handle a special task executor without being able to get the SecurityContext? I found the SecurityContext cannot be accessible as long as the data fetch happened at the 2nd level. For example, if I run the following query, query ($id: ID!) { and, I defined the following api. @DgsData(parentType = DgsConstants.COMPANY.TYPE_NAME, field = DgsConstants.COMPANY.MultiTenancyProperties) @DgsData(parentType = DgsConstants.MULTITENANCYPROPERTY.TYPE_NAME, field = DgsConstants.MULTITENANCYPROPERTY.Tenants) Then, I will find the SecurityContext is accessible till multiTenancyProperties Fetcher level, but, it is not accessible at tenants Fetcher level. Q1. why multiTenancyProperties Fetcher level can still access SeucrityContext? Thanks for your attention. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, experts,
What's the strategy of DGS to propagate SecurityContext into the Thread? Right now, I found I can access SecurityContext from root level thread with @DgsQuery function but not always from nested function such as @DgsData @DgsDataFetch. I believe it is related to the SecurityContext is not propagate to threads by default.
What's the strategy to access SecurityContext in DGS? I tried the spring setting (spring.security.strategy = MODE_INHERITABLETHREADLOCAL). But, it does not work. I still cannot use SecurityContextHolder function to access the authentication object.
Thanks for your attention.
Beta Was this translation helpful? Give feedback.
All reactions