aurora 0.0.1 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- 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/History.txt
DELETED
data/License.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2007 FIXME full name
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
License.txt
|
3
|
-
Manifest.txt
|
4
|
-
README.txt
|
5
|
-
Rakefile
|
6
|
-
config/hoe.rb
|
7
|
-
config/requirements.rb
|
8
|
-
examples/basics.rb
|
9
|
-
lib/aurora.rb
|
10
|
-
lib/aurora/client.rb
|
11
|
-
lib/aurora/client/base.rb
|
12
|
-
lib/aurora/client/token.rb
|
13
|
-
lib/aurora/server.rb
|
14
|
-
lib/aurora/server/base.rb
|
15
|
-
lib/aurora/server/handler.rb
|
16
|
-
lib/aurora/server/server.rb
|
17
|
-
lib/aurora/server/token.rb
|
18
|
-
lib/aurora/version.rb
|
19
|
-
log/debug.log
|
20
|
-
script/destroy
|
21
|
-
script/generate
|
22
|
-
script/txt2html
|
23
|
-
setup.rb
|
24
|
-
tasks/deployment.rake
|
25
|
-
tasks/environment.rake
|
26
|
-
tasks/website.rake
|
27
|
-
test/test_aurora.rb
|
28
|
-
test/test_helper.rb
|
29
|
-
website/index.html
|
30
|
-
website/index.txt
|
31
|
-
website/javascripts/rounded_corners_lite.inc.js
|
32
|
-
website/stylesheets/screen.css
|
33
|
-
website/template.rhtml
|
data/README.txt
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
= Aurora Simple Authentication Server
|
2
|
-
|
3
|
-
A small scale authentication server to provide multiple applications one point
|
4
|
-
of contact for authentication against LDAP et al data stores. The system will
|
5
|
-
respond with a temporary Authenticated Token to be used for the session. There
|
6
|
-
will also be a client-side library for use in Ruby available.
|
7
|
-
|
8
|
-
The authentication server will also have a component for user management
|
9
|
-
including permissions and access management.
|
10
|
-
|
11
|
-
== Installation
|
12
|
-
|
13
|
-
$ sudo gem install aurora
|
14
|
-
|
15
|
-
== Basics
|
16
|
-
|
17
|
-
An Aurora server is created on a specific port which listens diligently for all
|
18
|
-
requests and are routed accordingly. The most basic part of an Aurora server is
|
19
|
-
the @authenticate@ block. This passes the username and password to pass auth-
|
20
|
-
entication with and will return either a new Token for future authentication
|
21
|
-
requests or false. (NOTE: These details could change.)
|
22
|
-
|
23
|
-
Essentially what you have to do is set up hooks for the server to call when a
|
24
|
-
particular action is requested, starting with @authenticate@ and then moving
|
25
|
-
on to more custom functionality.
|
26
|
-
|
27
|
-
Because the server is not designed with any actual authentication checks, it
|
28
|
-
is totally up to the implementer to authenticate users, be it through an LDAP
|
29
|
-
data store or a MySQL database. This provides a great deal of flexibility, but
|
30
|
-
a good deal of burden and responsibility. Aurora just makes it possible to
|
31
|
-
centralize your authentication outside of your applications (though, with a
|
32
|
-
little creativity, you could certainly decentralize it with Aurora as well).
|
33
|
-
|
34
|
-
== Copyright and Licensing
|
35
|
-
|
36
|
-
Copyright (c) 2007 Matt Todd <http://purl.org/net/maraby>.
|
37
|
-
|
38
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
39
|
-
of this software and associated documentation files (the "Software"), to deal
|
40
|
-
in the Software without restriction, including without limitation the rights
|
41
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
42
|
-
copies of the Software, and to permit persons to whom the Software is
|
43
|
-
furnished to do so, subject to the following conditions:
|
44
|
-
|
45
|
-
The above copyright notice and this permission notice shall be included in
|
46
|
-
all copies or substantial portions of the Software.
|
47
|
-
|
48
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
49
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
50
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
51
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
52
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
53
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
54
|
-
THE SOFTWARE.
|
55
|
-
|
56
|
-
This notice is located at: http://www.opensource.org/licenses/mit-license.php
|
data/config/hoe.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'aurora/version'
|
2
|
-
|
3
|
-
AUTHOR = 'Matt Todd' # can also be an array of Authors
|
4
|
-
EMAIL = "mtodd@clayton.edu"
|
5
|
-
DESCRIPTION = "Simple authentication server and user permissions management tool."
|
6
|
-
GEM_NAME = 'aurora' # what ppl will type to install your gem
|
7
|
-
RUBYFORGE_PROJECT = 'aurora' # The unix name for your project
|
8
|
-
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
-
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
-
|
11
|
-
@config_file = "~/.rubyforge/user-config.yml"
|
12
|
-
@config = nil
|
13
|
-
RUBYFORGE_USERNAME = "unknown"
|
14
|
-
def rubyforge_username
|
15
|
-
unless @config
|
16
|
-
begin
|
17
|
-
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
18
|
-
rescue
|
19
|
-
puts <<-EOS
|
20
|
-
ERROR: No rubyforge config file found: #{@config_file}
|
21
|
-
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
22
|
-
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
23
|
-
EOS
|
24
|
-
exit
|
25
|
-
end
|
26
|
-
end
|
27
|
-
RUBYFORGE_USERNAME.replace @config["username"]
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
REV = nil
|
32
|
-
# UNCOMMENT IF REQUIRED:
|
33
|
-
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
34
|
-
VERS = Aurora::VERSION::STRING + (REV ? ".#{REV}" : "")
|
35
|
-
RDOC_OPTS = ['--quiet', '--title', 'Aurora Simple Authentication Server Docs',
|
36
|
-
"--opname", "index.html",
|
37
|
-
"--line-numbers",
|
38
|
-
"--main", "README",
|
39
|
-
"--inline-source"]
|
40
|
-
|
41
|
-
class Hoe
|
42
|
-
def extra_deps
|
43
|
-
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
44
|
-
@extra_deps
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# Generate all the Rake tasks
|
49
|
-
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
50
|
-
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
51
|
-
p.author = AUTHOR
|
52
|
-
p.description = DESCRIPTION
|
53
|
-
p.email = EMAIL
|
54
|
-
p.summary = DESCRIPTION
|
55
|
-
p.url = HOMEPATH
|
56
|
-
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
57
|
-
p.test_globs = ["test/**/test_*.rb"]
|
58
|
-
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store', 'tmp/*'] #An array of file patterns to delete on clean.
|
59
|
-
|
60
|
-
# == Optional
|
61
|
-
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
62
|
-
p.extra_deps = [
|
63
|
-
['json', '>= 1.1.1'],
|
64
|
-
['mongrel', '>= 1.1.1'],
|
65
|
-
['dhkeyexchange', '>= 1.0.0'],
|
66
|
-
['rack', '>= 0.2.0']
|
67
|
-
] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
68
|
-
|
69
|
-
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
74
|
-
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
75
|
-
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
76
|
-
hoe.rsync_args = '-av --delete --ignore-errors'
|
data/config/requirements.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
include FileUtils
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
-
begin
|
7
|
-
require req_gem
|
8
|
-
rescue LoadError
|
9
|
-
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
-
puts "Installation: gem install #{req_gem} -y"
|
11
|
-
exit
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
16
|
-
|
17
|
-
require 'aurora'
|
data/examples/basics.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'aurora/server/base'
|
2
|
-
|
3
|
-
Aurora::Server::Base.new('http://localhost:2828/', :logger_level => Logger::INFO) do |serv, uri, logger|
|
4
|
-
serv.authenticate do |user, pass|
|
5
|
-
# ldap = LDAP.new('http://localhost/')
|
6
|
-
# if ldap.bind("#{user}@domain")
|
7
|
-
if user == 'mtodd' and pass == 'test'
|
8
|
-
# successfully bound/authenticated
|
9
|
-
Aurora::Server::Token.new(user, pass)
|
10
|
-
else
|
11
|
-
false
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/lib/aurora/client/base.rb
DELETED
data/lib/aurora/client/token.rb
DELETED
data/lib/aurora/server/base.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
module Aurora
|
2
|
-
module Server
|
3
|
-
class Base
|
4
|
-
|
5
|
-
#--
|
6
|
-
# Constants and Attributes
|
7
|
-
#++
|
8
|
-
|
9
|
-
DEFAULTS = {
|
10
|
-
:log_file => '/var/log/aurora.server.log',
|
11
|
-
:log_level => Logger::ERROR
|
12
|
-
}
|
13
|
-
|
14
|
-
attr_accessor :options, :uri, :logger, :processes
|
15
|
-
|
16
|
-
#--
|
17
|
-
# class methods
|
18
|
-
#++
|
19
|
-
|
20
|
-
# Starts the server listening on the port specified
|
21
|
-
def initialize(uri, options = {})
|
22
|
-
# setup options
|
23
|
-
@options = DEFAULTS.merge(options)
|
24
|
-
@uri = URI.parse(uri)
|
25
|
-
@logger = Logger.new(@options[:log_file])
|
26
|
-
@logger.level = @options[:log_level]
|
27
|
-
|
28
|
-
@logger.info 'Starting Aurora Authentication Server...'
|
29
|
-
|
30
|
-
# setup authentication handlers
|
31
|
-
@logger.info 'Loading processes...'
|
32
|
-
yield self, @uri, @logger
|
33
|
-
@logger.info 'done.'
|
34
|
-
|
35
|
-
# setup server
|
36
|
-
@logger.info 'Starting HTTP Server and setting up HTTP Handler...'
|
37
|
-
serv = Aurora::Server::Server.new(@uri.host, @uri.port)
|
38
|
-
serv.register('/', Aurora::Server::Handler.new(self))
|
39
|
-
@logger.info 'done. Running now.'
|
40
|
-
serv.run.join
|
41
|
-
end
|
42
|
-
|
43
|
-
#--
|
44
|
-
# Instance Methods
|
45
|
-
#++
|
46
|
-
|
47
|
-
def parse_credentials(body)
|
48
|
-
['mtodd', 'test']
|
49
|
-
end
|
50
|
-
|
51
|
-
def authenticate(&block)
|
52
|
-
add_process(:authenticate, block)
|
53
|
-
end
|
54
|
-
|
55
|
-
def method_missing(name, *args, &block)
|
56
|
-
add_process(name, block)
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
# Adds process
|
62
|
-
def add_process(name, proc)
|
63
|
-
@processes ||= {}
|
64
|
-
@processes[name] = proc
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
module Aurora
|
2
|
-
module Server
|
3
|
-
class Handler < Mongrel::HttpHandler
|
4
|
-
|
5
|
-
#--
|
6
|
-
# constants and attributes
|
7
|
-
#++
|
8
|
-
|
9
|
-
attr_accessor :serv
|
10
|
-
|
11
|
-
#--
|
12
|
-
# Class Methods
|
13
|
-
#++
|
14
|
-
|
15
|
-
# Stores a reference to the Base server to access the processes (procs
|
16
|
-
# which define auth functionality) and then returns to the super
|
17
|
-
def initialize(serv)
|
18
|
-
@serv = serv
|
19
|
-
@serv.logger.info 'Loading Handler.'
|
20
|
-
super()
|
21
|
-
end
|
22
|
-
|
23
|
-
#--
|
24
|
-
# Instance Methods
|
25
|
-
#++
|
26
|
-
|
27
|
-
# Generic request processor (Mongrel hook)
|
28
|
-
def process(request, response)
|
29
|
-
@serv.logger.info 'Request received.'
|
30
|
-
|
31
|
-
# parse out username and password and call the authenticate method
|
32
|
-
@serv.logger.info request.body
|
33
|
-
user, pass = *Aurora::Server::Base.parse_credentials(request.body)
|
34
|
-
response = @serv.processses[:authenticate].call(user, pass)
|
35
|
-
|
36
|
-
# prepare response
|
37
|
-
if response.is_a? Aurora::Server::Token then
|
38
|
-
# success
|
39
|
-
code = 200
|
40
|
-
else
|
41
|
-
# failure
|
42
|
-
code = 200
|
43
|
-
end
|
44
|
-
|
45
|
-
# send response
|
46
|
-
response.start(code) do |head, out|
|
47
|
-
head["Content-Type"] = "application/json"
|
48
|
-
out.write(result.to_json)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
data/lib/aurora/server/server.rb
DELETED
data/lib/aurora/server/token.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module Aurora
|
2
|
-
module Server
|
3
|
-
class Token
|
4
|
-
|
5
|
-
#--
|
6
|
-
# Constants and Attributes
|
7
|
-
#++
|
8
|
-
|
9
|
-
attr_accessor :token, :lifetime
|
10
|
-
|
11
|
-
#--
|
12
|
-
# Class Methods
|
13
|
-
#++
|
14
|
-
|
15
|
-
# Takes the lifetime of the token
|
16
|
-
def initialize(user, pass, lifetime=5*60)
|
17
|
-
@lifetime = lifetime
|
18
|
-
@token = Digest::MD5.hexdigest("#{user}:#{pass}").split(/(....)/)[1..-1].map{|node|node="-" if node==""; node}.to_s.upcase
|
19
|
-
|
20
|
-
@@tokens ||= []
|
21
|
-
@@tokens << self
|
22
|
-
end
|
23
|
-
|
24
|
-
# Creates JSON format of Token
|
25
|
-
def to_json
|
26
|
-
{
|
27
|
-
:token => @token,
|
28
|
-
:lifetime => @lifetime
|
29
|
-
}.to_json
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/lib/aurora/version.rb
DELETED
data/log/debug.log
DELETED
File without changes
|
data/script/destroy
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/destroy'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Destroy.new.run(ARGV)
|