Skip to content

hzh11012/qnets-sso

Repository files navigation

Qnets SSO Serve

Qnets SSO Server, Based on Koa + Prisma + JWT

English · 中文

Introduction

  • 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.

Completed API

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

Technology Stack

  • koa2
  • prisma
  • zod
  • eslint + prettier
  • module-alias
  • mysql

Project Structure

Directory Structure


├─app
   ├─api
   ├─dao
   ├─service
   └─validators
├─core
├─doc
├─middleware
├─prisma
├─app.js
└─...

Configuration

Environment Variables

Incomplete environment variables will result in service unavailability. Please go to supplement.

Env

  • NODE_PORT:Service port, default 4800
  • DATABASE_URL:Prisma MySQL connection URL, format mysql://USER:PASSWORD @HOST: PORT/DATABASE
  • ACCESS_TOKEN_SECRET_KEY:Access token secret key
  • REFRESH_TOKEN_SECRET_KEY:Refresh token secret key
  • ACCESS_TOKEN_EXPIRES_IN:Access token expiration time, default 1 hour
  • REFRESH_TOKEN_EXPIRES_IN:Refresh token expiration time, default 7 day
  • SMS_APP_ID:Tencent Cloud SMS Application ID
  • SMS_SIGN_NAME:Tencent Cloud SMS Signature Content
  • SMS_TEMPLATE_ID:Tencent Cloud SMS Template ID
  • SMS_SECRET_ID:Tencent Cloud SMS SecretId
  • SMS_SECRET_KEY:Tencent Cloud SMS SecretKey
  • SMS_REGION:Tencent Cloud SMS Region
  • COOKIES_DOMAIN:The effective domain of cookies

Quick Start

$ git clone https://github.com/hzh11012/qnets-sso.git

## Install dependencies
$ yarn

## Run
$ yarn dev

Star History

Star History Chart

Contributors

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published