From f1f4a700942b42ac0a40fed52a3df11ef4787a1a Mon Sep 17 00:00:00 2001 From: crc-32 Date: Mon, 7 Nov 2022 21:43:08 +0000 Subject: [PATCH 1/2] Add cobble boot config --- boot/__init__.py | 2 ++ boot/cobble.py | 33 +++++++++++++++++++++++++++++++++ boot/settings.py | 2 ++ 3 files changed, 37 insertions(+) create mode 100644 boot/cobble.py diff --git a/boot/__init__.py b/boot/__init__.py index 1bc3432..c9f2b21 100644 --- a/boot/__init__.py +++ b/boot/__init__.py @@ -20,6 +20,7 @@ from .stage1 import init_app as init_stage1 from .stage2 import init_app as init_stage2 from .auth import rebble, init_app as init_auth +from .cobble import init_app as init_cobble from .settings import config app = Flask(__name__) @@ -34,6 +35,7 @@ init_stage1(app) init_stage2(app) init_auth(app) +init_cobble(app) # XXX: upstream this import beeline diff --git a/boot/cobble.py b/boot/cobble.py new file mode 100644 index 0000000..c2e1c50 --- /dev/null +++ b/boot/cobble.py @@ -0,0 +1,33 @@ +from flask import Blueprint, jsonify, request +import requests + +from .settings import config + +cobble = Blueprint('cobble', __name__) + +@cobble.route('/') +def boot_cobble(): + build = request.args.get('build') + platform = request.args.get('platform') + locale = request.args.get('locale', 'en_US') + boot = { + "auth": { + "base": f"{config['REBBLE_AUTH_URL']}/api", + "authorise_url": f"{config['REBBLE_AUTH_URL']}/oauth/authorise", + "refresh_url": f"{config['REBBLE_AUTH_URL']}/oauth/token", + "client_id": config['COBBLE_OAUTH_CLIENT_ID'] + }, + "appstore": { + "base": f"{config['APPSTORE_API_URL']}/api" + }, + "webviews": { + "appstoreApplication": f"{config['APPSTORE_URL']}/{locale}/application/", + "appstoreWatchapps": f"{config['APPSTORE_URL']}/{locale}/watchapps", + "appstoreWatchfaces": f"{config['APPSTORE_URL']}/{locale}/watchfaces", + "manageAccount": config['REBBLE_ACCOUNT_URL'] + } + } + return jsonify(boot) + +def init_app(app, prefix='/api/cobble'): + app.register_blueprint(cobble, url_prefix=prefix) diff --git a/boot/settings.py b/boot/settings.py index 9e263df..ee2b91a 100644 --- a/boot/settings.py +++ b/boot/settings.py @@ -23,4 +23,6 @@ }, 'HONEYCOMB_KEY': environ.get('HONEYCOMB_KEY', None), 'WS_PROXY_URL': environ.get('WS_PROXY_URL', f'ws://dev-ws-proxy.{domain_root}'), + 'COBBLE_OAUTH_CLIENT_ID': environ['COBBLE_OAUTH_CLIENT_ID'], + 'REBBLE_ACCOUNT_URL': environ.get('REBBLE_ACCOUNT_URL', f"{http_protocol}://auth.{domain_root}/account/"), } From 797515f0a9b6aa23ab904a5d8c788f233c988005 Mon Sep 17 00:00:00 2001 From: Katharine Berry Date: Fri, 14 Apr 2023 09:44:34 -0700 Subject: [PATCH 2/2] Americanise some JSON --- boot/cobble.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/cobble.py b/boot/cobble.py index c2e1c50..2786451 100644 --- a/boot/cobble.py +++ b/boot/cobble.py @@ -13,7 +13,7 @@ def boot_cobble(): boot = { "auth": { "base": f"{config['REBBLE_AUTH_URL']}/api", - "authorise_url": f"{config['REBBLE_AUTH_URL']}/oauth/authorise", + "authorize_url": f"{config['REBBLE_AUTH_URL']}/oauth/authorise", "refresh_url": f"{config['REBBLE_AUTH_URL']}/oauth/token", "client_id": config['COBBLE_OAUTH_CLIENT_ID'] },