- This project is only a single sign on server, and users only need to log in once to access all Qnets projects, and support login free for 7 days.
The interface has no special instructions and must carry a token for authentication.
Select Authorization and Bearer Token for Type in Postman software, and fill in the token value.
Token needs to be carried on the header in the code
// Transcoding token
function _encode() {
const token = localStorage.getItem('token');
return 'Bearer ' + token;
}
// Code example: Focus on header carrying Authorization Bearer+token
ajax({
url: 'http://localhost:4800/api/sso/login',
method: 'GET',
success: res => {
console.log(res.data);
},
header: {
Authorization: _encode()
}
});
// Carrying tokens on Axios
config.headers['Authorization'] = _encode();
Please refer to the specific interfaces of each module for details API Document
- koa2
- prisma
- zod
- eslint + prettier
- module-alias
- mysql
│
├─app
├─api
├─dao
├─service
└─validators
├─core
├─doc
├─middleware
├─prisma
├─app.js
└─...
Incomplete environment variables will result in service unavailability. Please go to supplement.
NODE_PORT
:Service port, default4800
DATABASE_URL
:Prisma MySQL connection URL, format mysql://USER:PASSWORD @HOST: PORT/DATABASEACCESS_TOKEN_SECRET_KEY
:Access token secret keyREFRESH_TOKEN_SECRET_KEY
:Refresh token secret keyACCESS_TOKEN_EXPIRES_IN
:Access token expiration time, default1 hour
REFRESH_TOKEN_EXPIRES_IN
:Refresh token expiration time, default7 day
SMS_APP_ID
:Tencent Cloud SMS Application IDSMS_SIGN_NAME
:Tencent Cloud SMS Signature ContentSMS_TEMPLATE_ID
:Tencent Cloud SMS Template IDSMS_SECRET_ID
:Tencent Cloud SMS SecretIdSMS_SECRET_KEY
:Tencent Cloud SMS SecretKeySMS_REGION
:Tencent Cloud SMS RegionCOOKIES_DOMAIN
:The effective domain of cookies
$ git clone https://github.com/hzh11012/qnets-sso.git
## Install dependencies
$ yarn
## Run
$ yarn dev