Permalink
Browse files

Version bump to 0.0.0

  • Loading branch information...
1 parent 99259b6 commit 5fa5836d03a3c4aa04b577d9e9f1462ed8bd4e63 @peakpg peakpg committed Jan 15, 2010
View
@@ -55,7 +55,7 @@ group can visit.
## E. Configure Login Form Portlet
Alter the Login Form portlet to look something like this:
- <% form_tag "https://cas.yourdomainname.org" do %>
+ <% form_tag "login_url" do %>
<%= login_ticket_tag %>
<%= service_url_tag %>
<p>
@@ -76,9 +76,17 @@ Alter the Login Form portlet to look something like this:
The key changes are:
1. The form needs to submit directly to the CAS server
-2. You need to add helpers for login_ticket_tag and service_url_tag. These generate hidden parameters CAS services need.
+2. You need to add helpers for login_url, login_ticket_tag and service_url_tag. These generate hidden parameters CAS services need.
3. Change the username parameter from :login to :username
+You must also create a file in your project called: app/portlets/helpers/login_portlet_helper.rb, with the following contents:
+
+ module LoginPortletHelper
+ include Cas::LoginPortlet
+ end
+
+This will add the needed methods for the above class.
+
F. Known Issues
* Every page is secured by the CASClient Gateway Filter, which means a lot of redirects. This is potentially a big performance hit, and would require modifying the filter so it only handles checking login_tickets, rather than redirects.
View
@@ -1,4 +1,4 @@
---
:minor: 0
:patch: 0
-:major: 1
+:major: 0
@@ -1,15 +1,3 @@
-# This assumes there is no existing LoginPortletHelper defined in the Core CMS project, and provides one
-# to simplify what users need to do in the form.
module LoginPortletHelper
-
- # Generates the hidden field for the service_url that the CAS server expects, which tells it where to redirect to. Must create
- # an absolute URL.
- def service_url_tag
- hidden_field_tag :service, Cas::Utils.service_url(@portlet, @page, session[:return_to])
- end
-
- # Generates the hidden field for the login ticket that CAS server expects.
- def login_ticket_tag
- hidden_field_tag :lt, Cas::Utils.fetch_lt_from_cas
- end
+ include Cas::LoginPortlet
end
View
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
]
s.files = [
"app/models/cas_user.rb",
- "app/portlets/helpers/login_portlet_helper.rb",
+ "app/portlets/helpers/login_portlet_extension.rb",
"db/migrate/20091002162550_add_cas_user_group.rb",
"lib/bcms_cas.rb",
"lib/bcms_cas/routes.rb",
@@ -0,0 +1,7 @@
+# This is the 'last' initialzer to ensure that the module has been initialized first.
+
+# Configure a sample service to point to a local CAS Server.
+CASClient::Frameworks::Rails::Filter.configure(
+ :cas_base_url => "https://localhost",
+ :extra_attributes_session_key => :cas_extra_attributes
+)
View
@@ -1,2 +1,3 @@
require 'bcms_cas/routes'
require 'cas/authentication'
+require 'cas/login_portlet_extension'
@@ -0,0 +1,22 @@
+##
+# This file needs to be included in a file called app/portlets/helpers/login_portlet_helper.rb
+# in the project. See installation instructions in the README for details.
+module Cas::LoginPortlet
+
+ # Generates the hidden field for the service_url that the CAS server expects, which tells it where to redirect to. Must create
+ # an absolute URL.
+ def service_url_tag
+ hidden_field_tag :service, Cas::Utils.service_url(@portlet, @page, session[:return_to])
+ end
+
+ # Generates the hidden field for the login ticket that CAS server expects.
+ def login_ticket_tag
+ hidden_field_tag :lt, Cas::Utils.fetch_lt_from_cas
+ end
+
+ ##
+ # Returns the URL to the CAS login service.
+ def login_url
+ CASClient::Frameworks::Rails::Filter.login_url
+ end
+end
@@ -0,0 +1,33 @@
+require "test_helper"
+require 'mocha'
+
+class LoginObject
+ include Cas::LoginPortlet
+end
+
+class LoginPortletTest < ActiveSupport::TestCase
+
+ test "service_url_tag" do
+ obj = LoginObject.new
+ assert obj.respond_to?(:service_url_tag)
+ end
+
+ test "login_ticket_tag" do
+ obj = LoginObject.new
+ assert obj.respond_to?(:login_ticket_tag)
+ end
+
+ test "login_service_url exists" do
+ obj = LoginObject.new
+ assert obj.respond_to?(:login_url)
+ end
+
+ test "Returns the login service from Cas" do
+ CASClient::Frameworks::Rails::Filter.expects(:login_url).returns("http://example.com")
+
+ obj = LoginObject.new
+
+ assert_equal "http://example.com", obj.login_url
+ end
+
+end

0 comments on commit 5fa5836

Please sign in to comment.