Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: d8197524f4
Fetching contributors…

Cannot retrieve contributors at this time

74 lines (62 sloc) 1.462 kB
module Hancock
module TestApp
module Helpers
def landing_page
<<-HAML
%h2 Hello #{session_user.inspect}!
HAML
end
def unauthenticated
<<-HAML
%fieldset
%legend You need to log in, buddy.
%form{:action => '/sso/login', :method => 'POST'}
%label{:for => 'email'}
Email:
%input{:type => 'text', :name => 'email'}
%br
%label{:for => 'password'}
Password:
%input{:type => 'password', :name => 'password'}
%br
%input{:type => 'submit', :value => 'Login'}
or
%a{:href => '/sso/signup'} Signup
HAML
end
end
def self.registered(app)
app.helpers Helpers
app.get '/' do
ensure_authenticated
haml landing_page
end
end
def self.app
@app ||= Rack::Builder.new do
use Rack::Session::Cookie
run SsoServer
end
end
class SsoServer < ::Hancock::SSO::App
enable :raise_errors
disable :show_exceptions
error Hancock::SSO::Unauthenticated do
haml(unauthenticated)
end
error Hancock::SSO::Forbidden do
throw(:halt, [403, "Forbidden"])
end
error Hancock::SSO::BadRequest do
throw(:halt, [400, "Bad Request"])
end
error Hancock::SSO::LogMeOut do
redirect "/"
end
error Hancock::SSO::RouteMeHome do
redirect "/"
end
register(Hancock::TestApp)
end
end
end
Jump to Line
Something went wrong with that request. Please try again.