casino_core 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +48 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +24 -0
  6. data/Gemfile.lock +64 -0
  7. data/LICENSE.txt +20 -0
  8. data/README.md +19 -0
  9. data/Rakefile +44 -0
  10. data/VERSION +1 -0
  11. data/casino_core.gemspec +126 -0
  12. data/config/cas.yml +26 -0
  13. data/config/database.yml +18 -0
  14. data/db/migrate/20121112154930_create_ticket_granting_tickets.rb +11 -0
  15. data/db/migrate/20121112160009_create_login_tickets.rb +9 -0
  16. data/db/migrate/20121112165804_ticket_should_not_be_null.rb +5 -0
  17. data/db/migrate/20121122180310_add_user_agent_to_ticket_granting_tickets.rb +5 -0
  18. data/db/migrate/20121124170004_add_index_for_username_to_ticket_granting_tickets.rb +5 -0
  19. data/db/migrate/20121124183542_create_service_tickets.rb +13 -0
  20. data/db/migrate/20121124183732_add_ticket_indexes.rb +6 -0
  21. data/db/migrate/20121124195013_add_consumed_to_service_tickets.rb +5 -0
  22. data/db/migrate/20121125091934_add_issued_from_credentials_to_service_tickets.rb +5 -0
  23. data/db/migrate/20121125185415_create_proxy_granting_tickets.rb +14 -0
  24. data/db/migrate/20121125190013_tickets_should_be_unique.rb +8 -0
  25. data/db/schema.rb +61 -0
  26. data/lib/casino_core.rb +33 -0
  27. data/lib/casino_core/authenticator.rb +9 -0
  28. data/lib/casino_core/authenticator/static.rb +23 -0
  29. data/lib/casino_core/helper.rb +21 -0
  30. data/lib/casino_core/helper/browser.rb +16 -0
  31. data/lib/casino_core/helper/service_tickets.rb +30 -0
  32. data/lib/casino_core/model.rb +10 -0
  33. data/lib/casino_core/model/login_ticket.rb +11 -0
  34. data/lib/casino_core/model/proxy_granting_ticket.rb +8 -0
  35. data/lib/casino_core/model/service_ticket.rb +32 -0
  36. data/lib/casino_core/model/service_ticket/single_sign_out_notifier.rb +53 -0
  37. data/lib/casino_core/model/ticket_granting_ticket.rb +9 -0
  38. data/lib/casino_core/processor.rb +15 -0
  39. data/lib/casino_core/processor/legacy_validator.rb +49 -0
  40. data/lib/casino_core/processor/login_credential_acceptor.rb +67 -0
  41. data/lib/casino_core/processor/login_credential_requestor.rb +45 -0
  42. data/lib/casino_core/processor/logout.rb +23 -0
  43. data/lib/casino_core/processor/session_destroyer.rb +17 -0
  44. data/lib/casino_core/railtie.rb +10 -0
  45. data/lib/casino_core/rake_tasks.rb +14 -0
  46. data/lib/casino_core/settings.rb +26 -0
  47. data/lib/casino_core/tasks/cleanup.rake +26 -0
  48. data/lib/casino_core/tasks/database.rake +60 -0
  49. data/spec/authenticator/static_spec.rb +42 -0
  50. data/spec/model/login_ticket_spec.rb +16 -0
  51. data/spec/model/service_ticket_spec.rb +45 -0
  52. data/spec/processor/legacy_validator_spec.rb +87 -0
  53. data/spec/processor/login_credential_acceptor_spec.rb +70 -0
  54. data/spec/processor/login_credential_requestor_spec.rb +75 -0
  55. data/spec/processor/logout_spec.rb +55 -0
  56. data/spec/processor/session_destroyer_spec.rb +68 -0
  57. data/spec/spec_helper.rb +33 -0
  58. metadata +234 -0
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --format documentation
data/.rvmrc ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p194@casino_core"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.15.8 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ before_script:
3
+ - DATABASE_ENV=test rake casino_core:db:schema:load
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ source 'http://rubygems.org'
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem 'activesupport', '>= 2.3.5'
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem 'bundler', '~> 1.2.0'
10
+ gem 'jeweler', '~> 1.8.4'
11
+ gem 'redcarpet'
12
+ gem 'yard', '~> 0.8.3', require: 'redcarpet'
13
+ end
14
+
15
+ group :development, :test do
16
+ gem 'rspec', '~> 2.12.0'
17
+ gem 'simplecov', '~> 0.7.1'
18
+ gem 'sqlite3'
19
+ gem 'database_cleaner'
20
+ end
21
+
22
+ gem 'activerecord', '~> 3.2.9'
23
+ gem 'addressable', '~> 2.3.2'
24
+ gem 'useragent', '~> 0.4.13'
@@ -0,0 +1,64 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.2.9)
5
+ activesupport (= 3.2.9)
6
+ builder (~> 3.0.0)
7
+ activerecord (3.2.9)
8
+ activemodel (= 3.2.9)
9
+ activesupport (= 3.2.9)
10
+ arel (~> 3.0.2)
11
+ tzinfo (~> 0.3.29)
12
+ activesupport (3.2.9)
13
+ i18n (~> 0.6)
14
+ multi_json (~> 1.0)
15
+ addressable (2.3.2)
16
+ arel (3.0.2)
17
+ builder (3.0.4)
18
+ database_cleaner (0.9.1)
19
+ diff-lcs (1.1.3)
20
+ git (1.2.5)
21
+ i18n (0.6.1)
22
+ jeweler (1.8.4)
23
+ bundler (~> 1.0)
24
+ git (>= 1.2.5)
25
+ rake
26
+ rdoc
27
+ json (1.7.5)
28
+ multi_json (1.4.0)
29
+ rake (10.0.2)
30
+ rdoc (3.12)
31
+ json (~> 1.4)
32
+ redcarpet (2.2.2)
33
+ rspec (2.12.0)
34
+ rspec-core (~> 2.12.0)
35
+ rspec-expectations (~> 2.12.0)
36
+ rspec-mocks (~> 2.12.0)
37
+ rspec-core (2.12.0)
38
+ rspec-expectations (2.12.0)
39
+ diff-lcs (~> 1.1.3)
40
+ rspec-mocks (2.12.0)
41
+ simplecov (0.7.1)
42
+ multi_json (~> 1.0)
43
+ simplecov-html (~> 0.7.1)
44
+ simplecov-html (0.7.1)
45
+ sqlite3 (1.3.6)
46
+ tzinfo (0.3.35)
47
+ useragent (0.4.15)
48
+ yard (0.8.3)
49
+
50
+ PLATFORMS
51
+ ruby
52
+
53
+ DEPENDENCIES
54
+ activerecord (~> 3.2.9)
55
+ addressable (~> 2.3.2)
56
+ bundler (~> 1.2.0)
57
+ database_cleaner
58
+ jeweler (~> 1.8.4)
59
+ redcarpet
60
+ rspec (~> 2.12.0)
61
+ simplecov (~> 0.7.1)
62
+ sqlite3
63
+ useragent (~> 0.4.13)
64
+ yard (~> 0.8.3)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Nils Caspar
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.
@@ -0,0 +1,19 @@
1
+ # CASinoCore [![Build Status](https://secure.travis-ci.org/pencil/CASinoCore.png?branch=master)](https://travis-ci.org/pencil/CASinoCore)
2
+
3
+ A CAS server core library.
4
+
5
+ ## Contributing to CASinoCore
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ ## Copyright
16
+
17
+ Copyright (c) 2012 Nils Caspar. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
3
+
4
+ require 'rubygems'
5
+ require 'bundler'
6
+ begin
7
+ Bundler.setup(:default, :development)
8
+ rescue Bundler::BundlerError => e
9
+ $stderr.puts e.message
10
+ $stderr.puts "Run `bundle install` to install missing gems"
11
+ exit e.status_code
12
+ end
13
+ require 'rake'
14
+
15
+ require 'casino_core'
16
+ CASinoCore.setup 'development'
17
+ CASinoCore::RakeTasks.load_tasks
18
+
19
+ require 'jeweler'
20
+ Jeweler::Tasks.new do |gem|
21
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
22
+ gem.name = "casino_core"
23
+ gem.homepage = "http://github.com/pencil/CASinoCore"
24
+ gem.license = "MIT"
25
+ gem.summary = "A CAS server core library."
26
+ gem.description = gem.summary
27
+ gem.email = "ncaspar@me.com"
28
+ gem.authors = ["Nils Caspar"]
29
+ # dependencies defined in Gemfile
30
+ end
31
+ Jeweler::RubygemsDotOrgTasks.new
32
+
33
+ require 'yard'
34
+ YARD::Rake::YardocTask.new do |t|
35
+ t.files = FileList['lib/**/*.rb']
36
+ end
37
+
38
+ require 'rspec/core'
39
+ require 'rspec/core/rake_task'
40
+ RSpec::Core::RakeTask.new(:spec) do |spec|
41
+ spec.pattern = FileList['spec/**/*_spec.rb']
42
+ end
43
+
44
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,126 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "casino_core"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Nils Caspar"]
12
+ s.date = "2012-12-16"
13
+ s.description = "A CAS server core library."
14
+ s.email = "ncaspar@me.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ ".rvmrc",
23
+ ".travis.yml",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.md",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "casino_core.gemspec",
31
+ "config/cas.yml",
32
+ "config/database.yml",
33
+ "db/migrate/20121112154930_create_ticket_granting_tickets.rb",
34
+ "db/migrate/20121112160009_create_login_tickets.rb",
35
+ "db/migrate/20121112165804_ticket_should_not_be_null.rb",
36
+ "db/migrate/20121122180310_add_user_agent_to_ticket_granting_tickets.rb",
37
+ "db/migrate/20121124170004_add_index_for_username_to_ticket_granting_tickets.rb",
38
+ "db/migrate/20121124183542_create_service_tickets.rb",
39
+ "db/migrate/20121124183732_add_ticket_indexes.rb",
40
+ "db/migrate/20121124195013_add_consumed_to_service_tickets.rb",
41
+ "db/migrate/20121125091934_add_issued_from_credentials_to_service_tickets.rb",
42
+ "db/migrate/20121125185415_create_proxy_granting_tickets.rb",
43
+ "db/migrate/20121125190013_tickets_should_be_unique.rb",
44
+ "db/schema.rb",
45
+ "lib/casino_core.rb",
46
+ "lib/casino_core/authenticator.rb",
47
+ "lib/casino_core/authenticator/static.rb",
48
+ "lib/casino_core/helper.rb",
49
+ "lib/casino_core/helper/browser.rb",
50
+ "lib/casino_core/helper/service_tickets.rb",
51
+ "lib/casino_core/model.rb",
52
+ "lib/casino_core/model/login_ticket.rb",
53
+ "lib/casino_core/model/proxy_granting_ticket.rb",
54
+ "lib/casino_core/model/service_ticket.rb",
55
+ "lib/casino_core/model/service_ticket/single_sign_out_notifier.rb",
56
+ "lib/casino_core/model/ticket_granting_ticket.rb",
57
+ "lib/casino_core/processor.rb",
58
+ "lib/casino_core/processor/legacy_validator.rb",
59
+ "lib/casino_core/processor/login_credential_acceptor.rb",
60
+ "lib/casino_core/processor/login_credential_requestor.rb",
61
+ "lib/casino_core/processor/logout.rb",
62
+ "lib/casino_core/processor/session_destroyer.rb",
63
+ "lib/casino_core/railtie.rb",
64
+ "lib/casino_core/rake_tasks.rb",
65
+ "lib/casino_core/settings.rb",
66
+ "lib/casino_core/tasks/cleanup.rake",
67
+ "lib/casino_core/tasks/database.rake",
68
+ "spec/authenticator/static_spec.rb",
69
+ "spec/model/login_ticket_spec.rb",
70
+ "spec/model/service_ticket_spec.rb",
71
+ "spec/processor/legacy_validator_spec.rb",
72
+ "spec/processor/login_credential_acceptor_spec.rb",
73
+ "spec/processor/login_credential_requestor_spec.rb",
74
+ "spec/processor/logout_spec.rb",
75
+ "spec/processor/session_destroyer_spec.rb",
76
+ "spec/spec_helper.rb"
77
+ ]
78
+ s.homepage = "http://github.com/pencil/CASinoCore"
79
+ s.licenses = ["MIT"]
80
+ s.require_paths = ["lib"]
81
+ s.rubygems_version = "1.8.24"
82
+ s.summary = "A CAS server core library."
83
+
84
+ if s.respond_to? :specification_version then
85
+ s.specification_version = 3
86
+
87
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
88
+ s.add_runtime_dependency(%q<activerecord>, ["~> 3.2.9"])
89
+ s.add_runtime_dependency(%q<addressable>, ["~> 2.3.2"])
90
+ s.add_runtime_dependency(%q<useragent>, ["~> 0.4.13"])
91
+ s.add_development_dependency(%q<bundler>, ["~> 1.2.0"])
92
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
93
+ s.add_development_dependency(%q<redcarpet>, [">= 0"])
94
+ s.add_development_dependency(%q<yard>, ["~> 0.8.3"])
95
+ s.add_development_dependency(%q<rspec>, ["~> 2.12.0"])
96
+ s.add_development_dependency(%q<simplecov>, ["~> 0.7.1"])
97
+ s.add_development_dependency(%q<sqlite3>, [">= 0"])
98
+ s.add_development_dependency(%q<database_cleaner>, [">= 0"])
99
+ else
100
+ s.add_dependency(%q<activerecord>, ["~> 3.2.9"])
101
+ s.add_dependency(%q<addressable>, ["~> 2.3.2"])
102
+ s.add_dependency(%q<useragent>, ["~> 0.4.13"])
103
+ s.add_dependency(%q<bundler>, ["~> 1.2.0"])
104
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
105
+ s.add_dependency(%q<redcarpet>, [">= 0"])
106
+ s.add_dependency(%q<yard>, ["~> 0.8.3"])
107
+ s.add_dependency(%q<rspec>, ["~> 2.12.0"])
108
+ s.add_dependency(%q<simplecov>, ["~> 0.7.1"])
109
+ s.add_dependency(%q<sqlite3>, [">= 0"])
110
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
111
+ end
112
+ else
113
+ s.add_dependency(%q<activerecord>, ["~> 3.2.9"])
114
+ s.add_dependency(%q<addressable>, ["~> 2.3.2"])
115
+ s.add_dependency(%q<useragent>, ["~> 0.4.13"])
116
+ s.add_dependency(%q<bundler>, ["~> 1.2.0"])
117
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
118
+ s.add_dependency(%q<redcarpet>, [">= 0"])
119
+ s.add_dependency(%q<yard>, ["~> 0.8.3"])
120
+ s.add_dependency(%q<rspec>, ["~> 2.12.0"])
121
+ s.add_dependency(%q<simplecov>, ["~> 0.7.1"])
122
+ s.add_dependency(%q<sqlite3>, [">= 0"])
123
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
124
+ end
125
+ end
126
+
@@ -0,0 +1,26 @@
1
+ defaults: &defaults
2
+ login_ticket:
3
+ lifetime: 600
4
+ service_ticket:
5
+ lifetime_unconsumed: 300
6
+ lifetime_consumed: 86400
7
+
8
+ development:
9
+ <<: *defaults
10
+ authenticators:
11
+ -
12
+ class: "CASinoCore::Authenticator::Static"
13
+ options:
14
+ users:
15
+ testuser:
16
+ password: foobar123
17
+
18
+ test:
19
+ <<: *defaults
20
+ authenticators:
21
+ -
22
+ class: "CASinoCore::Authenticator::Static"
23
+ options:
24
+ users:
25
+ testuser:
26
+ password: foobar123
@@ -0,0 +1,18 @@
1
+ # this configuration is only needed to setup the database for the tests
2
+
3
+ # SQLite version 3.x
4
+ # gem install sqlite3
5
+ #
6
+ # Ensure the SQLite 3 gem is defined in your Gemfile
7
+ # gem 'sqlite3'
8
+ development:
9
+ adapter: sqlite3
10
+ database: db/development.sqlite3
11
+ pool: 5
12
+ timeout: 5000
13
+
14
+ test:
15
+ adapter: sqlite3
16
+ database: db/test.sqlite3
17
+ pool: 5
18
+ timeout: 5000
@@ -0,0 +1,11 @@
1
+ class CreateTicketGrantingTickets < ActiveRecord::Migration
2
+ def change
3
+ create_table :ticket_granting_tickets do |t|
4
+ t.string :ticket, null: false, unique: true
5
+ t.string :username, null: false
6
+ t.text :extra_attributes
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class CreateLoginTickets < ActiveRecord::Migration
2
+ def change
3
+ create_table :login_tickets do |t|
4
+ t.string :ticket
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class TicketShouldNotBeNull < ActiveRecord::Migration
2
+ def change
3
+ change_column :login_tickets, :ticket, :string, null: false, unique: true
4
+ end
5
+ end