Sha256: 551cd08954fe4ff9232facfd884d8261b0e88b99c964e0324a866d49a2cb0e47
Contents?: true
Size: 816 Bytes
Versions: 1
Compression:
Stored size: 816 Bytes
Contents
require 'jwt' module QuizApiClient::Services HASHING_ALGORITHM = 'HS512'.freeze class JwtService attr_reader :host, :jwt_secret, :protocol def initialize(jwt_secret:, host:, protocol: 'https') @host = host @jwt_secret = jwt_secret @protocol = protocol end def grant_permission(scope:, exp: nil, resource_id: nil) payload = { host: host, scope: scope, exp: exp || Time.now.utc.to_i + 60, # FIXME: This is currently required on quiz_web user: { full_name: 'Fake Full Name', given_name: 'Fake', email: 'quizzes+fake@instructure.com', id: 1 } } payload[:resource_id] = resource_id if resource_id JWT.encode(payload, jwt_secret, HASHING_ALGORITHM) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quiz_api_client-0.1.1 | lib/quiz_api_client/services/jwt_service.rb |