Skip to content

Commit 476abc2

Browse files
committedJun 7, 2017
Use default phabricator api key to query public revisions
After a long talk with our security folks, we came to a conclusion that having every user of Lando (1000+) enter their Phabricator API keys would be a possible security risk, even if stored in a secure cookie. This patch allows Lando to use 1 key that it owns itself to query for public revisions on behalf of users. If the user does provide an api key, that key will be used instead, which allows users who have access to secure revisions to only input their API key when needed.
1 parent d2f0fb2 commit 476abc2

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed
 

‎docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ services:
1616
- PORT=80
1717
- VERSION_PATH=/version.json
1818
- PHABRICATOR_URL=https://mozphab.dev.mozaws.net
19+
- PHABRICATOR_UNPRIVILEGED_API_KEY=api-123456789
1920
py3-linter:
2021
build:
2122
context: ./

‎landoapi/api/revisions.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
Revision API
66
See the OpenAPI Specification for this API in the spec/swagger.yml file.
77
"""
8+
import os
9+
810
from connexion import problem
911
from landoapi.phabricator_client import PhabricatorClient
1012

1113

12-
def get(api_key, revision_id):
14+
def get(revision_id, api_key=None):
1315
""" API endpoint at /revisions/{id} to get revision data. """
1416
phab = PhabricatorClient(api_key)
1517
revision = phab.get_revision(id=revision_id)

‎landoapi/phabricator_client.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ class PhabricatorClient:
1818

1919
def __init__(self, api_key):
2020
self.api_url = os.getenv('PHABRICATOR_URL') + '/api'
21-
self.api_key = api_key
21+
if api_key:
22+
self.api_key = api_key
23+
else:
24+
self.api_key = os.getenv('PHABRICATOR_UNPRIVILEGED_API_KEY')
2225

2326
def get_revision(self, id=None, phid=None):
2427
""" Gets a revision as defined by the Phabricator API.

‎landoapi/spec/swagger.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ paths:
3434
type: string
3535
description: |
3636
A Phabricator Conduit API key to use to get the revision.
37-
required: true
37+
required: false
3838
responses:
3939
200:
4040
description: OK

0 commit comments

Comments
 (0)
Failed to load comments.