Commit 0250f492 authored by Lakr Aream's avatar Lakr Aream 👼🏽

更新token有效时间设置

parent 93982a01
......@@ -25,20 +25,22 @@ required:
# Application Config For Backend
app:
port: 3030 # listening at
root: "591F4FF9-D355-44E6-9817-1196F452BB30" # root signing ticket
root: "591f4ff9-d355-44e6-9817-1196f452bb30" # root signing ticket
# changed it to 00000 to disable root sign after setup
accept: # accept connection from
- 0.0.0.0
kikik: 0 # how many second before login token expired, 0 = never
# tips: 3600 = 1hour, 86400 = 1day, 604800 = 1week
use_development_ticket: true # if true
# accept any request
# Database Config For Backend Application
database:
host: "db" # database host name
port: 3306 # database port
host: "iomun.cn" # database host name
port: 15092 # database port
user: "root" # database user name
table: "Candiay" # database table name
pass: "6FAE553E-20AF-49FB-8C34-B76509CABA44" # database password for your user
base: "Candiay" # database name
pass: "00000000" # database password for your user
```
</details>
......@@ -158,7 +160,7 @@ echo $signStr;
TABLE `Candiay`.`users` (
`name` varchar(255) NOT NULL,
`pass` varchar(255) NULL,
`role` varchar(255) DEFAULT user,
`role` varchar(255) NOT NULL,
`token` varchar(255) NULL,
`guard` int NULL,
`actived` int(1) NULL DEFAULT 1,
......
......@@ -10,6 +10,8 @@ app:
# changed it to 00000 to disable root sign after setup
accept: # accept connection from
- 0.0.0.0
kikik: 0 # how many second before login token expired, 0 = never
# tips: 3600 = 1hour, 86400 = 1day, 604800 = 1week
use_development_ticket: true # if true
# accept any request
......
......@@ -15,6 +15,7 @@ export class ConfigManager {
public rootTicket: string | null
public accpetAddr: string[]
public noSign: boolean
public kikik: number
constructor() {
console.log("ConfigManager constructor")
......@@ -27,6 +28,18 @@ export class ConfigManager {
}
this.accpetAddr = this.object.app.accpet
this.noSign = this.object.app.use_development_ticket
if (this.noSign) {
console.log(" -");
console.log("WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING");
console.log(" * Using Development Sign Will Accept Any Request From Anywhere");
console.log("WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING");
console.log(" -");
}
this.kikik = Number(this.object.app.kikik)
if (this.kikik === 0) {
// almost forever (actually 68 years)
this.kikik = 2147483647
}
}
healthCheck() {
......
......@@ -83,7 +83,7 @@ export class DataBase {
let cmd = "CREATE TABLE IF NOT EXISTS `" + this.base + "`.`users` (" + "\n"
cmd += " `name` varchar(255) NOT NULL," + "\n"
cmd += " `pass` varchar(255) NULL," + "\n"
cmd += " `role` varchar(255) DEFAULT user," + "\n"
cmd += " `role` varchar(255) NOT NULL," + "\n"
cmd += " `token` varchar(255) NULL," + "\n"
cmd += " `guard` int NULL," + "\n"
cmd += " `actived` int(1) NULL DEFAULT 1," + "\n"
......@@ -95,7 +95,7 @@ export class DataBase {
CREATE TABLE `Candiay`.`users` (
`name` varchar(255) NOT NULL,
`pass` varchar(255) NULL,
`role` varchar(255) DEFAULT user,
`role` varchar(255) NOT NULL,
`token` varchar(255) NULL,
`guard` int NULL,
`actived` int(1) NULL DEFAULT 1,
......
......@@ -7,9 +7,9 @@ export class RequestManager {
public vaildateRequest(headers: object, params: object, from: string, callback: (isVaildated: boolean) => void) {
// if (ConfigManager.shared.noSign) {
// return true
// }
if (ConfigManager.shared.noSign) {
return true
}
const clientSignResult = headers["x-candiay-sign"]
if (clientSignResult === "" || clientSignResult === undefined || clientSignResult === null) {
......@@ -54,7 +54,7 @@ export class RequestManager {
// Sign is ok, then check timestamp
const current = (new Date()).getTime() / 1000
const gap = current - clientTimeStamp
if (gap < 0 || gap > 60) {
if (gap < 0 || gap > ConfigManager.shared.kikik) {
callback(false)
} else {
callback(true)
......
......@@ -85,6 +85,8 @@ export class UserManager {
})
}
public createUser(name: String, passSHA256: string, role: string) {
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment