PMSF icon indicating copy to clipboard operation
PMSF copied to clipboard

OAuth2 integration for Discord

Open tallypokemap opened this issue 7 years ago • 6 comments

There will need to be substantial additions to documentation. These instructions assume a nginx server on Ubuntu 16.04

You will need a discord bot user in your server. Here is a link on how to set it up: https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token

  1. sudo pip3 install virtualenv
  2. virtualenv env
  3. source env/bin/activate
  4. pip3 install -r requirements.txt
  5. deactivate
  6. set values in oauth2/config/config.ini
  7. move oauth2.service to /etc/systemd/system
  8. sudo systemctl enable oauth2 and sudo systemctl start oauth2
  9. add this to your site-enabled conf file
    location /login {
        include proxy_params;
        proxy_pass http://unix:/var/www/html/PMSF/oauth2/oauth2.sock:/login;
    }
  1. sudo systemctl restart nginx
  2. Probably some permission settings for your PATH/TO/PMSF, idk

What is still needed:

  1. better templates for when access is denied (for now it either says "ACCESS DENIED" or "INSUFFICENT ROLES"
  2. for to have a config option to disable oauth2 in index.php
  3. Better instructions that above and probably for varying OS's and also for Apache

tallypokemap avatar Aug 18 '17 04:08 tallypokemap

Stuck at ..

` systemctl start oauth2 [root@vpsxxxxxxx PMSF]# systemctl status oauth2 ● oauth2.service - Gunicorn instance to serve oauth2 Loaded: loaded (/etc/systemd/system/oauth2.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since Sun 2017-08-20 01:17:23 EDT; 4s ago Process: 15388 ExecStart=/var/www/html/PMSF/oauth2/env/bin/gunicorn --workers 3 --bind unix:oauth2.sock -m 007 wsgi:app (code=exited, status=216/GROUP) Main PID: 15388 (code=exited, status=216/GROUP)

Aug 20 01:17:23 vpsxxxxxxx.vps.ovh.ca systemd[1]: Started Gunicorn instance to serve oauth2. Aug 20 01:17:23 vpsxxxxxxx.vps.ovh.ca systemd[1]: Starting Gunicorn instance to serve oauth2... Aug 20 01:17:23 vpsxxxxxxx.vps.ovh.ca systemd[1]: oauth2.service: main process exited, code=exited, status=216/GROUP Aug 20 01:17:23 vpsxxxxxxx.vps.ovh.ca systemd[1]: Unit oauth2.service entered failed state. Aug 20 01:17:23 vpsxxxxxxx.vps.ovh.ca systemd[1]: oauth2.service failed. `

Also, this requires that PMSF is installed in /var/www/html/PMSF as per the oauth2 service env path.

Also var/www/html/PMSF/oauth2/env/ didn't get created till after running 7. pip3 install -r requirements.txt yet the service is asked to be started in step 3.

ARGG1 avatar Aug 20 '17 05:08 ARGG1

I updated the order of the steps which hopefully is a better order. Also, I meant to replace the /var/www/html/PMSF with PATH/TO/PMSF but I never could get it to work anywhere else but that folder. Maybe someone better understanding permissions can figure out how to make it work elsewhere. Two places to look for error messages are in /var/log/nginx/error.log and also by running the command sudo journalctl -u oauth2. Lastly what doe the console say when you run this command: /var/www/html/PMSF/oauth2/env/bin/gunicorn --workers 3 --bind unix:oauth2.sock -m 007 wsgi:app

tallypokemap avatar Aug 20 '17 15:08 tallypokemap

https://pastebin.com/HdxiTWTY

ModuleNotFoundError: No module named 'wsgi'

Running on centos7. Already have installed mod_wsgi

ARGG1 avatar Aug 20 '17 15:08 ARGG1

@tallypokemap I haven't run the code yet but there's a circular reference in bot.py and oauth2.py.

hokiepokedad avatar Aug 27 '17 14:08 hokiepokedad

Howdy, can't get it run tho to this error: root:/var/www/PMSF/oauth2# python3 bot.py Traceback (most recent call last): File "bot.py", line 8, in from oauth2 import get_path, get_args File "/var/www/PMSF/oauth2/oauth2.py", line 12, in from bot import Bot, get_path File "/var/www/PMSF/oauth2/bot.py", line 8, in from oauth2 import get_path, get_args ImportError: cannot import name 'get_path' Thanks for the PR wish i can get it to work :P

wateredstorm avatar Aug 27 '17 14:08 wateredstorm

@tallypokemap Have you stop working on this?

tokar86a avatar Oct 09 '17 09:10 tokar86a