Class: Aurora::Client

Inherits:
Halcyon::Client::Base
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#appObject

Returns the value of attribute app.



29
30
31
# File 'lib/aurora/client.rb', line 29

def app
  @app
end

Class Method Details

.versionObject



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(options = {})
  user, pass = options[:username], options[:password]
  token = options[: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, permission, value)
  post("/user/#{user}/#{@app}/permit/#{permission}", :value => value)[:body]
end

#permit?(user, permission) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/aurora/client.rb', line 61

def permit?(user, permission)
  get("/user/#{user}/#{@app}/permit/#{permission}")[:body]
end