OpenID consumer implementation
REQUIRES EiffelStudio 7.2
This commit is contained in:
148
draft/library/security/openid/consumer/demo/application.e
Normal file
148
draft/library/security/openid/consumer/demo/application.e
Normal file
@@ -0,0 +1,148 @@
|
||||
note
|
||||
description : "OPENID demo application root class"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
class
|
||||
APPLICATION
|
||||
|
||||
inherit
|
||||
WSF_URI_TEMPLATE_ROUTED_SERVICE
|
||||
|
||||
WSF_SERVICE
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_and_launch
|
||||
local
|
||||
launcher: WSF_NINO_SERVICE_LAUNCHER
|
||||
opts: WSF_SERVICE_LAUNCHER_OPTIONS
|
||||
do
|
||||
initialize_router
|
||||
|
||||
create opts.make
|
||||
opts.set_verbose (True)
|
||||
opts.set_option ("port", 0)
|
||||
create launcher.make (Current, opts)
|
||||
launcher.on_launched_actions.extend (agent on_launched)
|
||||
launcher.launch
|
||||
end
|
||||
|
||||
on_launched (conn: WGI_CONNECTOR)
|
||||
local
|
||||
e: EXECUTION_ENVIRONMENT
|
||||
do
|
||||
if attached {WGI_NINO_CONNECTOR} conn as nino then
|
||||
create e
|
||||
if attached e.item ("COMSPEC") as l_comspec then
|
||||
e.launch (l_comspec + " /C start " + "http://localhost:" + nino.port.out + "/")
|
||||
else
|
||||
e.launch ("http://localhost:" + nino.port.out + "/")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
setup_router
|
||||
do
|
||||
map_uri_template_agent ("/", agent handle_root)
|
||||
map_uri_template_agent ("/openid", agent handle_openid)
|
||||
end
|
||||
|
||||
handle_root (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
m: WSF_HTML_PAGE_RESPONSE
|
||||
s: STRING
|
||||
do
|
||||
create m.make
|
||||
m.set_title ("EWF::OpenID demo")
|
||||
create s.make_empty
|
||||
s.append ("<form action=%"" + req.script_url ("/openid") + "%" method=%"POST%">%N")
|
||||
s.append ("<strong>OpenID identifier</strong> <input type='text' name='openid_identifier' value='' size='60'/>")
|
||||
s.append ("<input type='submit' name='op' value='sign with OpenID' />")
|
||||
s.append ("</form>%N")
|
||||
s.append ("<form action=%"" + req.script_url ("/openid") + "%" method=%"POST%">%N")
|
||||
s.append ("<strong>OpenID identifier</strong> <input type='text' name='openid_identifier' value='https://www.google.com/accounts/o8/id' size='60'/>")
|
||||
s.append ("<input type='submit' name='op' value='sign with Google' />")
|
||||
s.append ("</form>%N")
|
||||
m.set_body (s)
|
||||
res.send (m)
|
||||
end
|
||||
|
||||
handle_openid (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
m: WSF_HTML_PAGE_RESPONSE
|
||||
redir: WSF_HTML_DELAYED_REDIRECTION_RESPONSE
|
||||
s: STRING
|
||||
o: OPENID_CONSUMER
|
||||
v: OPENID_CONSUMER_VALIDATION
|
||||
do
|
||||
if attached req.string_item ("openid.mode") as l_openid_mode then
|
||||
create m.make
|
||||
m.set_title ("EWF::OpenID demo")
|
||||
create s.make_empty
|
||||
|
||||
if l_openid_mode.same_string ("id_res") then
|
||||
o := new_openid_consumer (req)
|
||||
create v.make_from_string (o, req.absolute_script_url (req.request_uri))
|
||||
v.validate
|
||||
if v.is_valid then
|
||||
s.append ("<div>User authenticated</div>")
|
||||
s.append ("<ul>Query")
|
||||
across
|
||||
req.query_parameters as c
|
||||
loop
|
||||
s.append ("<li>" + c.item.url_encoded_name + "=" + c.item.string_representation + "</li>")
|
||||
end
|
||||
s.append ("</ul>")
|
||||
s.append ("<ul>Attributes")
|
||||
across
|
||||
v.attributes as c
|
||||
loop
|
||||
s.append ("<li>" + c.key + "=" + c.item + "</li>")
|
||||
end
|
||||
s.append ("</ul>")
|
||||
else
|
||||
s.append ("<div>User authentication failed!!!</div>")
|
||||
end
|
||||
else
|
||||
s.append ("<div>Unexpected OpenID.mode=" + l_openid_mode + "</div>")
|
||||
end
|
||||
m.set_body (s)
|
||||
res.send (m)
|
||||
elseif attached req.string_item ("openid_identifier") as l_id then
|
||||
create s.make_empty
|
||||
|
||||
o := new_openid_consumer (req)
|
||||
s.append ("Testing " + l_id + "<br>%N")
|
||||
s.append ("Return-to" + o.return_url + "<br>")
|
||||
if attached o.auth_url (l_id) as l_auth_url then
|
||||
s.append ("<a href=%""+ l_auth_url + "%">Click to sign with " + l_id + "</a><br>")
|
||||
create redir.make (l_auth_url, 1)
|
||||
s.append ("Automatically follow link in " + redir.delay.out + " second(s)<br>")
|
||||
redir.set_title ("EWF::OpenID demo")
|
||||
redir.set_body (s)
|
||||
res.send (redir)
|
||||
else
|
||||
create m.make
|
||||
m.set_title ("EWF::OpenID demo")
|
||||
m.set_body (s)
|
||||
res.send (m)
|
||||
end
|
||||
else
|
||||
res.redirect_now ("/")
|
||||
end
|
||||
end
|
||||
|
||||
new_openid_consumer (req: WSF_REQUEST): OPENID_CONSUMER
|
||||
do
|
||||
create Result.make (req.absolute_script_url ("/openid"))
|
||||
|
||||
-- Result.ask_email (True)
|
||||
Result.ask_nickname (False)
|
||||
-- Result.ask_fullname (False)
|
||||
Result.ask_country (True)
|
||||
end
|
||||
end
|
||||
23
draft/library/security/openid/consumer/demo/demo-safe.ecf
Normal file
23
draft/library/security/openid/consumer/demo/demo-safe.ecf
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-10-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-10-0 http://www.eiffel.com/developers/xml/configuration-1-10-0.xsd" name="demo" uuid="DC4D6549-D5F4-4E1A-959A-6BD536737A21" library_target="demo">
|
||||
<target name="demo">
|
||||
<root class="APPLICATION" feature="make_and_launch"/>
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="concurrency" value="thread"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="http" location="..\..\..\..\network\protocol\http\http-safe.ecf"/>
|
||||
<library name="wsf_nino_connector" location="..\..\..\..\server\wsf\connector\nino-safe.ecf" readonly="false"/>
|
||||
<library name="ewsgi" location="..\..\..\..\server\ewsgi\ewsgi-safe.ecf" readonly="false"/>
|
||||
<library name="ewsgi_nino_connector" location="..\..\..\..\server\ewsgi\connectors\nino\nino-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="..\..\..\..\server\wsf\wsf-safe.ecf"/>
|
||||
<library name="openid" location="../openid-safe.ecf" readonly="false"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
6
draft/library/security/openid/consumer/demo/demo.rc
Normal file
6
draft/library/security/openid/consumer/demo/demo.rc
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <windows.h>
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
1 "This Program was made using EiffelStudio using Visual Studio C++"
|
||||
END
|
||||
Reference in New Issue
Block a user