Coder Social home page Coder Social logo

oauth's Introduction

ASoulCnki OAuth

(枝网 OAuth 服务)

本服务提供以下内容

  • 统一的 OAuth 鉴权(基于 B 站私信)

待完成

  1. 新增授权码接口,提供短时间的授权
    1. 目前为固定时间只分配一个 token
    2. 希望后续能根据传参约定 token 有效时间
  2. 新增管理 API 用于管理 OAuth 服务

安装

依赖

  • Openresty
  • opm
  • luarocks
  • Redis

如果没有,请先前往安装,opm 随 OpenResty 携带,请检查 OpenResty 的 bin 目录,并将其添加到环境变量

redis 和 luarocks 可以通过包管理工具获取

依赖安装

opm get openresty/lua-resty-redis \
  openresty/lua-resty-mysql \
  anjia0532/lua-resty-redis-util \
  thibaultcha/lua-resty-jit-uuid \
  tokers/lua-resty-requests
luarocks install lua-resty-socket

其他

不同地区 dns 解析情况可能不同,如果私信收发网络状态太差,可以尝试更改 conf/nginx.conf 的 resolver

如何启动

  1. 安装 OpenResty 和 Redis

  2. lua/config/config.lua.bak 重命名为 lua/config/config.lua 并修改相应配置,必选配置项如下

    • Redis 地址,密码,如果无密码请填写 nil
    • 监听账号的 cookie,可配置多个,必选字段请参照文件内描述
  3. 将这个文件夹的内容全部复制到 openresty 目录下的 nginx 下,记得改好权限

  4. 启动 openresty

  5. 可选配置项有

    • 用户 session,token 的过期时间
    • 用户鉴权使用的头(尚在施工,目前只支持 Authorization 头)
    • 根据 UID 做的黑名单

不复制文件可以选择在当前目录直接启动,需要添加参数,命令为

openresty -p `pwd` -c conf/nginx.conf

每次修改配置后,需要 reload

openresty -p `pwd` -c conf/nginx.conf -s reload

oauth's People

Contributors

ch3cknull avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oauth's Issues

新增多账号收取

  • 添加多账号收取功能,支持多组 Cookie
  • 将不同的 Cookie 固定分配给不同的 Worker,如果能错开时间就更好了
    • 读 Cookie 的时候顺便可以把 uid 整理好
  • 新增一个获取账号的接口,用于给前端分发账号uid

数据持久化

目前的用户信息是放在Redis里的,所以遇到特殊情况,可能回丢失数据,需要把Redis的数据持久化

CORS配置不当

oauth.asoulcnki.asia/:1

   Access to XMLHttpRequest at 'https://api.asoulcnki.asia/oauth/v1/uid' from origin 'https://oauth.asoulcnki.asia' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

管理API

需要添加一组管理API,用于管理以下内容

  • 监听账号池的账号cookie,提供增删功能
  • token 和 session 的过期时间
  • 根据 uid 配置黑名单,提供增删功能

管理API通过在参数中携带指定的参数来鉴权,鉴权参数的名称和值都应当是可配置的

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.