Zero Trust User Permissions
Hey yall,
I have a Vue app that I expect max 10 users to use internally. I have two groups of users that I want to use this app. One group will have certain permissions within the app and the other group will not.
This app is hosted on Cloudflare pages with Zero trust currently.
Is there a way to communicate to the Vue app that certain emails or users (maybe with a worker?) have signed into using Zero trust so I can handle the the permissions that user should see on the Vue app?
3 Replies
Figured out a solution:
Created a worker that works with that Cloudflare page specifically (Click on worker, Go to Settings, Go to Triggers, Add Route).
Then I added the javascript seen above ^
This creates a new header on the request, and I can search for that value in my Vue application to display the different permissions.
Very nice! only bit I think you're missing is actually verifying the JWT: https://developers.cloudflare.com/cloudflare-one/identity/authorization-cookie/validating-json/ and not just trusting whatever came through. There has been exploits in the past where CF Access was skipped/issues like that, I'm sure CF has taken those more seriously since then but still a potential worry/edge case that may be worth covering if you're using it to assign admin status
Cloudflare Docs
Validate JWTs | Cloudflare Zero Trust docs
When Cloudflare sends a request to your origin, the request will include an application token as a Cf-Access-Jwt-Assertion request header and as a CF_Authorization cookie.
Oh thank you very much for this information @Chaika ! I will have to look into this.