Module: Proctoring::TokensHelper
- Included in:
- Api::V1::AuthenticationController, HundredMsServiceHelper
- Defined in:
- app/helpers/proctoring/tokens_helper.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.encode_authentication_token ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/helpers/proctoring/tokens_helper.rb', line 40 def self.encode_authentication_token now = Time.now exp = now + 10.minutes payload = { app_name: Proctoring.app_name, type: 'application', jti: SecureRandom.uuid, version: 2, iat: now.to_i, nbf: now.to_i, exp: exp.to_i } JWT.encode payload, Proctoring.hundred_ms_auth_secret, 'HS256' end |
Instance Method Details
#generate_authentication_token(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/helpers/proctoring/tokens_helper.rb', line 7 def generate_authentication_token(params) now = Time.now exp = now + 1.day payload = { access_key: Proctoring.hundred_ms_app_access_key, room_id: params[:room_id], user_id: params[:user_id], role: params[:role], type: 'app', jti: SecureRandom.uuid, version: 2, iat: now.to_i, nbf: now.to_i, exp: exp.to_i } JWT.encode(payload, Proctoring.hundred_ms_app_secret, 'HS256') end |
#generate_management_token ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/proctoring/tokens_helper.rb', line 25 def generate_management_token now = Time.now exp = now + 1.day payload = { access_key: Proctoring.hundred_ms_app_access_key, type: 'management', version: 2, jti: SecureRandom.uuid, iat: now.to_i, nbf: now.to_i, exp: exp.to_i } JWT.encode(payload, Proctoring.hundred_ms_app_secret, 'HS256') end |