Skip to content

Authentication not going when the endpoint is dispatcher #282

Open
@brunofrank

Description

@brunofrank

There's something happening here I don't know if it's the correct behavior because there's nothing at the docs about it.

I have the following:

# routes.rb
devise_for :users, path: 'auth', path_names: {
                                   sign_in: 'login',
                                   sign_out: 'logout',
                                   registration: 'signup'
                                 },
                                 controllers: {
                                   sessions: 'users/sessions'
                                 }

get '/auth/me', to: 'users#me'

# initializers/devise.rb

  config.jwt do |jwt|
    jwt.secret = ENV['DEVISE_JWT_SECRET_KEY']

    jwt.dispatch_requests = [
      ['POST', '/auth/login.json'],
      ['GET', '/auth/me']
    ]

    jwt.revocation_requests = [
      ['DELETE', '/auth/logout']
    ]
  end

Test request:

curl -i --header "Authorization: Bearer <TOKEN>" http://demo.lvh.me:3000/auth/me
HTTP/1.1 302 Found

If I remove the /auth/me from dispatchers it works.

The main ideia is, after my app logs in, it will hold the token, and everything it hits the /auth/me path it refreshes the token, everything works if a remove the /auth/me path from dispatch_requests, when I add back the me does not authenticate with the token anymore.

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions