Code Monkey home page Code Monkey logo

wechat-auth's Introduction

wechat-auth

Auth server for wechat login

img

more info: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html

API

  • /api/wechat/redeem
  • /api/wechat/expire
curl -X POST -H 'Content-Type: application/json' --data '{"code":"023ey3Ts00Gc8d1NH7Vs0RlZSs0ey3Ty", "appid":"yiz"}' 127.0.0.1:7001/api/wechat/redeem

curl -X POST -H 'Content-Type: application/json' --data '{"credentials":"yiz:f166d608e398a066f1016131e296069d2d9992b3c82a0b6ae09ec56fdcac42be"}' 127.0.0.1:7001/api/wechat/expire

Development

npm i
npm run dev
open http://localhost:7001/

Deploy

server start

docker network create wechat-net
docker pull jiewei/wechat-auth
docker pull redis

# redis
docker run -d --network wechat-net \
-v /home/admin/data/wechat-redis:/data \
-v /home/admin/conf/redis/redis.conf:/usr/local/etc/redis/redis.conf \
-p:6379:6379 --name wechat-redis redis \
redis-server /usr/local/etc/redis/redis.conf --appendonly yes

# set app config in db
docker exec -it wechat-redis redis-cli -a $auth HMSET app:yiz appid $appid secret $serect
docker exec -it wechat-redis redis-cli -a $auth set app:authtoken $token

# app
docker run -d --network wechat-net \
-v /home/admin/wechat-auth:/home/admin/app \
-p:6001:7001 --name wechat-auth jiewei/wechat-auth

docker build & upload

docker build . -t jiewei/wechat-auth
docker push jiewei/wechat-auth

nginx on centsOS

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7

sudo yum install epel-release
sudo yum install nginx
sudo systemctl start nginx

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

sudo systemctl enable nginx
sudo systemctl restart nginx

vi /etc/nginx/nginx.conf

debug lua in redis

redis-cli -p 6380  --eval phgetall.lua 0 , yiz:user:*
redis-cli -p 6380  --eval pget.lua 0 , app:*

backup

docker cp wechat-redis:/data /home/admin/data/redis/`date +"%Y%m%d_%H%M%S"`

wechat-auth's People

Contributors

echopi avatar bokfang avatar jingshanccc avatar

Watchers

James Cloos 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.