cas_client 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/cas_client/sessions_controller.rb +21 -3
- data/app/views/sessions/new.html.erb +15 -0
- data/config/routes.rb +6 -6
- data/lib/cas_client.rb +1 -0
- data/lib/cas_client/configuration.rb +22 -0
- data/lib/cas_client/engine.rb +3 -3
- data/lib/cas_client/user_api.rb +0 -1
- data/lib/cas_client/version.rb +1 -1
- metadata +6 -4
@@ -2,7 +2,17 @@ class CASClient::SessionsController < ApplicationController
|
|
2
2
|
unloadable # ensures this controller doesn't get reloaded between requests in development
|
3
3
|
|
4
4
|
def new
|
5
|
-
|
5
|
+
if CASClient::Configuration.mock_cas
|
6
|
+
if request.post?
|
7
|
+
request.env['omniauth.auth'] = {}
|
8
|
+
request.env['omniauth.auth']['uid'] = params[:uuid]
|
9
|
+
create
|
10
|
+
else
|
11
|
+
render :new
|
12
|
+
end
|
13
|
+
else
|
14
|
+
redirect_to '/auth/cas'
|
15
|
+
end
|
6
16
|
end
|
7
17
|
|
8
18
|
def create
|
@@ -10,11 +20,19 @@ class CASClient::SessionsController < ApplicationController
|
|
10
20
|
end
|
11
21
|
|
12
22
|
def destroy
|
13
|
-
|
23
|
+
if CASClient::Configuration.mock_cas
|
24
|
+
cas_logout
|
25
|
+
else
|
26
|
+
redirect_to ::CAS_SERVER["cas_domain"] + '/logout'
|
27
|
+
end
|
14
28
|
end
|
15
29
|
|
16
30
|
def cas_logout
|
17
|
-
|
31
|
+
if CASClient::Configuration.mock_cas
|
32
|
+
redirect_to login_path
|
33
|
+
else
|
34
|
+
render :nothing => true
|
35
|
+
end
|
18
36
|
end
|
19
37
|
|
20
38
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= form_tag do %>
|
2
|
+
<p>
|
3
|
+
<%= label_tag :uuid, "Username" %><br />
|
4
|
+
<%= text_field_tag :uuid %>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<p>
|
8
|
+
<%= label_tag :password %><br />
|
9
|
+
<%= password_field_tag :password %>
|
10
|
+
</p>
|
11
|
+
|
12
|
+
<p>
|
13
|
+
<%= submit_tag "Login" %>
|
14
|
+
</p>
|
15
|
+
<%- end %>
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
|
3
|
-
get
|
4
|
-
get
|
5
|
-
get
|
6
|
-
get
|
7
|
-
get
|
2
|
+
match 'login', :to => 'sessions#new', :as => :login
|
3
|
+
get 'logout', :to => 'sessions#destroy', :as => :logout
|
4
|
+
get 'cas_logout', :to => 'sessions#cas_logout'
|
5
|
+
get 'auth/cas/callback', :to => 'sessions#create'
|
6
|
+
get 'auth/facebook_signup/callback', :to => 'sessions#create'
|
7
|
+
get 'auth/facebook_signup', :as => :facebook_signup
|
8
8
|
end
|
data/lib/cas_client.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module CASClient
|
2
|
+
class Configuration
|
3
|
+
include Singleton
|
4
|
+
|
5
|
+
def self.mock_cas
|
6
|
+
self.instance.mock_cas
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.mock_cas=(_mock_cas)
|
10
|
+
self.instance.mock_cas = _mock_cas
|
11
|
+
end
|
12
|
+
|
13
|
+
def mock_cas
|
14
|
+
@mock_cas ||= false
|
15
|
+
end
|
16
|
+
|
17
|
+
def mock_cas=(_mock_cas)
|
18
|
+
@mock_cas = _mock_cas
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/lib/cas_client/engine.rb
CHANGED
@@ -7,7 +7,6 @@ require File.dirname(__FILE__) + '/user_api.rb'
|
|
7
7
|
module CASClient
|
8
8
|
|
9
9
|
class Engine < Rails::Engine
|
10
|
-
engine_name :cas_client
|
11
10
|
|
12
11
|
initializer "cas_client.configure_omniauth" do |app|
|
13
12
|
if File.exists?(Rails.root.to_s + '/config/cas_server.yml')
|
@@ -18,13 +17,14 @@ module CASClient
|
|
18
17
|
provider :facebook_signup, :cas_server => CAS_SERVER["cas_domain"]
|
19
18
|
end
|
20
19
|
else
|
21
|
-
|
20
|
+
warn "WARNING: A cas_server.yml configuration file is required. Please run 'rails g cas_client:install' to generate an example cas_server.yml file."
|
22
21
|
end
|
23
22
|
end
|
24
|
-
|
23
|
+
|
25
24
|
generators do
|
26
25
|
require File.dirname(__FILE__) + '/../generators/install_generator.rb'
|
27
26
|
end
|
27
|
+
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
data/lib/cas_client/user_api.rb
CHANGED
data/lib/cas_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cas_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Moran
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-29 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -65,9 +65,11 @@ files:
|
|
65
65
|
- Rakefile
|
66
66
|
- TODO
|
67
67
|
- app/controllers/cas_client/sessions_controller.rb
|
68
|
+
- app/views/sessions/new.html.erb
|
68
69
|
- cas_client.gemspec
|
69
70
|
- config/routes.rb
|
70
71
|
- lib/cas_client.rb
|
72
|
+
- lib/cas_client/configuration.rb
|
71
73
|
- lib/cas_client/engine.rb
|
72
74
|
- lib/cas_client/errors.rb
|
73
75
|
- lib/cas_client/user_api.rb
|