Constraints in Routes

Does the conn object available at that moment? Where I suppose session data can be accessed?

This is exactly what I wanted to avoid.

In fact on my rails project I’m actually doing scoping but only for the controllers and not for the path.

constraints lambda { |req| req.session[:user_type] == 'Admin' } do
  scope module: 'admin' do
    get  '/dashboard', to: 'admin_dashboard#show', as: 'dashboard'
    ...
  end
end

constraints lambda { |req| req.session[:user_type] == 'User' } do
  scope module: 'employee' do
    get  '/dashboard', to: 'user_dashboard#show', as: 'dashboard'
    ...
  end
end

Having the exact same path for the resources really simplify the whole. And then all the actions for a specific kind of user can perform only its related actions defined in its controller.
In my use-cases I had 6 types of users with some other resources. And I have several combinations of what a kind of user can do (view/edit/delete) to other users and other resources.
Trust me, filtering right at the route level simplified so much the whole codebase and everything worked very well without using any kind of authorization library.

So in conclusion, is it simply impossible to have constraints at the route level with Plug/Phoenix?

In the meantime I came across the following SO question where the OP asked something similar about constraint based routes. Unfortunately, there isn’t any solution in his question..