Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App passwords #826

Merged
merged 9 commits into from
Apr 18, 2023
Merged

App passwords #826

merged 9 commits into from
Apr 18, 2023

Conversation

dholms
Copy link
Collaborator

@dholms dholms commented Apr 17, 2023

Implement routes for:

  • creating app passwords
  • revoking app passwords
  • listing app password names (but not passwords because they are scrypted)

Access tokens from app passwords have a different scope on them (which is a subset of the general "access") & the auth verifier for most routes is augmented to allow requests from both scopes. Some routes - such as account deletion or creating new app passwords - do not allow requests from app passwords.

At the DB layer, we scrypt app passwords using the user's did as a salt. This prevents us from having to scrypt a password (costly operation) many times for many different salts. This still protects against rainbow table attacks.

@@ -0,0 +1,10 @@
export interface AppPassword {
accountDid: string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issue here at all, but I'm interested to hear whether there's any special reason this is accountDid rather than just did, as you might find in some of the other tables.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no good reason lol. i'll update it 👍

)
})

it('restricts certain actions', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just double-checking that createAppPassword is the only method we want to restrict in this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so? I can't think of any others besides maybe revokeAppPassword

Honestly I'm not even sure we need to restrict createAppPassword 🤔

deleteAccount requires you to add in your account password anyways

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good call to restrict createAppPassword 👍

@@ -0,0 +1,103 @@
import AtpAgent from '@atproto/api'
Copy link
Collaborator

@devinivy devinivy Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other case I can think of that might be nice in here is that tokens received after a refresh continue to be restricted as app-password credentials.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah good call 👍

Copy link
Collaborator

@devinivy devinivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@pfrazee
Copy link
Collaborator

pfrazee commented Apr 17, 2023

APIs lgtm from the app perspective

@dholms dholms changed the title App-specific passwords App passwords Apr 18, 2023
@dholms dholms merged commit 6446e8d into main Apr 18, 2023
@dholms dholms deleted the app-passwords branch April 18, 2023 18:47
dholms added a commit that referenced this pull request Apr 18, 2023
* app password lex & auth chnages

* scrypt things

* implemented app password refresh tokens

* db tidy & migration

* revocation + bugfixin

* tests, listing passwords & cleanup

* Update packages/pds/src/db/scrypt.ts

Co-authored-by: devin ivy <[email protected]>

* Update packages/pds/src/db/scrypt.ts

Co-authored-by: devin ivy <[email protected]>

* pr feedback

---------

Co-authored-by: devin ivy <[email protected]>
dholms added a commit that referenced this pull request Apr 23, 2023
* moderation tweks

* fix: typo. (#818)

* Create invite codes for many accounts (#825)

* create invite codes for many accounts

* test

* Revamp dev env (#796)

* fix up a couple of tsc errors in app view merge

* wip

* use dev-env for appview tests

* process all in blob resolver

* another test fix

* fixed missed merge conflict

* fix one more merge conflict

* fix popular test

* Sync test env with labeler changes (#836)

fix test-env

* Remove extraneous info on getRecord (#835)

* remove extraneous info on getRecord

* fix test-env

* Fix duplication of constants in the crypto package (#819)

* App passwords (#826)

* app password lex & auth chnages

* scrypt things

* implemented app password refresh tokens

* db tidy & migration

* revocation + bugfixin

* tests, listing passwords & cleanup

* Update packages/pds/src/db/scrypt.ts

Co-authored-by: devin ivy <[email protected]>

* Update packages/pds/src/db/scrypt.ts

Co-authored-by: devin ivy <[email protected]>

* pr feedback

---------

Co-authored-by: devin ivy <[email protected]>

* remove profile labels

* rm temp branch from workflow

---------

Co-authored-by: Devin Ivy <[email protected]>
Co-authored-by: S. Ota <[email protected]>
Co-authored-by: Ilya Siamionau <[email protected]>
mloar pushed a commit to mloar/atproto that referenced this pull request Nov 15, 2023
* app password lex & auth chnages

* scrypt things

* implemented app password refresh tokens

* db tidy & migration

* revocation + bugfixin

* tests, listing passwords & cleanup

* Update packages/pds/src/db/scrypt.ts

Co-authored-by: devin ivy <[email protected]>

* Update packages/pds/src/db/scrypt.ts

Co-authored-by: devin ivy <[email protected]>

* pr feedback

---------

Co-authored-by: devin ivy <[email protected]>
mloar pushed a commit to mloar/atproto that referenced this pull request Nov 15, 2023
* moderation tweks

* fix: typo. (bluesky-social#818)

* Create invite codes for many accounts (bluesky-social#825)

* create invite codes for many accounts

* test

* Revamp dev env (bluesky-social#796)

* fix up a couple of tsc errors in app view merge

* wip

* use dev-env for appview tests

* process all in blob resolver

* another test fix

* fixed missed merge conflict

* fix one more merge conflict

* fix popular test

* Sync test env with labeler changes (bluesky-social#836)

fix test-env

* Remove extraneous info on getRecord (bluesky-social#835)

* remove extraneous info on getRecord

* fix test-env

* Fix duplication of constants in the crypto package (bluesky-social#819)

* App passwords (bluesky-social#826)

* app password lex & auth chnages

* scrypt things

* implemented app password refresh tokens

* db tidy & migration

* revocation + bugfixin

* tests, listing passwords & cleanup

* Update packages/pds/src/db/scrypt.ts

Co-authored-by: devin ivy <[email protected]>

* Update packages/pds/src/db/scrypt.ts

Co-authored-by: devin ivy <[email protected]>

* pr feedback

---------

Co-authored-by: devin ivy <[email protected]>

* remove profile labels

* rm temp branch from workflow

---------

Co-authored-by: Devin Ivy <[email protected]>
Co-authored-by: S. Ota <[email protected]>
Co-authored-by: Ilya Siamionau <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants