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.
@@ -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
- redirect_to '/auth/cas'
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
- redirect_to ::CAS_SERVER["domain"] + '/logout'
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
- render :nothing => true
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 %>
@@ -1,8 +1,8 @@
1
1
  Rails.application.routes.draw do
2
- get "/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
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
@@ -7,6 +7,7 @@ if defined?(Rails) && Rails::VERSION::MAJOR == 3
7
7
  require 'omniauth/strategies/facebook_signup/strategy'
8
8
  end
9
9
  require 'cas_client/errors'
10
+ require 'cas_client/configuration'
10
11
 
11
12
  module CASClient
12
13
  end
@@ -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
@@ -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
- raise "A cas_server.yml configuration file is required. Please run 'rails g cas_client:install' to generate an example cas_server.yml file."
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
@@ -152,7 +152,6 @@ module CASClient
152
152
  when "Password doesn't match confirmation"
153
153
  raise CASClient::PasswordMismatch, "Password and confirmation do not match"
154
154
  else
155
- puts res.body
156
155
  res.error!
157
156
  end
158
157
  else
@@ -1,3 +1,3 @@
1
1
  module CASClient
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
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 00:00:00 -07:00
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