shibboleth_auth 0.0.1 → 0.1.0

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/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,35 @@
1
+ class ShibbolethAuth::LoginController < ApplicationController
2
+
3
+ # GET /shibboleth_auth/login
4
+ def login_form
5
+ end
6
+
7
+ # GET /shibboleth_auth/show
8
+ def show
9
+ end
10
+
11
+ # POST /shibboleth_auth/login
12
+ def login
13
+ # Adding Group Prefix
14
+ groups = params["shibboleth_debug_login"][:groups].split(";").map do |group|
15
+ ShibbolethAuth::GroupPrefixField + ":" + group unless group.include?(ShibbolethAuth::GroupPrefixField)
16
+ end.join(";")
17
+
18
+ session[:shibboleth_debug_env] = {
19
+ ShibbolethAuth::UsernameField => params["shibboleth_debug_login"][:person_uid],
20
+ ShibbolethAuth::CommonNameField => params["shibboleth_debug_login"][:person_common_name],
21
+ ShibbolethAuth::GroupsField => groups,
22
+ ShibbolethAuth::AffiliationField => params["shibboleth_debug_login"][:unscoped_affiliation],
23
+ 'debug_login' => true
24
+ }
25
+ session[:shibboleth_debug_login] = true
26
+ redirect_to :root
27
+ end
28
+
29
+ # GET /shibboleth_auth/logout
30
+ def logout
31
+ session[:shibboleth_debug_login] = false
32
+ session[:shibboleth_debug_env] = nil
33
+ redirect_to :root
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+
2
+ module ShibbolethAuth
3
+ class ShibbolethUser
4
+ attr_reader :username, :common_name, :groups, :affiliations
5
+
6
+ def strip_group_prefix groups
7
+ return groups.select do |s|
8
+ s[0...ShibbolethAuth::GroupPrefixField.length] == ShibbolethAuth::GroupPrefixField
9
+ end.map do |s|
10
+ s[ShibbolethAuth::GroupPrefixField.length+1..-1]
11
+ end
12
+ end
13
+
14
+ def initialize(env)
15
+ # Development Settings
16
+ if env["HTTP_HOST"] && ["localhost", "127.0.0.1"].any? {|url| env["HTTP_HOST"].include? url }
17
+ @username = ShibbolethAuth::DevelopmentUsername
18
+ @common_name = ShibbolethAuth::DevelopmentCommonName
19
+ @groups = strip_group_prefix ShibbolethAuth::DevelopmentGroups
20
+ @affiliations = ShibbolethAuth::DevelopmentAffiliation
21
+ else
22
+ env = env[:shibboleth_debug_env] || env
23
+ @username = env[ShibbolethAuth::UsernameField]
24
+ @common_name = env[ShibbolethAuth::CommonNameField]
25
+
26
+ # strip the group prefix from groups
27
+ @groups = strip_group_prefix(env[ShibbolethAuth::GroupsField] || '')
28
+
29
+ @affiliations = (env[ShibbolethAuth::AffiliationField] || '').split(';')
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ require 'rails/generators'
2
+ module ShibbolethAuth
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ desc = "
6
+ Description:
7
+ Copy rspec files to your application."
8
+
9
+ def self.source_root
10
+ File.join(File.dirname(__FILE__), 'templates')
11
+ end
12
+ def install_auth
13
+ copy_file(
14
+ 'app/views/shibboleth_auth/login/login_form.html.haml',
15
+ 'app/views/shibboleth_auth/login/login_form.html.haml'
16
+ )
17
+ copy_file(
18
+ 'app/views/shibboleth_auth/login/show.html.haml',
19
+ 'app/views/shibboleth_auth/login/show.html.haml'
20
+ )
21
+ copy_file(
22
+ 'config/initializers/shibboleth_auth.rb',
23
+ 'config/initializers/shibboleth_auth.rb'
24
+ )
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ = semantic_form_for 'shibboleth_debug_login', :url => shibboleth_debug_login_url do |f|
2
+ = f.inputs "Shibboleth Debug Login" do
3
+ = f.input :person_uid, :input_html => {:value => ShibbolethAuth::DebugDefaultUsername}
4
+ = f.input :person_common_name, :input_html => {:value => ShibbolethAuth::DebugDefaultCommonName}
5
+ = f.input :groups, :input_html => {:value => ShibbolethAuth::DebugDefaultGroups}
6
+ = f.input :unscoped_affiliation, :input_html => {:value => ShibbolethAuth::DebugDefaultAffiliation}
7
+ = f.buttons
@@ -0,0 +1,19 @@
1
+ %p Shibboleth Data:
2
+ %p
3
+ %b Username:
4
+ = @current_user.username
5
+ %p
6
+ %b Common Name:
7
+ = @current_user.common_name
8
+ %p
9
+ %b Groups:
10
+ %br
11
+ %ul
12
+ - @current_user.groups.each do |group|
13
+ %li= group
14
+ %p
15
+ %b Affiliation:
16
+ %br
17
+ %ul
18
+ - @current_user.affiliations.each do |affiliation|
19
+ %li= affiliation
@@ -0,0 +1,22 @@
1
+ # Fieldnames from the enviroment (env)
2
+ ShibbolethAuth::UsernameField = 'HTTP_SHIB_INETORGPERSON_UID'
3
+ ShibbolethAuth::CommonNameField = 'HTTP_SHIB_PERSON_COMMONNAME'
4
+ ShibbolethAuth::GroupsField = 'HTTP_SHIB_EP_ENTITLEMENT'
5
+ ShibbolethAuth::AffiliationField = 'HTTP_SHIB_EP_UNSCOPEDAFFILIATION'
6
+
7
+ # This GroupPrefix will be cut off from every group and will be added on every group in the debug login formular
8
+ ShibbolethAuth::GroupPrefixField = 'my:prefix:group'
9
+
10
+ # Default values for the debug login formular
11
+ ShibbolethAuth::DebugDefaultUsername = 'ab123456'
12
+ ShibbolethAuth::DebugDefaultCommonName = 'Debug User'
13
+ ShibbolethAuth::DebugDefaultGroups = 'my:prefix:group:...'
14
+ ShibbolethAuth::DebugDefaultAffiliation = ''
15
+
16
+ # Default values for the development user
17
+ ShibbolethAuth::DevelopmentUsername = 'dev12345'
18
+ ShibbolethAuth::DevelopmentCommonName = 'Development User'
19
+ # As Array
20
+ ShibbolethAuth::DevelopmentGroups = ["my:prefix:group:..."]
21
+ # As Array
22
+ ShibbolethAuth::DevelopmentAffiliation = []
data/lib/routes.rb ADDED
@@ -0,0 +1,10 @@
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+ def shibboleth_routes
4
+ match "/shibboleth_debug_login", :to => "shibboleth_auth/login#login_form", :via => :get, :as => "shibboleth_debug_login"
5
+ match "/shibboleth_debug_login", :to => "shibboleth_auth/login#login", :via => :post, :as => "shibboleth_debug_login"
6
+ match "/shibboleth_debug_logout", :to => "shibboleth_auth/login#logout", :as => "shibboleth_debug_logout"
7
+ match "/shibboleth_debug_show", :to => "shibboleth_auth/login#show", :as => "shibboleth_debug_show"
8
+ end
9
+ end
10
+ end
@@ -5,7 +5,7 @@ module ShibbolethAuth
5
5
 
6
6
  autoload :LoginController, __FILE__.split('/')[0..-2].join('/')+'/../app/controllers/login_controller'
7
7
  autoload :ShibbolethUser, __FILE__.split('/')[0..-2].join('/')+'/../app/models/shibboleth_user'
8
- require 'generators/auth_generator'
8
+ require './generators/auth_generator'
9
9
  require 'routes'
10
10
  class Railtie < Rails::Railtie
11
11
  end
@@ -0,0 +1,74 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{shibboleth_auth}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Dominik Masur"]
12
+ s.date = %q{2010-09-08}
13
+ s.description = %q{Adds a Userobject and a debug Login/Logout to your Railsapplication}
14
+ s.email = %q{masur@rz.rwth-aachen.de}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "app/controllers/login_controller.rb",
27
+ "app/models/shibboleth_user.rb",
28
+ "features/shibboleth_auth.feature",
29
+ "features/step_definitions/shibboleth_auth_steps.rb",
30
+ "features/support/env.rb",
31
+ "lib/generators/auth_generator.rb",
32
+ "lib/generators/templates/app/views/shibboleth_auth/login/login_form.html.haml",
33
+ "lib/generators/templates/app/views/shibboleth_auth/login/show.html.haml",
34
+ "lib/generators/templates/config/initializers/shibboleth_auth.rb",
35
+ "lib/routes.rb",
36
+ "lib/shibboleth_auth.rb",
37
+ "shibboleth_auth.gemspec",
38
+ "spec/shibboleth_auth_spec.rb",
39
+ "spec/spec.opts",
40
+ "spec/spec_helper.rb"
41
+ ]
42
+ s.homepage = %q{http://github.com/TBAA/shibboleth_auth}
43
+ s.rdoc_options = ["--charset=UTF-8"]
44
+ s.require_paths = ["lib"]
45
+ s.rubygems_version = %q{1.3.7}
46
+ s.summary = %q{Support for Shibboleth Auth}
47
+ s.test_files = [
48
+ "spec/shibboleth_auth_spec.rb",
49
+ "spec/spec_helper.rb"
50
+ ]
51
+
52
+ if s.respond_to? :specification_version then
53
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
+ s.specification_version = 3
55
+
56
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
58
+ s.add_development_dependency(%q<cucumber>, [">= 0.8.5"])
59
+ s.add_development_dependency(%q<haml>, [">= 3.0.0"])
60
+ s.add_development_dependency(%q<formtastic>, [">= 1.0.0"])
61
+ else
62
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
63
+ s.add_dependency(%q<cucumber>, [">= 0.8.5"])
64
+ s.add_dependency(%q<haml>, [">= 3.0.0"])
65
+ s.add_dependency(%q<formtastic>, [">= 1.0.0"])
66
+ end
67
+ else
68
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
69
+ s.add_dependency(%q<cucumber>, [">= 0.8.5"])
70
+ s.add_dependency(%q<haml>, [">= 3.0.0"])
71
+ s.add_dependency(%q<formtastic>, [">= 1.0.0"])
72
+ end
73
+ end
74
+
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 0
8
7
  - 1
9
- version: 0.0.1
8
+ - 0
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dominik Masur
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-12 00:00:00 +02:00
17
+ date: 2010-09-08 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -62,6 +62,21 @@ dependencies:
62
62
  version: 3.0.0
63
63
  type: :development
64
64
  version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: formtastic
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 1
75
+ - 0
76
+ - 0
77
+ version: 1.0.0
78
+ type: :development
79
+ version_requirements: *id004
65
80
  description: Adds a Userobject and a debug Login/Logout to your Railsapplication
66
81
  email: masur@rz.rwth-aachen.de
67
82
  executables: []
@@ -77,10 +92,19 @@ files:
77
92
  - LICENSE
78
93
  - README.rdoc
79
94
  - Rakefile
95
+ - VERSION
96
+ - app/controllers/login_controller.rb
97
+ - app/models/shibboleth_user.rb
80
98
  - features/shibboleth_auth.feature
81
99
  - features/step_definitions/shibboleth_auth_steps.rb
82
100
  - features/support/env.rb
101
+ - lib/generators/auth_generator.rb
102
+ - lib/generators/templates/app/views/shibboleth_auth/login/login_form.html.haml
103
+ - lib/generators/templates/app/views/shibboleth_auth/login/show.html.haml
104
+ - lib/generators/templates/config/initializers/shibboleth_auth.rb
105
+ - lib/routes.rb
83
106
  - lib/shibboleth_auth.rb
107
+ - shibboleth_auth.gemspec
84
108
  - spec/shibboleth_auth_spec.rb
85
109
  - spec/spec.opts
86
110
  - spec/spec_helper.rb