@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Only let users log in to an OAuth server if they can see it

Summary:
Fixes T7169. We just weren't doing a policy-aware query. Basic idea here is that if you set an app to be visible only to specific users, those specific users are the only ones who should be able to authorize it.

In the Phacility cluster, this allows us to prevent users who haven't been invited from logging in to an instance.

Test Plan:
- Tried to log into an instance I was not a member of.
- Logged into an instance I am a member of.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7169

Differential Revision: https://secure.phabricator.com/D11696

+17 -2
+17 -2
src/applications/oauthserver/controller/PhabricatorOAuthServerAuthController.php
··· 39 39 // one giant try / catch around all the exciting database stuff so we 40 40 // can return a 'server_error' response if something goes wrong! 41 41 try { 42 - $client = id(new PhabricatorOAuthServerClient()) 43 - ->loadOneWhere('phid = %s', $client_phid); 42 + try { 43 + $client = id(new PhabricatorOAuthServerClientQuery()) 44 + ->setViewer($viewer) 45 + ->withPHIDs(array($client_phid)) 46 + ->executeOne(); 47 + } catch (PhabricatorPolicyException $ex) { 48 + // We require that users must be able to see an OAuth application 49 + // in order to authorize it. This allows an application's visibility 50 + // policy to be used to restrict authorized users. 51 + 52 + // None of the OAuth error responses are a perfect fit for this, but 53 + // 'invalid_client' seems closest. 54 + return $this->buildErrorResponse( 55 + 'invalid_client', 56 + pht('Not Authorized'), 57 + pht('You are not authorized to authenticate.')); 58 + } 44 59 45 60 if (!$client) { 46 61 return $this->buildErrorResponse(