Stream: hapi
Topic: Query data inside interceptor
Marek Gocał (Jul 01 2021 at 19:28):
I'd like to create a custom interceptor that check permissions based on data query result. Does hapi support "server side fluet query" - so I'd like to query data directly from within my jpa server, and not using rest api
Marek Gocał (Jul 01 2021 at 19:32):
To be more precise what my interceptor does:
- Receive external (outh provider) token
- Call outh service to verify if token is valid
-
Get user details for the outh service
4. Find user that matches user details email (e.g. via system/identifier keys) -
Filter results based on the user id
So my question is how can you query hapi (from my interceptor) to retrieve user based on system/identifier
Joris Scharp (Aug 09 2021 at 12:29):
I'm wondering the same, in my case I want to lookup a Device
based on the OAuth azp
field to determine if a party is authorized for a request. Did you manage to find out yet @Marek Gocał ? Or perhaps someone else can help?
Joris Scharp (Aug 09 2021 at 12:42):
For now I just inject the Dao from the BaseJpaRestfulServer
; not sure if this is best practice though..
daoRegistry.getResourceDao(ResourceTypeEnum.DEVICE.getCode())
Marek Gocał (Aug 10 2021 at 19:13):
Didn't manage to solve my problem yet, but I will try with your solution!
Joris Scharp (Aug 10 2021 at 19:20):
Yeah works fine for me @Marek Gocał , there's a slight better way to extract the DAO (with generics) though. So inside ca.uhn.fhir.jpa.starter.JpaRestfulServer#initialize
:
...
final IFhirResourceDao<Device> deviceDao = daoRegistry.getResourceDao(Device.class);
registerInterceptor(new InjectResourceOriginInterceptor(deviceDao));
...
Last updated: Apr 12 2022 at 19:14 UTC