From b2baef0643c9c108f680ab9c6369a45840383622 Mon Sep 17 00:00:00 2001 From: yubo Date: Tue, 10 Nov 2020 13:23:37 +0800 Subject: [PATCH] Auth with SSO (#387) * add logout v2 for sso * support sms-code login * use db instead of memory cache for login code * feature: support reset password by sms code * remove deprecated api/code * feature: support image captcha * use db instead of memory cache for sso.auth.state * add authLogin for login, v1/login; support (*)[.local].tpl for tpl file * add username to sms-code api * disable captcha by default in rdb.yml --- control | 2 +- etc/rdb.yml | 2 +- sql/n9e_rdb.sql | 15 +++++++-------- sql/n9e_rdb_3.3.0.sql | 30 ++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 sql/n9e_rdb_3.3.0.sql diff --git a/control b/control index 26b2fe12..79f9615a 100755 --- a/control +++ b/control @@ -1,7 +1,7 @@ #!/bin/bash # release version -version=3.2.0 +version=3.3.0 CWD=$(cd $(dirname $0)/; pwd) cd $CWD diff --git a/etc/rdb.yml b/etc/rdb.yml index e2b31aba..f214cbf7 100644 --- a/etc/rdb.yml +++ b/etc/rdb.yml @@ -24,7 +24,7 @@ sso: coverAttributes: false stateExpiresIn: 300 -captcha: true +captcha: false tokens: - rdb-builtin-token diff --git a/sql/n9e_rdb.sql b/sql/n9e_rdb.sql index 53aeaf4c..f0100531 100644 --- a/sql/n9e_rdb.sql +++ b/sql/n9e_rdb.sql @@ -297,18 +297,17 @@ CREATE TABLE `login_code` DEFAULT CHARSET = utf8; CREATE TABLE `auth_state` ( - `state` varchar(128) DEFAULT '' NOT NULL, - `typ` varchar(32) DEFAULT '' NOT NULL COMMENT 'response_type', - `redirect` varchar(1024) DEFAULT '' NOT NULL, - `expires_at` bigint DEFAULT '0' NOT NULL, + `state` varchar(128) DEFAULT '' NOT NULL, + `typ` varchar(32) DEFAULT '' NOT NULL COMMENT 'response_type', + `redirect` varchar(1024) DEFAULT '' NOT NULL, + `expires_at` bigint DEFAULT '0' NOT NULL, PRIMARY KEY (`state`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; - CREATE TABLE `captcha` ( - `captcha_id` varchar(128) NOT NULL, - `answer` varchar(128) DEFAULT '' NOT NULL, - `created_at` bigint DEFAULT '0' NOT NULL, + `captcha_id` varchar(128) NOT NULL, + `answer` varchar(128) DEFAULT '' NOT NULL, + `created_at` bigint DEFAULT '0' NOT NULL, KEY (`captcha_id`, `answer`), KEY (`created_at`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; diff --git a/sql/n9e_rdb_3.3.0.sql b/sql/n9e_rdb_3.3.0.sql new file mode 100644 index 00000000..aecfc11e --- /dev/null +++ b/sql/n9e_rdb_3.3.0.sql @@ -0,0 +1,30 @@ +set names utf8; +use n9e_rdb; + +CREATE TABLE `login_code` +( + `username` varchar(64) not null comment 'login name, cannot rename', + `code` varchar(32) not null, + `login_type` varchar(32) not null, + `created_at` bigint not null comment 'created at', + KEY (`code`), + KEY (`created_at`), + UNIQUE KEY (`username`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8; + +CREATE TABLE `auth_state` ( + `state` varchar(128) DEFAULT '' NOT NULL, + `typ` varchar(32) DEFAULT '' NOT NULL COMMENT 'response_type', + `redirect` varchar(1024) DEFAULT '' NOT NULL, + `expires_at` bigint DEFAULT '0' NOT NULL, + PRIMARY KEY (`state`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + +CREATE TABLE `captcha` ( + `captcha_id` varchar(128) NOT NULL, + `answer` varchar(128) DEFAULT '' NOT NULL, + `created_at` bigint DEFAULT '0' NOT NULL, + KEY (`captcha_id`, `answer`), + KEY (`created_at`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8;