This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.middleware.insert_before 0, Rack::Cors do | |
allow do | |
origins '*' | |
resource '*', headers: :any,expose: ['access-token', 'expiry', 'token-type', 'uid', 'client', 'Authorization'], | |
methods: [:get, :post, :options, :put, :delete] | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
devise_for :users, | |
path: '', | |
path_names: { | |
sign_in: 'login', | |
sign_out: 'logout', | |
registration: 'signup' | |
}, | |
controllers: { | |
sessions: 'sessions', | |
registrations: 'registrations' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JWTBlacklist < ApplicationRecord | |
include Devise::JWT::RevocationStrategies::Blacklist | |
self.table_name = 'jwt_blacklist' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateJwtBlacklist < ActiveRecord::Migration[5.0] | |
def change | |
create_table :jwt_blacklist do |t| | |
t.string :jti, null: false | |
end | |
add_index :jwt_blacklist, :jti | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ApplicationRecord | |
devise :database_authenticatable, | |
:jwt_authenticatable, | |
jwt_revocation_strategy: JWTBlacklist | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#..... | |
gem 'devise-jwt' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.jwt do |jwt| | |
jwt.secret = ENV['DEVISE_JWT_SECRET_KEY'] | |
jwt.dispatch_requests = [ | |
['POST', %r{^/login$}] | |
] | |
jwt.revocation_requests = [ | |
['DELETE', %r{^/logout$}] | |
] | |
jwt.expiration_time = 1.day.to_i | |
end |