Tag: jwt

无法自动加载常量JWTBlacklist,预期/home/sourabh/dev/celebration/app/models/jwt_blacklist.rb来定义它(LoadError)

我的user.rb模型包含: class User < ApplicationRecord devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable, :lockable, :timeoutable, :omniauthable, :jwt_authenticatable, jwt_revocation_strategy: JWTBlacklist def send_devise_notification(notification, *args) devise_mailer.send(notification, self, *args).deliver_later end end 我正在使用devise-jwt gem来登录我的rails api。 我的JWTBlacklist.rb模型包含: class JwtBlacklist < ApplicationRecord include Devise::JWT::RevocationStrategies::Blacklist self.table_name = 'jwt_blacklist' end

使用自定义令牌的Firebase身份validation

我有一个firebase项目,我试图从我的rails服务器进行身份validation,创建一个自定义令牌与库ruby-jwt,就像在文档上说的那样,但我一直得到同样的错误: auth / invalid-custom-token,自定义标记格式不正确。 请查看文档。 credentials.json来自我在谷歌控制台中创建的服务帐户,uid从前端发送到api。 def generate_auth_token(uid) now_seconds = Time.now.to_i credentials = JSON.parse(File.read(“credentials.json”)) private_key = OpenSSL::PKey::RSA.new credentials[“private_key”] payload = { :iss => credentials[“client_email”], :sub => credentials[“client_email”], :aud => ‘https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit’, :iat => now_seconds, :exp => now_seconds+(60*60), # Maximum expiration time is one hour :uid => uid.to_s, :claims => {:premium_account => true} } JWT.encode(payload, private_key, ‘RS256’) […]