Giter Club home page Giter Club logo

whu-library-seat-ghauth's Introduction

.github/workflows/leancloud.yml

whu-library-seat-ghauth

whu-library-seat 后台认证中间件

认证原理

工作流程

  1. 客户端主动建立 Socket 连接,得到 Socket id
  2. 将 Socket id 和其他必要的参数 (比如区分是否是移动端的参数) 嵌入到一个让用户确认是否继续认证的链接中,打开浏览器访问该链接,这个网页需要做的工作是在用户点击确认后,把 Socket id 和其他参数存到本地缓存中,然后访问认证链接 (即 https://github.com/login/oauth/authorize?client_id={Client_ID}&scope=user:email)
  3. 在认证页面,用户确认授权后,网页会被重定向到我们在注册 App 时提供的回调地址,并附带 code 参数,回调地址产生的连接进入阻塞状态,等待服务器返回 access_token
  4. 回调地址对应的后台处理模块将 code 参数、Client IDClient Secret 发送至 GitHub 后台 (链接是:https://github.com/login/oauth/access_token?client_id=${Client_ID}&client_secret=${Client_Secret}&code=${code})
  5. GitHub 后台验证 code 等参数的可用性,如果可用,GitHub 后台会将 access_token 返回给后台服务
  6. 后台得到 access_token 后,将它发送给浏览器 (第 3 步的阻塞状态结束)
  7. 浏览器得到 access_token 后,再将 access_token、缓存的 Socket id 和其他参数发送到后台,然后显示发送成功或失败的信息
  8. 后台相应的处理模块通过这些参数,将 access_token 发送到指定 Socket id 的桌面端

认证步骤

请按照以下步骤登录本软件并获取永久授权

  1. 点击软件下方的钥匙进入软件授权页面(第一次打开软件会默认进入本页面)

    图片加载失败

  2. 点击GitHub Star 永久授权按钮,软件会打开系统浏览器访问认证页面

    图片加载失败

  3. 点击确定通过 GitHub 账号登录,此时 GitHub 会让你确认是否授权(如果没有登录 GitHub,此时会进入登录页面)

    图片加载失败

  4. 点击Authorize CS-Tao即可成功登录

    图片加载失败

  5. 登录成功后返回软件,如果出现下面的弹窗,说明您还未对本仓库点星,请进行下一步

    图片加载失败

  6. 如果您还给本仓库点星,请到指定仓库点星以供管理员了解软件使用情况。桌面端进入:whu-library-seat,移动端进入:whu-library-seat-mobile

    • 桌面端点击右上角的Star按钮,按钮如下图所示:

      图片加载失败

    • 移动端需要登录才会显示Star按钮,登录状态下直接点击即可,按钮如下图所示:

      图片加载失败

  7. 点星后回到本软件,点击确定即可

    图片加载失败

环境变量

# Lean Cloud
LEANCLOUD_APP_ID=******
LEANCLOUD_APP_KEY=******
LEANCLOUD_APP_MASTER_KEY=******

# GitHub App Secret
WHU_SEAT_CLIENT_SCERET=******

构建步骤

# Install
yarn

# Develop
yarn dev

# Deploy
yarn pub

whu-library-seat-ghauth's People

Contributors

cs-tao avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 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.