Updated Login Module.

- OAUTH LOGIN: is generic based on a new OAUTH_20_GENERIC_API
        - Storage (at the moment only SQL) for OAUTH_CONSUMER configuration.
        - OAUTH login and callback are generic.
        - Added a OAUTH_20_GENERIC_API.
        - Added scripts and templates to build the new OAUTH tables.
        - Fixed CMS_STORAGE_SQL_I.check_sql_query_validity issue.
        - Extended CMS_STORAGE_SQL_I, to execute scripts with paramerters.
        - Updated filter, now it's generic for every OAUTH consumer.
This commit is contained in:
jvelilla
2015-06-11 10:01:36 -03:00
parent f652aa8a15
commit 18732a9532
16 changed files with 688 additions and 154 deletions

View File

@@ -0,0 +1,20 @@
BEGIN;
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")
);
COMMIT;

View File

@@ -0,0 +1,11 @@
BEGIN;
-- 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");
COMMIT;

View File

@@ -1,9 +1,9 @@
BEGIN;
CREATE TABLE "oauth2_gmail"(
CREATE TABLE :table_name (
"uid" INTEGER PRIMARY KEY NOT NULL CHECK("uid">=0),
"access_token" VARCHAR(255) NOT NULL,
"access_token" TEXT NOT NULL,
"created" DATETIME NOT NULL,
"details" TEXT NOT NULL,
CONSTRAINT "uid"

View File

@@ -1,4 +1,4 @@
<div>
<div class="primary-tabs">
{unless isset="$user"}
<h3>Login or <a href="/account/roc-register">Register</a></h3>
<div>
@@ -26,7 +26,9 @@
</div>
</div>
<div>
<a href="/account/login-with-google"><img src="http://qpleple.com/img/post-how-to-make-people-login-into-your-website-with-their-google-account/signin-google-3.png"></a>
{foreach item="item" from="$oauth_consumers"}
<a href="/account/login-with-oauth/{$item/}">Login with {$item/}</a><br>
{/foreach}
</div>
{/unless}
</div>

View File

@@ -57,7 +57,7 @@
<!-- Main Content Section -->
{unless isempty="$page_title"}<h1 class="page-title">{$page_title/}</h1>{/unless}
{$page.region_content/}
</div>
</div>
</div>