Auth API Calls

Let me come again with my Data Model to show some isolation I’d planned for Auth and Data.

Now, for the Cover Story,

Image result for hasura auth

User Sessions

Any 2 HTTP calls are completely berserk, they are independent. It’s the HTTP header/ the cookie that identifies 2 calls with the same user, from IMAD :).

Recall from the last story that, client-end of things are just to make HTTP calls and the API gateway does the authentication and upstream forwarding.

It’s surprising that even the Auth Service is a Postgres Schema, with the same query structure and form.

If you were to make a guess that my request & response POJO objects are ready, then I wouldn’t deny :)

Register an User

I pass username, password and mobile counting for a testament.
The user is assigned an id and a role. Though the auth_token is purely granted on login.
Voila, Hasura Auth Console pomps up a new record!

Log the User In

It’s really cool on how Hasura manage multi-sessions for an user across devices. I’ve personally noticed this feature.

Just look out for my active sessions. I’ve got 3 sessions on different devices.

Maybe, they map the user_id inside a Cookie object to point to a list of user_tokens?

There you go is a login request. A simple one.
An auth_token is generated and from hereon, I attach it while making privilege requests as an user.

Log the user out

A GET request with an authentication header bearing the auth_token of the logged in user.
A Typical logout response

Concluding Note

This is kind of how Hasura manage users in your project’s console.

I’ve briefly written about Postman collections and request grouping in the prequel blog. Find my Postman Collection for Auth APIs here.

Watch out for the next story :)

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade