Skip to content

Commit 6f88b8c

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 6f88b8c

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from landoapi.phabricator_client import PhabricatorClient
1010

1111

12-
def get(api_key, revision_id):
12+
def get(revision_id, api_key=None):
1313
""" API endpoint at /revisions/{id} to get revision data. """
1414
phab = PhabricatorClient(api_key)
1515
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

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ paths:
3333
in: query
3434
type: string
3535
description: |
36-
A Phabricator Conduit API key to use to get the revision.
37-
required: true
36+
A Phabricator Conduit API key to use to get the revision. If not
37+
provided, then a default api key capable of getting public revisions
38+
only will be used instead.
39+
required: false
3840
responses:
3941
200:
4042
description: OK

0 commit comments

Comments
 (0)
Failed to load comments.