aurora 0.0.1
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/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +33 -0
- data/README.txt +56 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +76 -0
- data/config/requirements.rb +17 -0
- data/examples/basics.rb +14 -0
- data/lib/aurora.rb +5 -0
- data/lib/aurora/client.rb +22 -0
- data/lib/aurora/client/base.rb +15 -0
- data/lib/aurora/client/token.rb +7 -0
- data/lib/aurora/server.rb +26 -0
- data/lib/aurora/server/base.rb +69 -0
- data/lib/aurora/server/handler.rb +54 -0
- data/lib/aurora/server/server.rb +7 -0
- data/lib/aurora/server/token.rb +34 -0
- data/lib/aurora/version.rb +9 -0
- data/log/debug.log +0 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_aurora.rb +11 -0
- data/test/test_helper.rb +2 -0
- data/website/index.html +143 -0
- data/website/index.txt +77 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +126 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
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
ADDED
@@ -0,0 +1,33 @@
|
|
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
ADDED
@@ -0,0 +1,56 @@
|
|
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/Rakefile
ADDED
data/config/hoe.rb
ADDED
@@ -0,0 +1,76 @@
|
|
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'
|
@@ -0,0 +1,17 @@
|
|
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
ADDED
@@ -0,0 +1,14 @@
|
|
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.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Created by Matt Todd on 2007-11-10.
|
5
|
+
# Copyright (c) 2007 The HUB, Clayton State University. All rights reserved.
|
6
|
+
#++
|
7
|
+
|
8
|
+
#--
|
9
|
+
# Dependencies
|
10
|
+
#++
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'uri'
|
14
|
+
require 'json'
|
15
|
+
require 'digest/md5'
|
16
|
+
|
17
|
+
#--
|
18
|
+
# Module
|
19
|
+
#++
|
20
|
+
|
21
|
+
require 'client/base'
|
22
|
+
require 'client/token'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Created by Matt Todd on 2007-11-10.
|
5
|
+
# Copyright (c) 2007 The HUB, Clayton State University. All rights reserved.
|
6
|
+
#++
|
7
|
+
|
8
|
+
#--
|
9
|
+
# Dependencies
|
10
|
+
#++
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'logger'
|
14
|
+
require 'uri'
|
15
|
+
require 'json'
|
16
|
+
require 'digest/md5'
|
17
|
+
require 'mongrel'
|
18
|
+
|
19
|
+
#--
|
20
|
+
# Module
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'server/base'
|
24
|
+
require 'server/server'
|
25
|
+
require 'server/handler'
|
26
|
+
require 'server/token'
|
@@ -0,0 +1,69 @@
|
|
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
|
@@ -0,0 +1,54 @@
|
|
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
|