gcnovus-casrack_the_authenticator 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.rdoc +51 -0
  2. data/Rakefile +67 -0
  3. metadata +60 -0
data/README.rdoc ADDED
@@ -0,0 +1,51 @@
1
+ Casrack the Authenticator is a
2
+ Rack[http://github.com/chneukirchen/rack] middleware
3
+ that provides CAS[http://www.jasig.org/cas] support.
4
+
5
+ As of the current version, Casrack the Authenticator only supports the most basic
6
+ of CAS scenarios: it requires CAS authentication if it receives a 401 Unauthorized
7
+ response from lower-down in the Rack stack, and it stores the authentication token
8
+ in the session (so logout happens when users close their browers). Casrack the Authenticator
9
+ is a very open-minded beast, though, so please contribute (well-tested) additions to do
10
+ proxy-authentication and single-sign-out, or for anything else you desire.
11
+
12
+ === How-To
13
+
14
+ ==== 1: install
15
+
16
+ [sudo] gem install casrack_the_authenticator
17
+
18
+ ==== 2: set up the middleware:
19
+
20
+ # in your rackup:
21
+ use CasrackTheAuthenticator::Simple, :cas_server => "http://cas.mycompany.com/cas"
22
+ # or "config.middleware.use" if you're on Rails
23
+
24
+ See CasrackTheAuthenticator::Configuration for specifics on that Hash argument.
25
+
26
+ ==== 3: optionally install CasrackTheAuthenticator::RequireCAS if you want _every_ request to require CAS authentication:
27
+
28
+ # in your rackup:
29
+ use CasrackTheAuthenticator::Simple, :cas_server => ...
30
+ use CasrackTheAuthenticator::RequireCAS
31
+ # or "config.middleware.use" if you're on Rails
32
+
33
+ ==== 4: pull the authenticated CAS username out of the Rack session:
34
+
35
+ # in a Rack app:
36
+ def call(env)
37
+ user = cas_user(env)
38
+ ...
39
+ end
40
+
41
+ def cas_user(env)
42
+ username = Rack::Request.new(env).session[CasrackTheAuthenticator::USERNAME_PARAM]
43
+ User.find_by_username(username)
44
+ end
45
+
46
+ # or, in a Rails controller:
47
+
48
+ def cas_user
49
+ username = Rack::Request.new(request.env).session[CasrackTheAuthenticator::USERNAME_PARAM]
50
+ User.find_by_username(username)
51
+ end
data/Rakefile ADDED
@@ -0,0 +1,67 @@
1
+ desc "Default: run all tests, including features"
2
+ task :default => [ 'test', 'features' ]
3
+
4
+ # PACKAGING
5
+
6
+ require 'rake/gempackagetask'
7
+
8
+ spec = eval File.read('casrack_the_authenticator.gemspec')
9
+
10
+ Rake::GemPackageTask.new(spec) do |p|
11
+ p.gem_spec = spec
12
+ p.need_tar = true
13
+ p.need_zip = true
14
+ end
15
+
16
+ # DOCUMENTATION
17
+
18
+ require 'yard'
19
+ require 'yard/rake/yardoc_task'
20
+
21
+ desc "Generate RDoc"
22
+ task :doc => ['doc:generate']
23
+
24
+ namespace :doc do
25
+
26
+ doc_dir = './doc/rdoc'
27
+
28
+ YARD::Rake::YardocTask.new(:generate) do |yt|
29
+ yt.files = ['lib/**/*.rb', 'README.rdoc']
30
+ yt.options = ['--output-dir', doc_dir]
31
+ end
32
+
33
+ desc "Remove generated documenation"
34
+ task :clean do
35
+ rm_r doc_dir if File.exists?(doc_dir)
36
+ end
37
+
38
+ end
39
+
40
+ # TESTING
41
+
42
+ require 'cucumber'
43
+ require 'cucumber/rake/task'
44
+ require 'rake/testtask'
45
+
46
+ Cucumber::Rake::Task.new(:features) do |t|
47
+ t.cucumber_opts = "features --format pretty"
48
+ end
49
+
50
+ PROJECT_ROOT = File.expand_path(File.dirname(__FILE__))
51
+
52
+ LIB_DIRECTORIES = FileList.new do |fl|
53
+ fl.include "#{PROJECT_ROOT}/lib"
54
+ fl.include "#{PROJECT_ROOT}/test/lib"
55
+ end
56
+
57
+ TEST_FILES = FileList.new do |fl|
58
+ fl.include "#{PROJECT_ROOT}/test/**/*_test.rb"
59
+ fl.exclude "#{PROJECT_ROOT}/test/test_helper.rb"
60
+ fl.exclude "#{PROJECT_ROOT}/test/lib/**/*.rb"
61
+ end
62
+
63
+ Rake::TestTask.new(:test) do |t|
64
+ t.libs = LIB_DIRECTORIES
65
+ t.test_files = TEST_FILES
66
+ t.verbose = true
67
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gcnovus-casrack_the_authenticator
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - James Rosen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-30 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: CAS Authentication via Rack Middleware
17
+ email: james.a.rosen@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - README.rdoc
26
+ - Rakefile
27
+ has_rdoc: false
28
+ homepage: http://github.com/gcnovus/casrack_the_authenticator
29
+ licenses:
30
+ post_install_message:
31
+ rdoc_options:
32
+ - --line-numbers
33
+ - --inline-source
34
+ - --title
35
+ - "Casrack the Authenticator: RDoc"
36
+ - --charset
37
+ - utf-8
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ requirements: []
53
+
54
+ rubyforge_project:
55
+ rubygems_version: 1.3.5
56
+ signing_key:
57
+ specification_version: 2
58
+ summary: CAS Authentication via Rack Middleware
59
+ test_files: []
60
+