Made CMS_MODULE.name deferred, and implemented by constant so that it can be use as static call.

Copied site resources on related module source folder.
Renamed "login" module as "auth" module, and updated related locations and files.
This commit is contained in:
2015-06-29 16:24:17 +02:00
parent 48b0ad5195
commit ebc5924c01
56 changed files with 789 additions and 249 deletions

View File

@@ -21,7 +21,7 @@ feature {NONE} -- Initialization
s: detachable READABLE_STRING_32
l_contact_email, l_subject_register, l_subject_activate, l_subject_password, l_subject_oauth: detachable READABLE_STRING_8
do
setup := a_cms_api.setup
cms_api := a_cms_api
-- Use global smtp setting if any, otherwise "localhost"
smtp_server := utf.escaped_utf_32_string_to_utf_8_string_8 (a_cms_api.setup.text_item_or_default ("smtp", "localhost"))
l_site_name := utf.escaped_utf_32_string_to_utf_8_string_8 (a_cms_api.setup.site_name)
@@ -31,7 +31,7 @@ feature {NONE} -- Initialization
admin_email := l_site_name + " <" + admin_email +">"
end
if attached {CONFIG_READER} a_cms_api.module_configuration_by_name ("login", Void) as cfg then
if attached {CONFIG_READER} a_cms_api.module_configuration_by_name ({CMS_AUTHENTICATION_MODULE}.name, Void) as cfg then
if attached cfg.text_item ("smtp") as l_smtp then
-- Overwrite global smtp setting if any.
smtp_server := utf.utf_32_string_to_utf_8_string_8 (l_smtp)
@@ -133,7 +133,7 @@ feature {NONE} -- Implementation: Template
template_path (a_name: READABLE_STRING_GENERAL): PATH
-- Location of template named `a_name'.
do
Result := setup.environment.config_path.extended ("modules").extended ("login").extended (a_name)
Result := cms_api.module_location_by_name ({CMS_AUTHENTICATION_MODULE}.name).extended (a_name)
end
template_string (a_name: READABLE_STRING_GENERAL; a_default: STRING): STRING
@@ -151,7 +151,7 @@ feature {NONE} -- Implementation: Template
feature {NONE} -- Implementation
setup: CMS_SETUP
cms_api: CMS_API
read_template_file (a_path: PATH): detachable STRING
-- Read the content of the file at path `a_path'.

View File

@@ -47,7 +47,6 @@ feature {NONE} -- Initialization
make
-- Create current module
do
name := "oauth20"
version := "1.0"
description := "OAuth20 module"
package := "Oauth20"
@@ -56,6 +55,10 @@ feature {NONE} -- Initialization
cache_duration := 0
end
feature -- Access
name: STRING = "oauth20"
feature {CMS_API} -- Module Initialization
initialize (a_api: CMS_API)

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="oauth_module" uuid="D64B990F-B51F-4E0D-AB2E-4AA5DDB783CE" library_target="oauth_module">
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="oauth_module" uuid="D64B990F-B51F-4E0D-AB2E-4AA5DDB783CE" library_target="oauth_module">
<target name="oauth_module">
<root all_classes="true"/>
<file_rule>
@@ -12,6 +12,7 @@
<library name="apis" location="$ISE_LIBRARY\contrib\library\web\authentication\oauth\cypress\consumer\apis\apis.ecf" readonly="false"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="cms" location="$ISE_LIBRARY\unstable\library\web\cms\cms-safe.ecf" readonly="false"/>
<library name="cms_auth_module" location="..\auth\auth-safe.ecf" readonly="false"/>
<library name="cms_app_env" location="$ISE_LIBRARY\unstable\library\web\cms\library\app_env\app_env-safe.ecf" readonly="false"/>
<library name="cms_model" location="$ISE_LIBRARY\unstable\library\web\cms\library\model\cms_model-safe.ecf" readonly="false"/>
<library name="config" location="$ISE_LIBRARY\unstable\library\web\cms\library\configuration\config-safe.ecf"/>

View File

@@ -0,0 +1,18 @@
CREATE TABLE oauth2_consumers(
`cid` INTEGER PRIMARY KEY NOT NULL CHECK(`cid`>=0),
`name` VARCHAR(255) NOT NULL,
`api_secret` TEXT NOT NULL,
`api_key` TEXT NOT NULL,
`scope` VARCHAR (100) NOT NULL,
`protected_resource_url` VARCHAR (255) NOT NULL,
`callback_name` VARCHAR(255) NOT NULL,
`extractor` VARCHAR(50) NOT NULL,
`authorize_url` VARCHAR (255) NOT NULL,
`endpoint` VARCHAR (255) NOT NULL,
CONSTRAINT `cid`
UNIQUE(`cid`),
CONSTRAINT `name`
UNIQUE(`name`)
);

View File

@@ -0,0 +1,7 @@
-- Change the values TO_COMPLETE based on your API.
-- API SECTET KEY AND API PUBLIC KEY
INSERT INTO oauth2_consumers (name, api_secret, api_key, scope, protected_resource_url, callback_name, extractor, authorize_url, endpoint)
VALUES ('google', 'TO-COMPLETE', 'TO-COMPLETE', 'email', 'https://www.googleapis.com/plus/v1/people/me', 'callback_google', 'json','https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URI','https://accounts.google.com/o/oauth2/token');
INSERT INTO oauth2_consumers (name, api_secret, api_key, scope, protected_resource_url, callback_name, extractor, authorize_url, endpoint )
VALUES ('facebook', 'TO-COMPLETE', 'TO-COMPLETE', 'email', 'https://graph.facebook.com/me', 'callback_facebook','text','https://www.facebook.com/dialog/oauth?response_type=code&client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URI','https://graph.facebook.com/oauth/access_token');

View File

@@ -0,0 +1,10 @@
CREATE TABLE $table_name (
`uid` INTEGER PRIMARY KEY NOT NULL CHECK(`uid`>=0),
`access_token` TEXT NOT NULL,
`created` DATETIME NOT NULL,
`details` TEXT NOT NULL,
CONSTRAINT `uid`
UNIQUE(`uid`)
);

View File

@@ -0,0 +1,7 @@
<div class="primary-tabs">
<div>
{foreach item="item" from="$oauth_consumers"}
<a href="{$site_url/}account/login-with-oauth/{$item/}">Login with {$item/}</a><br>
{/foreach}
</div>
</div>