Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication not going when the endpoint is dispatcher #282

Open
brunofrank opened this issue Feb 24, 2025 · 0 comments
Open

Authentication not going when the endpoint is dispatcher #282

brunofrank opened this issue Feb 24, 2025 · 0 comments

Comments

@brunofrank
Copy link

brunofrank commented Feb 24, 2025

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant