Class: Aurora::Client
- Inherits:
-
Halcyon::Client::Base
- Object
- Halcyon::Client::Base
- Aurora::Client
- Defined in:
- lib/aurora/client.rb
Overview
Aurora Client
The Aurora Client makes interfacing with the Aurora server very simple and easy, hiding away most of the communication details while still allowing for a great deal of control in creating requests for the server.
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
Class Method Summary collapse
Instance Method Summary collapse
-
#authenticate(options = {}) ⇒ Object
Performs an authentication action against the current Aurora server.
-
#initialize(uri, app) ⇒ Client
constructor
Initialies the Aurora client, expecting the Aurora server to connect to and the application to represent itself as to query permissions and such against.
- #permit!(user, permission, value) ⇒ Object
- #permit?(user, permission) ⇒ Boolean
Constructor Details
#initialize(uri, app) ⇒ Client
Initialies the Aurora client, expecting the Aurora server to connect to and the application to represent itself as to query permissions and such against. The App ID can also be used to configure default permissions for newly created user accounts (from fresh LDAP auths, for instance).
39 40 41 42 |
# File 'lib/aurora/client.rb', line 39 def initialize(uri, app) @app = app super uri end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
29 30 31 |
# File 'lib/aurora/client.rb', line 29 def app @app end |
Class Method Details
.version ⇒ Object
31 32 33 |
# File 'lib/aurora/client.rb', line 31 def self.version VERSION.join('.') end |
Instance Method Details
#authenticate(options = {}) ⇒ Object
Performs an authentication action against the current Aurora server.
Expects a Hash with either a :username
and :password
pair or a single :token
option. The server authentication method is called accordingly.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/aurora/client.rb', line 49 def authenticate( = {}) user, pass = [:username], [:password] token = [:token] if user && pass post("/user/auth/#{user}", :password => pass)[:body] rescue false elsif token get("/token/auth/#{token}") rescue false else false end end |
#permit!(user, permission, value) ⇒ Object
65 66 67 |
# File 'lib/aurora/client.rb', line 65 def permit!(user, , value) post("/user/#{user}/#{@app}/permit/#{permission}", :value => value)[:body] end |
#permit?(user, permission) ⇒ Boolean
61 62 63 |
# File 'lib/aurora/client.rb', line 61 def permit?(user, ) get("/user/#{user}/#{@app}/permit/#{permission}")[:body] end |