Class: Rack::OAuth2::Server::Issuer
- Inherits:
-
Object
- Object
- Rack::OAuth2::Server::Issuer
- Defined in:
- lib/rack/oauth2/models/issuer.rb
Overview
A third party that issues assertions tools.ietf.org/html/draft-ietf-oauth-assertions-01#section-5.1
Instance Attribute Summary collapse
-
#_id ⇒ Object
(also: #identifier)
readonly
The unique identifier of this Issuer.
-
#hmac_secret ⇒ Object
readonly
shared secret used for verifying HMAC signatures.
-
#notes ⇒ Object
readonly
notes about this Issuer.
-
#public_key ⇒ Object
readonly
public key used for verifying RSA signatures.
Class Method Summary collapse
- .collection ⇒ Object
-
.create(args) ⇒ Object
Create a new Issuer.
-
.from_identifier(identifier) ⇒ Object
returns the Issuer object for the given identifier.
Instance Method Summary collapse
Instance Attribute Details
#_id ⇒ Object (readonly) Also known as: identifier
The unique identifier of this Issuer. String or URI
35 36 37 |
# File 'lib/rack/oauth2/models/issuer.rb', line 35 def _id @_id end |
#hmac_secret ⇒ Object (readonly)
shared secret used for verifying HMAC signatures
38 39 40 |
# File 'lib/rack/oauth2/models/issuer.rb', line 38 def hmac_secret @hmac_secret end |
#notes ⇒ Object (readonly)
notes about this Issuer
42 43 44 |
# File 'lib/rack/oauth2/models/issuer.rb', line 42 def notes @notes end |
#public_key ⇒ Object (readonly)
public key used for verifying RSA signatures
40 41 42 |
# File 'lib/rack/oauth2/models/issuer.rb', line 40 def public_key @public_key end |
Class Method Details
.collection ⇒ Object
28 29 30 31 |
# File 'lib/rack/oauth2/models/issuer.rb', line 28 def collection prefix = Server.[:collection_prefix] Server.database["#{prefix}.issuers"] end |
.create(args) ⇒ Object
Create a new Issuer.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rack/oauth2/models/issuer.rb', line 15 def create(args) fields = {} [:hmac_secret, :public_key, :notes].each do |key| fields[key] = args[key] if args.has_key?(key) end fields[:created_at] = Time.now.to_i fields[:updated_at] = Time.now.to_i fields[:_id] = args[:identifier] collection.insert(fields, :safe=>true) Server.new_instance self, fields end |
.from_identifier(identifier) ⇒ Object
returns the Issuer object for the given identifier
10 11 12 |
# File 'lib/rack/oauth2/models/issuer.rb', line 10 def from_identifier(identifier) Server.new_instance self, collection.find_one({:_id=>identifier}) end |
Instance Method Details
#update(args) ⇒ Object
45 46 47 48 49 |
# File 'lib/rack/oauth2/models/issuer.rb', line 45 def update(args) fields = [:hmac_secret, :public_key, :notes].inject({}) {|h,k| v = args[k]; h[k] = v if v; h} self.class.collection.update({:_id => identifier }, {:$set => fields}) self.class.from_identifier(identifier) end |