diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..499fb2a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python:alpine + +WORKDIR /var/www/ + +COPY ./requirements.txt /var/www/requirements.txt + +RUN pip install -r /var/www/requirements.txt \ No newline at end of file diff --git a/app/app.py b/app/app.py index 67ab0be..88a7a44 100644 --- a/app/app.py +++ b/app/app.py @@ -12,17 +12,13 @@ oauth = OAuth(app) gotosocial = oauth.register( name='gotosocial', - # 010DGVDVM5ZN0D8W9WM0X59YMD - # 01JFPCR4Q8FYP273DPCW8FGDMJ - client_id='010DGVDVM5ZN0D8W9WM0X59YMD', - # 917ab929-90f5-4c87-b902-be6bed0d3a4e - # 5c190ea8-1984-4e05-b610-d7ed4d241079 - client_secret='917ab929-90f5-4c87-b902-be6bed0d3a4e', - access_token_url='https://gts.werefox.cafe/oauth/token', - access_token_params={'response_type':'token', 'grant_type':'authorization_code', 'client_id':'010DGVDVM5ZN0D8W9WM0X59YMD', 'client_secret':'917ab929-90f5-4c87-b902-be6bed0d3a4e'}, - authorize_url='https://gts.werefox.cafe/oauth/authorize', + client_id='', + client_secret='', + access_token_url='/oauth/token', + access_token_params={'response_type':'token', 'grant_type':'authorization_code', 'client_id':'', 'client_secret':''}, + authorize_url='/oauth/authorize', authorize_params={'grant_type':'authorization_code'}, - api_base_url='https://gts.werefox.cafe/api', + api_base_url='/api', client_kwargs={'scope': 'read'}, ) @@ -32,6 +28,30 @@ def index(): return render_template('index.html') +@app.route('/set_domain', methods=['POST']) +def set_domain(): + if(request.method == 'POST'): + payload = { + 'client_name':'gotosocial-fe', + 'redirect_uris':url_for('index', _external=True) + } + response = post(f'https://{request.form["domain"]}/api/v1/apps', data=payload) + client_data = response.json() + gotosocial.client_id = client_data['client_id'] + gotosocial.client_secret = client_data['client_secret'] + gotosocial.access_token_params = { + 'response_type':'token', + 'grant_type':'authorization_code', + 'client_id':client_data['client_id'], + 'client_secret':client_data['client_secret'] + } + gotosocial.access_token_url = f'https://{request.form["domain"]}{gotosocial.access_token_url}' + gotosocial.authorize_url = f'https://{request.form["domain"]}{gotosocial.authorize_url}' + gotosocial.api_base_url = f'https://{request.form["domain"]}{gotosocial.api_base_url}' + return redirect('/login') + else: + return "Sorry, but you can't get *GET* /set_domain, hun." + @app.route('/login') def login(): redirect_uri = url_for('authorize', _external=True) diff --git a/app/templates/index.html b/app/templates/index.html index 4529c53..a8a69b8 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -5,7 +5,11 @@