Class: Verge::Server::Site
- Inherits:
-
Object
- Object
- Verge::Server::Site
- Includes:
- DataMapper::Resource
- Defined in:
- lib/verge/server/models.rb
Overview
Datastructure representing a site that will connect and authenticate against verge. If you’ve setup verge with just one generic site key none of your sites will need to specify who they are and should all share that common key.
Constant Summary collapse
- GENERIC_HOST =
Set a value that will be used to look up keys that are not associated with a particular site
"generic.hostname"
Class Method Summary collapse
-
.find_by_uri(uri) ⇒ Object
Searchs all the sites for ones that match the host EG: “verge.example.com/some/path?id=1” will match “verge.example.com”.
Instance Method Summary collapse
-
#sign(*args) ⇒ Object
Prepends this sites token to the string list and runs a digest over the new string.
-
#sign_token(token) ⇒ Object
Takes a token for a user and signs it creating a new hash.
Class Method Details
.find_by_uri(uri) ⇒ Object
Searchs all the sites for ones that match the host
EG:
"http://verge.example.com/some/path?id=1" will match
"verge.example.com"
142 143 144 145 |
# File 'lib/verge/server/models.rb', line 142 def self.find_by_uri(uri) return nil if uri.nil? Site.first(:host => uri[/^([A-Za-z\d]*\:\/\/){0,1}([^\/]*)/, 2]) end |
Instance Method Details
#sign(*args) ⇒ Object
Prepends this sites token to the string list and runs a digest over the new string.
129 130 131 |
# File 'lib/verge/server/models.rb', line 129 def sign(*args) Verge::Crypto.digest(signature, args.join) end |
#sign_token(token) ⇒ Object
Takes a token for a user and signs it creating a new hash
134 135 136 |
# File 'lib/verge/server/models.rb', line 134 def sign_token(token) signed_tokens.create(:value => sign(token.user.login, token.value), :token => token) end |