fireproofsocks
This may be a dumb question, but I’m lookin at ueberauth, I’m unclear as to its purpose… the docs kinda miss the forest for the trees IMO. I’m going to truffle sniff through the links there but has anyone used it to verify a Google Sign In?
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
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
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
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
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
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
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
invacto
The uberauth library is a base which tries to help with all authentication methods that work with a request & callback for example OAuth2.
You generally dont use it alone but instead use a strategy on top of it (which is a different library) these strategies are more specific implementations like github, gitlab, google as you said and many more
Hope that helps
danschultzer
Yeah, it’s built on the same concept as OmniAuth, so you want to use the individual strategy libraries. Here’s the one for google: GitHub - ueberauth/ueberauth_google: Google OAuth2 Strategy for Überauth. · GitHub
Side note; I never really liked this approach, it feels like too much abstraction. I built Assent to have everything out-of-the-box to both conform the strategy flows, make each strategy integration as minimal as possible, and prevent breaking stuff whenever there’s any changes to the core logic: GitHub - pow-auth/assent: Multi-provider framework in Elixir · GitHub
fireproofsocks
Hmm… the more I look at this, the more I think this is really an unfortunately failure of documentation. Ueberauth looks like a great package, but the documentation doesn’t demonstrate the problems it solves. I suspect this failure is responsible for motivating the development of some other packages that cover some of the same ground. It’s always a bummer when the docs aren’t up to par with the code and people never get to take advantage of all the hard work that went into the code. If I can get this figured out, I’ll try to submit a PR for the docs.
pera
I had the same impression the first time I looked into this… sometimes it’s just easier to read the code
fireproofsocks
Yeah, @pera, I hear you.
So a couple things I don’t understand with the Ueberauth Google implementation (and for @danschultzer and the asset package)…
There are 3 config/ENV variables that these implementations rely on:
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETGOOGLE_REDIRECT_URIThe flow for both these implementations (so far as I understand it):
/auth/google./auth/googleredirects to the the Google Sign In page for configured client, e.g.https://accounts.google.com/signin/oauth/identifier?client_id=123http://localhost:4000/auth/google/callback?code=xxxxxyyyyzzz&scope=email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+openid&authuser=0&hd=mysite.com&prompt=consentAnd that’s where I can’t follow what it’s doing. Is the plug checking the supplied code in the GET request from Google to verify that it actually is from Google and properly signed? Because I assume there’s something there that’s preventing randos from making GET requests against that same endpoint and having it issue a session.
How I did my implementation of this was simpler (IMO). It required only 1 config: the
GOOGLE_CLIENT_ID. I used the Google Sign In button provided by Google – I just had to include their JS. The flow was this:https://accounts.google.com/signin/oauth/identifier?client_id=123page (identified by the Google Client ID).At that point, your JS has the JWT produced via the signup, and it can POST that value to any endpoint you define in your app, and then:
4. Your app would verify the signature of the JWT to make sure it hadn’t been tampered with – setting
GOOGLE_CLIENT_SECRETandGOOGLE_REDIRECT_URIwas not required.Why/how is Ueberauth verifying the OAuth response?
danschultzer
It’s OAuth 2.0 auth code flow in both cases. Normally the client returns an auth code via query params to the server, and the server exchanges the auth code for an access token using the
client secret. When you use the JS SDK it’s instead the client that handles this process. Instead of usingclient secretit’s done with PKCE, and the server will only have to validate the token signature.This might give you an idea how it works in JS: OpenId Connect Auth Code Flow + PKCE - OneLogin API
fireproofsocks
This PKCE link is helpful, thank you! Let me see if I have this straight… in the first case (e.g. the one used by Ueberauth), the server backend (e.g. Phoenix) ends up with a token which (after exchanging it) can be used to make further requests, whereas in the JS variant, the client ends up only with a JWT which vouches for the user and basically proves that the user is who they say they are (the client just has to verify the signature on the JWK to prove that it has not been tampered with).
I don’t recall having to define a client secret or code challenge, however… I’m also looking over Authorization Code Flow with Proof Key for Code Exchange (PKCE) - Auth0 Docs – but I don’t follow all the steps that it diagrams.
I’ve done Facebook OAuth setups – they work the same way as the Ueberauth example with a token sent to the redirect URL that has to be exchanged before it can be used to make calls against the Facebook API. Twitter uses (used?) OAuth1, but it was the same type of flow.
I’m not aware of other authorities that will cough up a JWT as a “by-product” of logging in, which the client can then verify.
fireproofsocks
@danschultzer - does Assent support the PKCE type logins?
danschultzer
Yeah, that’s about right, they are both access tokens, but the one fetched by the client is usually short lived.
It’s handled in the JS SDK, so the code challenge is generated by the client and the only information needed is the
client id.No, but it make sense that short lived access tokens fetched by the client can be used in the Assent callback flow to generate long lived access token and fetch userinfo. It’s something I got in the pipeline (in this case Facebook), but haven’t had time to deal with yet: Allow passing access token to callback · Issue #34 · pow-auth/assent · GitHub
Many providers have this PKCE option or similar to generate tokens on clients, it is a necessity with e.g. SPA that doesn’t rely on a backend. As you can see in the above issue, Facebook has a client side SDK as well (they also have a JS version if I recall correctly).