brunoripa
Hi,
I am using ueberauth/Guardian to authenticate users against google. It works, but I have a problem with keys rotations that google executes: ueberuath makes the challenge phase, and guardian receives the token and verifies it, extrapolating claims etc etc
My problem is that Google rotates the keys (which are here: https://www.googleapis.com/oauth2/v3/certs) and I don’t understand how to deal with such rotation. There’s no info on which one of the two to use. Also, reading here:
it states:
These keys are regularly rotated; examine the
Cache-Controlheader in the response to determine when you should retrieve them again.
but does not tell anything more.
How should I handle this key rotation ? Which key should I use in what case ?
Thanks !
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security











Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
OvermindDL1
OAuth2 gives access tokens to access user data, they have an expiration (Cache-Control) at which point the oauth2 server should be contacted again to update it or so (or if the user logged out of the oauth2 server then you’ll log them out of your system now too). Guardian I don’t think has anything to do with this whatsoever? Ueberauth just does the initial auth, it is up to ‘you’ to do it again later if needed.
tangui
You have to try validating signature against every suitable key. A suitable key is a key whose:
"use"member is not set or is set to"sig", and"key_ops"member is not set or contains"verify", and"alg"is not set or set to the OIDC client’s registered"id_token_signed_response_alg"if set (or the default"RS256"otherwise)I’ve developed libs (JWKSURIUpdater and JWKUtils) for personal projects that you could be interested in.
brunoripa
I think I got the point. In the first part of the token [*], we have a bunch of information:
The
kidinfo is the one that gives us the chance to recognise which key has been used to generate the token you have received, and so which one to use to verify it.So, what I have done, I have created a custom secret fetcher that applies this logic, and everything works. I am using it like this:
MyApp.GoogleGuardian.decode_and_verify(token, %{}, secret: SecretsFetcher.get(token))The only feeling I have, is that maybe there is a way to implement this in a more Guardian-designed way; but I am struggling to find some real examples of this.
[*] the token is made of 3 parts, separated by a
.; the first one is the one that contains the info (and it’s B64 encoded).brunoripa
OAuth2 is made by two phases, with the first one being the “challenge” one, which is basically when you authorize the application after being redirected to the SSO implementation you are using (Google, in my case).
After this, ueberauth kingdom ends, and you have to handle the token. Guardian kicks in, but my question was about the multiple keys were to be used; this was the smoky part to me, sorry if I have not been very clear.
tangui
Indeed if a
"kid"is present, you shall use it! With JOSE you can useJOSE.JWS.peek_protected/1to retrieve the header.