Giter Club home page Giter Club logo

awsl-auth's Introduction

Awsl Auth

Deploy with Vercel

sequenceDiagram
    User->>ClentServer: cilck login
    ClentServer->>AwslAuth: redirect to awsl-auth login page
    User->>AwslAuth: chose login type
    AwslAuth->>LoginProvider: redirect to login provider login page
    User->>LoginProvider: cilck login
    LoginProvider->>AwslAuth: redirect with Provider's code
    AwslAuth ->> LoginProvider: request user info with Provider's code
    AwslAuth->>ClentServer: redirect to website with awsl's code
    ClentServer->>AwslAuth: request JWT with awsl's code
    AwslAuth->>ClentServer: verify awsl's code and return JWT
    ClentServer->>User: return JWT and login success

Usage

config app_id app_secret redirect_url in .env or ENV.

  1. redirect to https://auth.awsl.icu/login?app_id=demo

  2. after login, will redirect to <yourwebsiteredirect_url>?code=<awsl's code>

  3. request JWT with POST to https://auth.awsl.icu/api/token with code, app_id and app_secret in body

    const { jwt } = await api.fetch("/api/token", {
        method: "POST",
        message: message,
        body: JSON.stringify({
            app_id: "demo",
            app_secret: "demo_secret",
            code: code,
        })
    });
  4. choose one of the following ways to use jwt

    1. just use the jwt in your browser and decode by app_secret

    2. or request with jwt to get user info

     user = await api.fetch(`/api/info?app_id=${app_id}`, {
            message: message,
            headers: {
                'Authorization': `Bearer ${jwtSession.value}`,
                'Content-Type': 'application/json',
            }
        });

Deloy

Vercel 配置

enabled_db=false
supabase_api_url=
supabase_api_key=

upstash_api_url=
upstash_api_token=

enabled_smtp=false
smtp_url=smtp://username:[email protected]:587

cf_turnstile_site_key=
cf_turnstile_secret_key=

github_client_id=
github_client_secret=
google_client_id=
google_client_secret=
ms_client_id=
ms_client_secret=

app_settings__0__app_id=demo
app_settings__0__app_secret=demo_secret
app_settings__0__redirect_url=
app_settings__1__app_id=app2
app_settings__1__app_secret=app_secret2
app_settings__1__redirect_url=http://localhost:5000/callback

Docker

使用 docker-compose.yml 部署

services:
  awsl-auth:
    image: ghcr.io/dreamhunter2333/awsl-auth:latest
    container_name: "awsl-auth"
    ports:
      - "8000:8000"
    volumes:
      - ./data:/data
    environment:
      # 数据库
      - enabled_db=true
      - db_client_type=sqlite
      - sqlite_db_url=sqlite:////data/db.sqlite3
      # cache client type: memory/redis/upstash
      - cache_client_type=redis
      - redis_url=redis://awsl-auth-redis:6379/0
      # 邮件注册
      - enabled_smtp=false
      # - smtp_url=smtp://username:[email protected]:587
      # 邮件注册人机验证
      # - cf_turnstile_site_key=
      # - cf_turnstile_secret_key=
      # 第三方登录
      # - github_client_id=
      # - github_client_secret=
      # - google_client_id=
      # - google_client_secret=
      # - enabled_web3_client=true
      # - ms_client_id=
      # - ms_client_secret=
      # 登录App设置
      - app_settings__0__app_id=demo
      - app_settings__0__app_secret=demo_secret
      - app_settings__0__redirect_url=
      - app_settings__1__app_id=app2
      - app_settings__1__app_secret=app_secret2
      - app_settings__1__redirect_url=http://localhost:5000/callback

    depends_on:
      - awsl-auth-redis

  awsl-auth-redis:
    image: "redis:alpine"
    container_name: "awsl-auth-redis"
    ports:
      - "6379:6379"

awsl-auth's People

Contributors

dreamhunter2333 avatar dependabot[bot] avatar

Stargazers

HeisenBerg? avatar  avatar 我的名字叫浩仔 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.