Skip to content

Commit 359344c

Browse files
committed
Fixed link for Oauth sign with.
Added administration pages for OAuth20 module.
1 parent b814c91 commit 359344c

16 files changed

+277
-231
lines changed

examples/demo/demo.ecf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,17 @@
2020
</option>
2121
</library>
2222
<library name="cms_admin_module" location="..\..\modules\admin\admin-safe.ecf" readonly="false"/>
23-
<library name="cms_app_env" location="..\..\library\app_env\app_env-safe.ecf" readonly="false"/>
2423
<library name="cms_auth_module" location="..\..\modules\auth\auth-safe.ecf" readonly="false"/>
2524
<library name="cms_basic_auth_module" location="..\..\modules\basic_auth\basic_auth-safe.ecf" readonly="false"/>
2625
<library name="cms_blog_module" location="..\..\modules\blog\cms_blog_module-safe.ecf" readonly="false"/>
2726
<library name="cms_comments_module" location="..\..\modules\comments\comments-safe.ecf" readonly="false"/>
2827
<library name="cms_contact_module" location="..\..\modules\contact\contact-safe.ecf" readonly="false"/>
2928
<library name="cms_custom_block_module" location="..\..\modules\custom_block\custom_block-safe.ecf" readonly="false"/>
3029
<library name="cms_demo_module" location="modules\demo\cms_demo_module-safe.ecf" readonly="false"/>
31-
<library name="cms_email_service" location="..\..\library\email\email-safe.ecf" readonly="false"/>
3230
<library name="cms_feed_aggregator_module" location="..\..\modules\feed_aggregator\feed_aggregator-safe.ecf" readonly="false"/>
3331
<library name="cms_files_module" location="..\..\modules\files\files-safe.ecf" readonly="false"/>
3432
<library name="cms_google_search_20_module" location="..\..\modules\google_search_20\google_search_20-safe.ecf" readonly="false" use_application_options="true"/>
3533
<library name="cms_messaging_module" location="..\..\modules\messaging\messaging-safe.ecf" readonly="false"/>
36-
<library name="cms_model" location="..\..\library\model\cms_model-safe.ecf" readonly="false"/>
3734
<library name="cms_node_module" location="..\..\modules\node\node-safe.ecf" readonly="false"/>
3835
<library name="cms_oauth_20_module" location="..\..\modules\oauth20\oauth20-safe.ecf" readonly="false"/>
3936
<library name="cms_openid_module" location="..\..\modules\openid\openid-safe.ecf" readonly="false"/>
@@ -42,7 +39,7 @@
4239
<library name="cms_sitemap_module" location="..\..\modules\sitemap\sitemap-safe.ecf" readonly="false"/>
4340
<library name="cms_session_auth_module" location="..\..\modules\session_auth\cms_session_auth-safe.ecf" readonly="false"/>
4441
<library name="masquerade_auth_module" location="..\..\dev_modules\masquerade_auth\masquerade_auth-safe.ecf" readonly="false"/>
45-
<library name="cms_taxnomy_module" location="..\..\modules\taxonomy\taxonomy-safe.ecf" readonly="false"/>
42+
<library name="cms_taxonomy_module" location="..\..\modules\taxonomy\taxonomy-safe.ecf" readonly="false"/>
4643
<library name="embedded_video_module" location="..\..\modules\embedded_video\embedded_video-safe.ecf" readonly="false"/>
4744
<library name="cms_wikitext_module" location="..\..\modules\wikitext\wikitext-safe.ecf" readonly="false"/>
4845
<library name="persistence_sqlite3" location="..\..\library\persistence\sqlite3\sqlite3-safe.ecf" readonly="false"/>

examples/demo/launcher/any/application_launcher.e

Lines changed: 0 additions & 19 deletions
This file was deleted.

examples/demo/launcher/any/application_launcher_i.e

Lines changed: 0 additions & 127 deletions
This file was deleted.

examples/demo/launcher/default/application_launcher.e

Lines changed: 0 additions & 19 deletions
This file was deleted.

examples/demo/launcher/default/application_launcher_i.e

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="primary-tabs">
22
<div>
33
{foreach item="item" from="$oauth_consumers"}
4-
<a href="{$site_url/}account/login-with-oauth/{$item/}">Login with {$item/}</a><br>
4+
<a href="{$site_url/}account/auth/login-with-oauth/{$item/}">Login with {$item/}</a><br>
55
{/foreach}
66
</div>
77
</div>

modules/oauth20/cms_oauth_20_api.e

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,38 +83,41 @@ feature -- Access: Consumers OAuth20
8383
Result := oauth_20_storage.oauth2_consumers
8484
end
8585

86-
oauth_consumer_by_name (a_name: READABLE_STRING_8): detachable CMS_OAUTH_20_CONSUMER
86+
oauth_consumer_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_OAUTH_20_CONSUMER
8787
-- Retrieve a consumer by name `a_name', if any.
8888
do
8989
Result := oauth_20_storage.oauth_consumer_by_name (a_name)
9090
end
9191

92-
oauth_consumer_by_callback (a_callback: READABLE_STRING_8): detachable CMS_OAUTH_20_CONSUMER
92+
oauth_consumer_by_callback (a_callback: READABLE_STRING_GENERAL): detachable CMS_OAUTH_20_CONSUMER
9393
-- Retrieve a consumer by callback `a_callback', if any.
9494
do
9595
Result := oauth_20_storage.oauth_consumer_by_callback (a_callback)
9696
end
9797

9898
feature -- Change: User OAuth20
9999

100-
new_user_oauth2 (a_token: READABLE_STRING_GENERAL; a_user_profile: READABLE_STRING_32; a_user: CMS_USER; a_consumer: READABLE_STRING_GENERAL)
100+
save_oauth_consumer (a_cons: CMS_OAUTH_20_CONSUMER)
101+
do
102+
oauth_20_storage.save_oauth_consumer (a_cons)
103+
end
104+
105+
new_user_oauth2 (a_token: READABLE_STRING_GENERAL; a_user_profile: READABLE_STRING_GENERAL; a_user: CMS_USER; a_consumer: READABLE_STRING_GENERAL)
101106
-- Add a new user with oauth20 using the consumer `a_consumer'.
102107
require
103108
has_id: a_user.has_id
104109
do
105110
oauth_20_storage.new_user_oauth2 (a_token, a_user_profile, a_user, a_consumer)
106111
end
107112

108-
109-
update_user_oauth2 (a_token: READABLE_STRING_GENERAL; a_user_profile: READABLE_STRING_32; a_user: CMS_USER; a_consumer_table: READABLE_STRING_GENERAL)
113+
update_user_oauth2 (a_token: READABLE_STRING_GENERAL; a_user_profile: READABLE_STRING_GENERAL; a_user: CMS_USER; a_consumer_table: READABLE_STRING_GENERAL)
110114
-- Update user `a_user' with oauth2 for the consumer `a_consumer'.
111115
require
112116
has_id: a_user.has_id
113117
do
114118
oauth_20_storage.update_user_oauth2 (a_token, a_user_profile, a_user, a_consumer_table)
115119
end
116120

117-
118121
remove_user_oauth2 (a_user: CMS_USER; a_consumer_table: READABLE_STRING_GENERAL)
119122
-- Remove user `a_user' with oauth2 for the consumer `a_consumer'.
120123
require

modules/oauth20/cms_oauth_20_consumer.e

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,18 @@ feature {NONE} -- Initialization
3838
set_name ("")
3939
end
4040

41+
feature -- Status report
42+
43+
has_id: BOOLEAN
44+
do
45+
Result := id > 0
46+
end
47+
4148
feature -- Access
4249

50+
id: INTEGER_64
51+
-- unique identifier.
52+
4353
endpoint: READABLE_STRING_8
4454
-- Url that receives the access token request.
4555

@@ -68,9 +78,6 @@ feature -- Access
6878
name: READABLE_STRING_32
6979
-- consumer name.
7080

71-
id: INTEGER_64
72-
-- unique identifier.
73-
7481
feature -- Element change
7582

7683
set_extractor (a_extractor: like extractor)

modules/oauth20/cms_oauth_20_module.e

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ inherit
2121
oauth20_api
2222
end
2323

24+
CMS_ADMINISTRABLE
25+
2426
CMS_HOOK_BLOCK
2527

2628
SHARED_EXECUTION_ENVIRONMENT
@@ -50,6 +52,13 @@ feature -- Access
5052

5153
name: STRING = "oauth20"
5254

55+
feature {CMS_EXECUTION} -- Administration
56+
57+
administration: CMS_OAUTH_20_MODULE_ADMINISTRATION
58+
do
59+
create Result.make (Current)
60+
end
61+
5362
feature {CMS_API} -- Module Initialization
5463

5564
initialize (a_api: CMS_API)
@@ -130,7 +139,7 @@ feature {CMS_API} -- Module management
130139
end
131140
end
132141

133-
feature {CMS_API} -- Access: API
142+
feature {CMS_API, CMS_MODULE_ADMINISTRATION} -- Access: API
134143

135144
oauth20_api: detachable CMS_OAUTH_20_API
136145
-- <Precursor>
@@ -280,7 +289,7 @@ feature -- Hooks
280289
attached {WSF_STRING} req.cookie (a_oauth20_api.session_token) as l_cookie_token
281290
then
282291
-- Logout OAuth
283-
create l_cookie.make (a_oauth20_api.session_token, l_cookie_token.value)
292+
create l_cookie.make (a_oauth20_api.session_token, l_cookie_token.url_encoded_value)
284293
l_cookie.set_path ("/")
285294
l_cookie.set_max_age (-1)
286295
res.add_cookie (l_cookie)
@@ -386,7 +395,8 @@ feature -- OAuth2 Login with Provider
386395
l_cookie: WSF_COOKIE
387396
es: CMS_AUTHENTICATION_EMAIL_SERVICE
388397
do
389-
if attached {WSF_STRING} req.path_parameter (oauth_callback_path_parameter) as l_callback and then
398+
if
399+
attached {WSF_STRING} req.path_parameter (oauth_callback_path_parameter) as l_callback and then
390400
attached {CMS_OAUTH_20_CONSUMER} a_oauth_api.oauth_consumer_by_callback (l_callback.value) as l_consumer and then
391401
attached {WSF_STRING} req.query_parameter (oauth_code_query_parameter) as l_code
392402
then
@@ -411,7 +421,7 @@ feature -- OAuth2 Login with Provider
411421
a_oauth_api.update_user_oauth2 (l_access_token.token, l_user_profile, p_user, l_consumer.name )
412422
else
413423
-- create a oauth entry
414-
a_oauth_api.new_user_oauth2 (l_access_token.token, l_user_profile, p_user, l_consumer.name )
424+
a_oauth_api.new_user_oauth2 (l_access_token.token, l_user_profile.to_string_32, p_user, l_consumer.name )
415425
end
416426
create l_cookie.make (a_oauth_api.session_token, l_access_token.token)
417427
l_cookie.set_max_age (l_access_token.expires_in)
@@ -468,7 +478,7 @@ feature -- OAuth2 Login with Provider
468478
attached {WSF_STRING} req.form_parameter ("email") as l_email and then
469479
attached r.user as l_user
470480
then
471-
l_user.set_email (l_email.value)
481+
l_user.set_email (api.utf_8_encoded (l_email.value))
472482
a_oauth_api.new_user_oauth2 ("none", "none", l_user, l_consumer.value )
473483
-- TODO send email?
474484
end

0 commit comments

Comments
 (0)