Middleware for ally


Hi, I am build an api by using Adonis, I am using ally for social authentication.

How to make a middleware to verify that my user is social authenticated before access certain routes?

1 Like


You need to understand the concept of Authentication and Social authentication first.

The authentication means that a user verifies their identity by telling who they are, now this identity can be verified in multiple ways.

  1. By giving their login username and password.
  2. Or by using a social account like Facebook, Google and so on.

Once the identity has been verified, you issue SOMETHING unique to that user, so that they don’t have to re-verify their identity everything. This SOMETHING is a session in traditional server side apps, or JWT/Any other token when writing API’s.

In conclusion, you never verify on every request that a user was socially authentication, instead you verify that they have a valid session or JWT token.

In short, I suggest clearing the fundamentals, before getting puzzled with tools

1 Like


Thank you very much, I will look into it