Page MenuHomePhabricator

Implement `passphrase.query` for querying credentials
ClosedPublic

Authored by hach-que on Aug 14 2014, 1:39 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Sep 11, 7:11 PM
Unknown Object (File)
Mon, Sep 9, 12:44 AM
Unknown Object (File)
Fri, Sep 6, 1:11 AM
Unknown Object (File)
Wed, Sep 4, 7:26 PM
Unknown Object (File)
Thu, Aug 29, 9:00 AM
Unknown Object (File)
Thu, Aug 29, 2:51 AM
Unknown Object (File)
Wed, Aug 28, 9:32 PM
Unknown Object (File)
Wed, Aug 28, 10:18 AM

Details

Summary

Resolves T5868. This implements passphrase.query and a mechanism for allowing Conduit access to credentials.

Test Plan

Tested locally.

Diff Detail

Repository
rP Phabricator
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

hach-que retitled this revision from to Implement `passphrase.query` for querying credentials.
hach-que updated this object.
hach-que edited the test plan for this revision. (Show Details)
hach-que added a reviewer: epriestley.
epriestley edited edge metadata.

This looks generally good. Mostly-nitpicky inlines, high-level stuff is:

  • One actual important behavioral issue: enabling API access MUST require MFA if MFA is enabled on the account. See inline for more discussion.
  • There's some more modern stuff available for doing cursors/paging now, see DiffusionQueryCommitsConduitAPIMethod for an example.
  • I think the flag should only prevent secret access, not hide the entire credential.
src/applications/passphrase/conduit/PassphraseQueryConduitAPIMethod.php
12

pht()

20–21

There's a parent method to add these, isn't there? getPagingParamers() or something?

36

I don't think "Allow API" needs to completely prevent the credential from being retrieved over the API, just the secret. As written, this behavior seems a bit confusing -- you'll query for stuff and not get it back.

50–57

I think there are some CursorPager things in the parent?

65–67

Just omit from result list, I think? This seems like a bad behavior for an API method.

69–74

These are currently really expensive to pull -- we have to extract them from the private keys. Let's add a needPublicKeys option for now to enable pulling them? Alternatively, we could add a cache, or remove this feature for now if you don't need it. I don't want to do 100 synchronous openssl calls to respond to this query, though.

83–84

Let's add monogram, name and uri?

86

This is forward-looking, but maybe we should call this secrets, and return a map.

Particularly, T5553 contemplates storing SSL certificates in Passphrase, which seems reasonable. However, SSL certificates have multiple secrets (key, cert, possibly chain although that's not really secret).

Or maybe we could call it material and return a map like:

"material": {
  "publicKey": ...
  "privateKey": ...
}

Or:

"material": {
  "sslCertificate": ...,
  "sslKey": ...,
  "sslChain": ...,
}

And potentially (although I'm not sure this is a great idea or relevant at all):

"material": {
  "publicKey": ...,
  "noAPIAccess": "This credential's private material is not accessible via API calls."
}

...which might make the API flag less confusing.

91

As a modern method, this should return data in data and provide pager results. Look at DiffusionQueryCommitsConduitAPIMethod for an example of the most modern stuff. It simplifies some of the cursor/paging stuff.

src/applications/passphrase/controller/PassphraseCredentialConduitController.php
37

We must require MFA (if enabled) to access this endpoint.

Otherwise an attacker can access a credential, enable API access for it, and then retrieve the credential over the API without surviving a MFA check.

(You can just add the blahblah->requireMFA() thing present in the secret controller to implement this.)

58

it's -> its

72

Let's call this "Allow API Access" (vs "Allow Conduit Access") in the UI? I think that's probably clearer.

76–89

Remove unreachable copypasta.

src/applications/passphrase/storage/PassphraseCredentialTransaction.php
96–104

In this case where we have more space, maybe "Conduit API access".

This revision now requires changes to proceed.Aug 14 2014, 3:09 PM
src/applications/passphrase/controller/PassphraseCredentialConduitController.php
76–89

mmm pasta

hach-que edited edge metadata.

Changes requested in code review

epriestley edited edge metadata.

Couple of straightforward inlines.

src/applications/passphrase/conduit/PassphraseQueryConduitAPIMethod.php
100–101

pht() this value

117

This should be something like:

$result = array(
  'data' => $results,
);

return $this->addPagerResults($result, $pager);
src/applications/passphrase/controller/PassphraseCredentialConduitController.php
43

Remove; same as line 29.

src/applications/passphrase/query/PassphraseCredentialQuery.php
11

We could remove this stuff since we don't need it anymore, although maybe it's interesting to add the ability to search for these credentials in the UI ("What stuff are we exposing?"). I think it's fine to keep unless that use case sounds silly to you.

This revision is now accepted and ready to land.Aug 15 2014, 3:00 PM
hach-que edited edge metadata.

Changes requested in code review

hach-que updated this revision to Diff 24763.

Closed by commit rP26f283fe21a5 (authored by @hach-que).