aurora 0.0.1 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +150 -4
- data/bin/aurora +250 -0
- data/lib/aurora.rb +36 -1
- data/lib/aurora/client.rb +61 -12
- data/lib/aurora/migrations/001_create_users.rb +13 -0
- data/lib/aurora/migrations/002_create_tokens.rb +13 -0
- data/lib/aurora/server.rb +264 -16
- data/test/aurora/server_spec.rb +24 -0
- data/test/spec_helper.rb +20 -0
- metadata +37 -82
- data/History.txt +0 -4
- data/License.txt +0 -20
- data/Manifest.txt +0 -33
- data/README.txt +0 -56
- data/config/hoe.rb +0 -76
- data/config/requirements.rb +0 -17
- data/examples/basics.rb +0 -14
- data/lib/aurora/client/base.rb +0 -15
- data/lib/aurora/client/token.rb +0 -7
- data/lib/aurora/server/base.rb +0 -69
- data/lib/aurora/server/handler.rb +0 -54
- data/lib/aurora/server/server.rb +0 -7
- data/lib/aurora/server/token.rb +0 -34
- data/lib/aurora/version.rb +0 -9
- data/log/debug.log +0 -0
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -74
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/test/test_aurora.rb +0 -11
- data/test/test_helper.rb +0 -2
- data/website/index.html +0 -143
- data/website/index.txt +0 -77
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.rhtml +0 -48
data/Rakefile
CHANGED
@@ -1,4 +1,150 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib")))
|
2
|
+
|
3
|
+
%w(rubygems rake rake/clean rake/packagetask rake/gempackagetask rake/rdoctask rake/contrib/rubyforgepublisher fileutils pp).each{|dep|require dep}
|
4
|
+
|
5
|
+
include FileUtils
|
6
|
+
|
7
|
+
require 'lib/aurora'
|
8
|
+
|
9
|
+
project = {
|
10
|
+
:name => "aurora",
|
11
|
+
:version => Aurora.version,
|
12
|
+
:author => "Matt Todd",
|
13
|
+
:email => "chiology@gmail.com",
|
14
|
+
:description => "A Simple Authentication Server",
|
15
|
+
:homepath => 'http://aurora.rubyforge.org',
|
16
|
+
:bin_files => %w(aurora),
|
17
|
+
:rdoc_files => %w(lib),
|
18
|
+
:rdoc_opts => %w[
|
19
|
+
--all
|
20
|
+
--quiet
|
21
|
+
--op rdoc
|
22
|
+
--line-numbers
|
23
|
+
--inline-source
|
24
|
+
--title "Aurora\ Documentation"
|
25
|
+
--exclude "^(_darcs|test|pkg|.svn)/"
|
26
|
+
],
|
27
|
+
:dependencies => {
|
28
|
+
'halcyon' => '>=0.3.28'
|
29
|
+
},
|
30
|
+
:requirements => '',
|
31
|
+
:ruby_version_required => '>=1.8.6'
|
32
|
+
}
|
33
|
+
|
34
|
+
BASEDIR = File.expand_path(File.dirname(__FILE__))
|
35
|
+
|
36
|
+
spec = Gem::Specification.new do |s|
|
37
|
+
s.name = project[:name]
|
38
|
+
s.version = project[:version]
|
39
|
+
s.platform = Gem::Platform::RUBY
|
40
|
+
s.has_rdoc = true
|
41
|
+
s.extra_rdoc_files = project[:rdoc_files]
|
42
|
+
s.rdoc_options += project[:rdoc_opts]
|
43
|
+
s.summary = project[:description]
|
44
|
+
s.description = project[:description]
|
45
|
+
s.author = project[:author]
|
46
|
+
s.email = project[:email]
|
47
|
+
s.homepage = project[:homepath]
|
48
|
+
s.executables = project[:bin_files]
|
49
|
+
s.bindir = "bin"
|
50
|
+
s.require_path = "lib"
|
51
|
+
project[:dependencies].each{|dep|
|
52
|
+
s.add_dependency(dep[0], dep[1])
|
53
|
+
}
|
54
|
+
s.requirements << project[:requirements]
|
55
|
+
s.required_ruby_version = project[:ruby_version_required]
|
56
|
+
s.files = (project[:rdoc_files] + %w[Rakefile] + Dir["{test,lib}/**/*"]).uniq
|
57
|
+
end
|
58
|
+
|
59
|
+
Rake::GemPackageTask.new(spec) do |p|
|
60
|
+
p.need_zip = true
|
61
|
+
p.need_tar = true
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Package and Install aurora"
|
65
|
+
task :install do
|
66
|
+
name = "#{project[:name]}-#{project[:version]}.gem"
|
67
|
+
sh %{rake package}
|
68
|
+
sh %{sudo gem install pkg/#{name}}
|
69
|
+
end
|
70
|
+
|
71
|
+
desc "Uninstall the aurora gem"
|
72
|
+
task :uninstall => [:clean] do
|
73
|
+
sh %{sudo gem uninstall #{project[:name]}}
|
74
|
+
end
|
75
|
+
|
76
|
+
namespace 'spec' do
|
77
|
+
desc "generate spec"
|
78
|
+
task :gen do
|
79
|
+
sh "bacon -rlib/aurora -rtest/spec_helper test/**/* -s > test/SPEC"
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "run rspec"
|
83
|
+
task :run do
|
84
|
+
sh "bacon -r~/lib/bacon/output -rlib/aurora -rtest/spec_helper test/**/* -o CTestUnit"
|
85
|
+
end
|
86
|
+
|
87
|
+
desc "run rspec verbosely"
|
88
|
+
task :verb do
|
89
|
+
sh "bacon -r~/lib/bacon/output -rlib/aurora -rtest/spec_helper test/**/* -o CSpecDox"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
desc "Do predistribution stuff"
|
94
|
+
task :predist => [:chmod, :changelog, :manifest, :rdoc]
|
95
|
+
|
96
|
+
def manifest
|
97
|
+
require 'find'
|
98
|
+
paths = []
|
99
|
+
manifest = File.new('MANIFEST', 'w+')
|
100
|
+
Find.find('.') do |path|
|
101
|
+
path.gsub!(/\A\.\//, '')
|
102
|
+
next if path =~ /(\.svn|doc|pkg|^\.|MANIFEST)/
|
103
|
+
paths << path
|
104
|
+
end
|
105
|
+
paths.sort.each do |path|
|
106
|
+
manifest.puts path
|
107
|
+
end
|
108
|
+
manifest.close
|
109
|
+
end
|
110
|
+
|
111
|
+
desc "Make binaries executable"
|
112
|
+
task :chmod do
|
113
|
+
Dir["bin/*"].each { |binary| File.chmod(0775, binary) }
|
114
|
+
Dir["test/cgi/test*"].each { |binary| File.chmod(0775, binary) }
|
115
|
+
end
|
116
|
+
|
117
|
+
desc "Generate a MANIFEST"
|
118
|
+
task :manifest do
|
119
|
+
manifest
|
120
|
+
end
|
121
|
+
|
122
|
+
desc "Generate a CHANGELOG"
|
123
|
+
task :changelog do
|
124
|
+
sh "svn log > CHANGELOG"
|
125
|
+
end
|
126
|
+
|
127
|
+
desc "Generate RDoc documentation"
|
128
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
129
|
+
rdoc.options << '--line-numbers' << '--inline-source' <<
|
130
|
+
'--main' << 'README' <<
|
131
|
+
'--title' << 'Aurora Documentation' <<
|
132
|
+
'--charset' << 'utf-8'
|
133
|
+
rdoc.rdoc_dir = "doc"
|
134
|
+
rdoc.rdoc_files.include 'README'
|
135
|
+
rdoc.rdoc_files.include('lib/aurora.rb')
|
136
|
+
rdoc.rdoc_files.include('lib/aurora/*.rb')
|
137
|
+
rdoc.rdoc_files.include('lib/aurora/*/*.rb')
|
138
|
+
end
|
139
|
+
|
140
|
+
task :pushsite => [:rdoc] do
|
141
|
+
sh "rsync -avz doc/ mtodd@aurora.rubyforge.org:/var/www/gforge-projects/aurora/doc/"
|
142
|
+
sh "rsync -avz site/ mtodd@aurora.rubyforge.org:/var/www/gforge-projects/aurora/"
|
143
|
+
end
|
144
|
+
|
145
|
+
desc "find . -name \"*.rb\" | xargs wc -l | grep total"
|
146
|
+
task :loc do
|
147
|
+
sh "find . -name \"*.rb\" | xargs wc -l | grep total"
|
148
|
+
end
|
149
|
+
|
150
|
+
task :default => Rake::Task['spec:run']
|
data/bin/aurora
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
#!/usr/bin/env ruby -KU
|
2
|
+
#--
|
3
|
+
# Created by Matt Todd on 2008-01-13.
|
4
|
+
# Copyright (c) 2007. All rights reserved.
|
5
|
+
#++
|
6
|
+
|
7
|
+
$:.unshift(File.join(File.dirname(__FILE__),'lib'))
|
8
|
+
|
9
|
+
#--
|
10
|
+
# dependencies
|
11
|
+
#++
|
12
|
+
|
13
|
+
%w(rubygems halcyon/server aurora/server optparse).each{|dep|require dep}
|
14
|
+
|
15
|
+
#--
|
16
|
+
# default options
|
17
|
+
#++
|
18
|
+
|
19
|
+
$debug = false
|
20
|
+
$test = false
|
21
|
+
options = Halcyon::Server::DEFAULT_OPTIONS
|
22
|
+
|
23
|
+
#--
|
24
|
+
# parse options
|
25
|
+
#++
|
26
|
+
|
27
|
+
opts = OptionParser.new("", 24, ' ') do |opts|
|
28
|
+
opts.banner << "Aurora Simple Authentication Server\n"
|
29
|
+
opts.banner << "http://aurora.rubyforge.org/\n"
|
30
|
+
opts.banner << "\n"
|
31
|
+
opts.banner << "Usage: aurora [-c config/file.yml] [options] appname\n"
|
32
|
+
opts.banner << "\n"
|
33
|
+
opts.banner << "Put -c or --config first otherwise it will overwrite higher precedence options."
|
34
|
+
|
35
|
+
opts.separator ""
|
36
|
+
opts.separator "Ruby options:"
|
37
|
+
|
38
|
+
opts.on("-d", "--debug", "set debugging flag (set $debug to true)") { $debug = true }
|
39
|
+
opts.on("-D", "--Debug", "enable verbose debugging (set $debug and $DEBUG to true)") { $debug = true; $DEBUG = true }
|
40
|
+
opts.on("-w", "--warn", "turn warnings on for your script") { $-w = true }
|
41
|
+
|
42
|
+
opts.on("-I", "--include PATH", "specify $LOAD_PATH (multiples OK)") do |path|
|
43
|
+
$:.unshift(*path.split(":"))
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on("-r", "--require LIBRARY", "require the library, before executing your script") do |library|
|
47
|
+
require library
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.separator ""
|
51
|
+
opts.separator "Config file:"
|
52
|
+
|
53
|
+
opts.on("-c", "--config PATH", "load configuration (YAML) from PATH") do |conf_file|
|
54
|
+
if File.exist?(conf_file)
|
55
|
+
require 'yaml'
|
56
|
+
|
57
|
+
# load the config file
|
58
|
+
begin
|
59
|
+
conf = YAML.load_file(conf_file)
|
60
|
+
rescue Errno::EACCES => e
|
61
|
+
abort("Can't access #{conf_file}, try 'sudo #{$0}'")
|
62
|
+
end
|
63
|
+
|
64
|
+
# store config file path so SIGHUP and SIGUSR2 will reload the config in case it changes
|
65
|
+
options[:config_file] = conf_file
|
66
|
+
|
67
|
+
# parse config
|
68
|
+
case conf
|
69
|
+
when String
|
70
|
+
# config file given was just the commandline options
|
71
|
+
ARGV.replace(conf.split)
|
72
|
+
opts.parse! ARGV
|
73
|
+
when Hash
|
74
|
+
conf.symbolize_keys!
|
75
|
+
options = options.merge(conf)
|
76
|
+
when Array
|
77
|
+
# TODO (MT) support multiple servers (or at least specifying which
|
78
|
+
# server's configuration to load)
|
79
|
+
warn "Your configuration file is setup for multiple servers. This is not a supported feature yet."
|
80
|
+
warn "However, we've pulled the first server entry as this server's configuration."
|
81
|
+
# an array of server configurations
|
82
|
+
# default to the first entry since multiple server configurations isn't
|
83
|
+
# precisely worked out yet.
|
84
|
+
options = options.merge(conf[0])
|
85
|
+
else
|
86
|
+
abort "Config file in an unsupported format. Config files must be YAML or the commandline flags"
|
87
|
+
end
|
88
|
+
else
|
89
|
+
abort "Config file failed to load. #{conf_file} was not found. Correct the path and try again."
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
opts.separator ""
|
94
|
+
opts.separator "Options:"
|
95
|
+
|
96
|
+
opts.on("-b", "--background", "process in the background (daemonize)") {$daemonize = true}
|
97
|
+
|
98
|
+
opts.on("-s", "--server SERVER", "serve using SERVER (default: #{options[:server]})") do |serv|
|
99
|
+
options[:server] = serv
|
100
|
+
end
|
101
|
+
|
102
|
+
opts.on("-o", "--host HOST", "listen on HOST (default: #{options[:host]})") do |host|
|
103
|
+
options[:host] = host
|
104
|
+
end
|
105
|
+
|
106
|
+
opts.on("-p", "--port PORT", "use PORT (default: #{options[:port]})") do |port|
|
107
|
+
options[:port] = port
|
108
|
+
end
|
109
|
+
|
110
|
+
opts.on("-l", "--logfile PATH", "log access to PATH (default: #{options[:log_file]})") do |log_file|
|
111
|
+
options[:log_file] = log_file
|
112
|
+
end
|
113
|
+
|
114
|
+
opts.on("-L", "--loglevel LEVEL", "log level (default: #{options[:log_level]})") do |log_file|
|
115
|
+
options[:log_level] = log_file
|
116
|
+
end
|
117
|
+
|
118
|
+
opts.on("-P", "--pidfile PATH", "save PID to PATH (default: #{options[:pid_file]})") do |log_file|
|
119
|
+
options[:pid_file] = log_file
|
120
|
+
end
|
121
|
+
|
122
|
+
opts.on("-e", "--env ENVIRONMENT", "use ENVIRONMENT for defaults (default: #{options[:environment]})") do |env|
|
123
|
+
options[:environment] = env
|
124
|
+
end
|
125
|
+
|
126
|
+
opts.separator ""
|
127
|
+
|
128
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
129
|
+
puts opts
|
130
|
+
exit
|
131
|
+
end
|
132
|
+
|
133
|
+
opts.on_tail("-v", "--version", "Show version") do
|
134
|
+
puts "Aurora v#{Aurora.version}"
|
135
|
+
exit
|
136
|
+
end
|
137
|
+
|
138
|
+
begin
|
139
|
+
opts.parse! ARGV
|
140
|
+
rescue OptionParser::InvalidOption => e
|
141
|
+
abort "You used an unsupported option. Try: aurora -h"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
abort "Aurora needs an authenticating app to run. Try: aurora -h" if ARGV.empty?
|
146
|
+
options[:app] = ARGV.shift
|
147
|
+
|
148
|
+
#--
|
149
|
+
# load app
|
150
|
+
#++
|
151
|
+
|
152
|
+
begin
|
153
|
+
# go ahead and try to require since it could be a gem
|
154
|
+
require options[:app]
|
155
|
+
rescue
|
156
|
+
if !File.exists?("#{options[:app]}.rb")
|
157
|
+
abort "Aurora did not find the app #{options[:app]}. Check your path and try again."
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
begin
|
162
|
+
appname = File.basename(options[:app]).capitalize.gsub(/_([a-z])/){|m|m[1].chr.capitalize}
|
163
|
+
app = Object.const_get(appname)
|
164
|
+
rescue NameError => e
|
165
|
+
abort "Unable to load #{appname}. Please ensure your server is so named."
|
166
|
+
end
|
167
|
+
|
168
|
+
#--
|
169
|
+
# prepare server
|
170
|
+
#++
|
171
|
+
begin
|
172
|
+
server = Rack::Handler.const_get(options[:server].capitalize)
|
173
|
+
rescue NameError
|
174
|
+
servers = {
|
175
|
+
'cgi' => 'CGI',
|
176
|
+
'fastcgi' => 'FastCGI',
|
177
|
+
'lsws' => 'LSWS',
|
178
|
+
'mongrel' => 'Mongrel',
|
179
|
+
'webrick' => 'WEBrick'
|
180
|
+
}
|
181
|
+
abort "Unsupported server (missing Rack Handler). Did you mean to specify #{options[:server]}?" unless servers.key? options[:server]
|
182
|
+
server = Rack::Handler.const_get(servers[options[:server]])
|
183
|
+
end
|
184
|
+
|
185
|
+
#--
|
186
|
+
# daemonization
|
187
|
+
#++
|
188
|
+
|
189
|
+
if $daemonize
|
190
|
+
fork do
|
191
|
+
require 'daemons'
|
192
|
+
Daemonize.daemonize
|
193
|
+
|
194
|
+
#--
|
195
|
+
# prepare app environment
|
196
|
+
#++
|
197
|
+
|
198
|
+
case options[:environment]
|
199
|
+
when "development"
|
200
|
+
app = Rack::Builder.new {
|
201
|
+
use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
|
202
|
+
use Rack::ShowExceptions
|
203
|
+
use Rack::Reloader
|
204
|
+
use Rack::Lint
|
205
|
+
run app.new(options)
|
206
|
+
}.to_app
|
207
|
+
when "deployment"
|
208
|
+
app = Rack::Builder.new {
|
209
|
+
use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
|
210
|
+
run app.new(options)
|
211
|
+
}.to_app
|
212
|
+
else
|
213
|
+
app = app.new(options)
|
214
|
+
end
|
215
|
+
|
216
|
+
#--
|
217
|
+
# start server
|
218
|
+
#++
|
219
|
+
|
220
|
+
server.run app, :Port => options[:port]
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
#--
|
225
|
+
# prepare app environment
|
226
|
+
#++
|
227
|
+
|
228
|
+
case options[:environment]
|
229
|
+
when "development"
|
230
|
+
app = Rack::Builder.new {
|
231
|
+
use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
|
232
|
+
use Rack::ShowExceptions
|
233
|
+
use Rack::Reloader
|
234
|
+
use Rack::Lint
|
235
|
+
run app.new(options)
|
236
|
+
}.to_app
|
237
|
+
when "deployment"
|
238
|
+
app = Rack::Builder.new {
|
239
|
+
use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
|
240
|
+
run app.new(options)
|
241
|
+
}.to_app
|
242
|
+
else
|
243
|
+
app = app.new(options)
|
244
|
+
end
|
245
|
+
|
246
|
+
#--
|
247
|
+
# start server
|
248
|
+
#++
|
249
|
+
|
250
|
+
server.run app, :Port => options[:port] unless $daemonize
|
data/lib/aurora.rb
CHANGED
@@ -1,5 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#--
|
3
|
+
# Created by Matt Todd on 2007-12-14.
|
4
|
+
# Copyright (c) 2007. All rights reserved.
|
5
|
+
#++
|
6
|
+
|
1
7
|
$:.unshift File.dirname(__FILE__)
|
2
8
|
|
9
|
+
#--
|
10
|
+
# module
|
11
|
+
#++
|
12
|
+
|
3
13
|
module Aurora
|
4
|
-
|
14
|
+
VERSION = [0,1,10]
|
15
|
+
def self.version
|
16
|
+
VERSION.join('.')
|
17
|
+
end
|
18
|
+
|
19
|
+
# = Introduction
|
20
|
+
#
|
21
|
+
# Aurora is a simple authentication server. Built on Halcyon, it is a JSON
|
22
|
+
# Web Server Framework intended to be used for fast, small data transactions,
|
23
|
+
# like for AJAX-intensive sites or for special services like authentication
|
24
|
+
# centralized for numerous web apps in the same cluster.
|
25
|
+
#
|
26
|
+
# The possibilities are pretty limitless: the goal of Aurora was simply to be
|
27
|
+
# lightweight, fast, simple to implement and use, and able to be extended.
|
28
|
+
#
|
29
|
+
# == Usage
|
30
|
+
#
|
31
|
+
# For documentation on using Aurora, check out the Aurora::Server and
|
32
|
+
# Aurora::Client classes which contain much more usage documentation.
|
33
|
+
def introduction
|
34
|
+
abort "READ THE DAMNED RDOCS!"
|
35
|
+
end
|
36
|
+
|
37
|
+
autoload :Server, 'aurora/server'
|
38
|
+
autoload :Client, 'aurora/client'
|
39
|
+
|
5
40
|
end
|
data/lib/aurora/client.rb
CHANGED
@@ -1,22 +1,71 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
#!/usr/bin/env ruby
|
3
2
|
#--
|
4
|
-
#
|
5
|
-
#
|
3
|
+
# Created by Matt Todd on 2008-01-11.
|
4
|
+
# Copyright (c) 2008. All rights reserved.
|
6
5
|
#++
|
7
6
|
|
7
|
+
$:.unshift File.dirname(File.join('..', __FILE__))
|
8
|
+
$:.unshift File.dirname(__FILE__)
|
9
|
+
|
8
10
|
#--
|
9
|
-
#
|
11
|
+
# dependencies
|
10
12
|
#++
|
11
13
|
|
12
|
-
require
|
13
|
-
require 'uri'
|
14
|
-
require 'json'
|
15
|
-
require 'digest/md5'
|
14
|
+
%w(rubygems halcyon/client).each {|dep|require dep}
|
16
15
|
|
17
16
|
#--
|
18
|
-
#
|
17
|
+
# module
|
19
18
|
#++
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
module Aurora
|
21
|
+
|
22
|
+
# = Aurora Client
|
23
|
+
#
|
24
|
+
# The Aurora Client makes interfacing with the Aurora server very simple and
|
25
|
+
# easy, hiding away most of the communication details while still allowing
|
26
|
+
# for a great deal of control in creating requests for the server.
|
27
|
+
class Client < Halcyon::Client::Base
|
28
|
+
|
29
|
+
attr_accessor :app
|
30
|
+
|
31
|
+
def self.version
|
32
|
+
VERSION.join('.')
|
33
|
+
end
|
34
|
+
|
35
|
+
# Initialies the Aurora client, expecting the Aurora server to connect to
|
36
|
+
# and the application to represent itself as to query permissions and such
|
37
|
+
# against. The App ID can also be used to configure default permissions for
|
38
|
+
# newly created user accounts (from fresh LDAP auths, for instance).
|
39
|
+
def initialize(uri, app)
|
40
|
+
@app = app
|
41
|
+
super uri
|
42
|
+
end
|
43
|
+
|
44
|
+
# Performs an authentication action against the current Aurora server.
|
45
|
+
#
|
46
|
+
# Expects a Hash with either a <tt>:username</tt> and <tt>:password</tt>
|
47
|
+
# pair or a single <tt>:token</tt> option. The server authentication
|
48
|
+
# method is called accordingly.
|
49
|
+
def authenticate(options = {})
|
50
|
+
user, pass = options[:username], options[:password]
|
51
|
+
token = options[:token]
|
52
|
+
if user && pass
|
53
|
+
post("/user/auth/#{user}", :password => pass)[:body] rescue false
|
54
|
+
elsif token
|
55
|
+
get("/token/auth/#{token}") rescue false
|
56
|
+
else
|
57
|
+
false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def permit?(user, permission)
|
62
|
+
get("/user/#{user}/#{@app}/permit/#{permission}")[:body]
|
63
|
+
end
|
64
|
+
|
65
|
+
def permit!(user, permission, value)
|
66
|
+
post("/user/#{user}/#{@app}/permit/#{permission}", :value => value)[:body]
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|