Class: Fb::Jwt::Auth::ServiceAccessToken
- Inherits:
-
Object
- Object
- Fb::Jwt::Auth::ServiceAccessToken
- Defined in:
- lib/fb/jwt/auth/service_access_token.rb
Instance Attribute Summary collapse
-
#encoded_private_key ⇒ Object
readonly
Returns the value of attribute encoded_private_key.
-
#issuer ⇒ Object
readonly
Returns the value of attribute issuer.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(subject: nil, issuer: nil) ⇒ ServiceAccessToken
constructor
A new instance of ServiceAccessToken.
Constructor Details
#initialize(subject: nil, issuer: nil) ⇒ ServiceAccessToken
Returns a new instance of ServiceAccessToken.
10 11 12 13 14 15 |
# File 'lib/fb/jwt/auth/service_access_token.rb', line 10 def initialize(subject: nil, issuer: nil) @subject = subject @encoded_private_key = Fb::Jwt::Auth.encoded_private_key @namespace = Fb::Jwt::Auth.namespace @issuer = issuer || Fb::Jwt::Auth.issuer end |
Instance Attribute Details
#encoded_private_key ⇒ Object (readonly)
Returns the value of attribute encoded_private_key.
5 6 7 |
# File 'lib/fb/jwt/auth/service_access_token.rb', line 5 def encoded_private_key @encoded_private_key end |
#issuer ⇒ Object (readonly)
Returns the value of attribute issuer.
5 6 7 |
# File 'lib/fb/jwt/auth/service_access_token.rb', line 5 def issuer @issuer end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
5 6 7 |
# File 'lib/fb/jwt/auth/service_access_token.rb', line 5 def namespace @namespace end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
5 6 7 |
# File 'lib/fb/jwt/auth/service_access_token.rb', line 5 def subject @subject end |
Instance Method Details
#generate ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fb/jwt/auth/service_access_token.rb', line 17 def generate return '' if encoded_private_key.blank? private_key = OpenSSL::PKey::RSA.new(encoded_private_key.chomp) JWT.encode( token, private_key, 'RS256' ) end |