appstore: implement a proper config mechanism

This commit is contained in:
Alexandre Aubin 2023-08-17 13:57:32 +02:00
parent a52c769abc
commit b4a30b3f80
3 changed files with 25 additions and 7 deletions

1
store/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
config.toml

View file

@ -1,4 +1,4 @@
from flask import Flask, send_from_directory, render_template, session, redirect, request
import toml
import base64
import hashlib
import hmac
@ -6,16 +6,28 @@ import os
import random
import urllib
import json
from settings import DISCOURSE_SSO_SECRET, DISCOURSE_SSO_ENDPOINT, CALLBACK_URL_AFTER_LOGIN_ON_DISCOURSE
import sys
from flask import Flask, send_from_directory, render_template, session, redirect, request
app = Flask(__name__)
app.debug = True
app.config["DEBUG"] = True
app.config['TEMPLATES_AUTO_RELOAD'] = True
catalog = json.load(open("apps.json"))
catalog['categories'] = {c['id']:c for c in catalog['categories']}
try:
config = toml.loads(open("config.toml").read())
DISCOURSE_SSO_SECRET = config["DISCOURSE_SSO_SECRET"]
DISCOURSE_SSO_ENDPOINT = config["DISCOURSE_SSO_ENDPOINT"]
CALLBACK_URL_AFTER_LOGIN_ON_DISCOURSE = config["CALLBACK_URL_AFTER_LOGIN_ON_DISCOURSE"]
except Exception as e:
print("You should create a config.toml with the appropriate key/values, cf config.toml.example")
print(e)
sys.exit(1)
if config.get("DEBUG"):
app.debug = True
app.config["DEBUG"] = True
app.config['TEMPLATES_AUTO_RELOAD'] = True
category_color = {
"synchronization": "sky",
"publishing": "yellow",

View file

@ -0,0 +1,5 @@
# This secret is configured in Discourse
DISCOURSE_SSO_SECRET = "abcdefghijklmnopqrstuvwxyz1234567890"
DISCOURSE_SSO_ENDPOINT = "https://forum.yunohost.org/session/sso_provider"
CALLBACK_URL_AFTER_LOGIN_ON_DISCOURSE = "http://localhost:5000/sso_login_callback"
DEBUG = false