Class: IapAuthenticator::JWS
- Inherits:
-
Object
- Object
- IapAuthenticator::JWS
- Defined in:
- lib/iap_authenticator/jws.rb
Constant Summary collapse
- ALGORITHM =
'RS256'
Instance Method Summary collapse
- #assertion ⇒ Object
-
#initialize(private_key, refresh_time_seconds, iss, target_audience) ⇒ JWS
constructor
A new instance of JWS.
Constructor Details
#initialize(private_key, refresh_time_seconds, iss, target_audience) ⇒ JWS
Returns a new instance of JWS.
5 6 7 8 9 10 11 |
# File 'lib/iap_authenticator/jws.rb', line 5 def initialize(private_key, refresh_time_seconds, iss, target_audience) @private_key = private_key @refresh_time_seconds = refresh_time_seconds @iss = iss @aud = IapAuthenticator::Token::TokenURI @target_audience = target_audience end |
Instance Method Details
#assertion ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/iap_authenticator/jws.rb', line 13 def assertion exp = Time.now.to_i + @refresh_time_seconds iat = Time.now.to_i payload = { iss: @iss, aud: @aud, exp: exp, iat: iat, target_audience: @target_audience } begin token = JWT.encode payload, @private_key, ALGORITHM rescue raise "Unable to create JWT" end return token end |