Module: AuthToken
- Defined in:
- lib/auth_token.rb
Class Method Summary collapse
-
.issue_token(payload = {}, exp = (Time.now + 86400), secret = nil, aud = nil) ⇒ Object
More information on jwt available at self-issued.info/docs/draft-ietf-oauth-json-web-token.html#rfc.section.4.1.6.
- .valid?(token, secret = nil) ⇒ Boolean
Class Method Details
.issue_token(payload = {}, exp = (Time.now + 86400), secret = nil, aud = nil) ⇒ Object
More information on jwt available at self-issued.info/docs/draft-ietf-oauth-json-web-token.html#rfc.section.4.1.6
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/auth_token.rb', line 7 def self.issue_token( payload = {}, exp = (Time.now + 86400), secret = nil, aud = nil ) config = Senkyoshi.configuration payload["iat"] = Time.now.to_i # issued at claim payload["exp"] = exp.to_i # Default expiration set to 24 hours. payload["aud"] = aud || config.scorm_shared_id JWT.encode( payload, secret || config.scorm_shared_auth, "HS512", ) end |
.valid?(token, secret = nil) ⇒ Boolean
24 25 26 27 |
# File 'lib/auth_token.rb', line 24 def self.valid?(token, secret = nil) config = Senkyoshi.configuration JWT.decode(token, secret || config.scorm_shared_auth) end |