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

Add a SVN Password functionality #280

Merged
merged 44 commits into from
Aug 29, 2024
Merged

Add a SVN Password functionality #280

merged 44 commits into from
Aug 29, 2024

Conversation

dd32
Copy link
Member

@dd32 dd32 commented Jul 4, 2024

This is a user_pass but specific for SVN, in it's own table.

This is in place of an application password, fixes #276.

The option only shows when the user requires SVN access (or has a password set), based on user access.

Overview, not set. Overview, SVN password set
Screenshot 2024-07-04 at 4 41 29 PM Screenshot 2024-07-04 at 4 41 53 PM
Screen After password is generated
Screenshot 2024-07-04 at 4 41 37 PM Screenshot 2024-07-04 at 4 41 46 PM

TODO:

  • Verify table structure and names
  • Add user flags when a user is a comitter, plugin author, theme author, etc.
  • Wording.

@dd32 dd32 marked this pull request as ready for review July 19, 2024 07:13
Comment on lines +151 to +158
'user_id' => array(
'required' => true,
'type' => 'number',
'sanitize_callback' => 'absint',
'validate_callback' => function( $user_id ) {
return get_userdata( $user_id ) instanceof WP_User;
},
),
Copy link
Member

Choose a reason for hiding this comment

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

Do we allow user impersonation in WP.org? If not, maybe we can just use the current user id?

Copy link
Member Author

Choose a reason for hiding this comment

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

We do, although not how you may have invisioned it here.

Currently a super-admin can modify another users account data, that's why user_id is passed to the various 2FA endpoints.

I'm not a super-fan of it, but it's how the other endpoints in the plugin operate, so it made sense to duplicate that here.

An example of where this IS needed, is a case of accounts that cannot be logged into, system-level automation accounts that we need a SVN password for. However, we do have the CLI commands that can be used for that.

It also allows for super-admins to be able to quickly re-generate a new svn password for a user to lock them out (although, that's not something we'd likely make use of).

Happy to change this to throw a error along the lines of You can only re-generate a password for yourself if you feel strongly.

];
},
'permission_callback' => function( $request ) {
return Two_Factor_Core::rest_api_can_edit_user_and_update_two_factor_options( $request['user_id'] );
Copy link
Member

Choose a reason for hiding this comment

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

Should we restrict this endpoint to users only need a svn password? It seems like any authenticated .org user will be able to set their own SVN password here regardless if they need it or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was intentional, as WordPress is not aware of every user that may need a SVN password, such as those who are granted directly via svn configuration files (ie. develop.svn.wordpress.org).

Leaving this open allows for direct links to the svn password screen to be used, rather than having to set some user-meta to allow access.

settings/rest-api.php Show resolved Hide resolved
Copy link

@tellyworth tellyworth left a comment

Choose a reason for hiding this comment

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

Just suggestions/discussion around wording and UX only.

if ( svnPasswordRequired || svnPasswordSet ) {
if ( svnPasswordRequired ) {
svnBodyText = svnPasswordSet
? 'You have an active SVN password set. You can request a new one at any time.'

Choose a reason for hiding this comment

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

Only reviewing wording here:

  • Do we need to explicitly define like "SVN (Subversion)"?
  • Could be briefer and more direct, like "A SVN password is set" (or active)
  • Makes me wonder if there's such a thing as an inactive SVN password?

Copy link
Member Author

Choose a reason for hiding this comment

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

I kind of hope that those who need SVN access would know what SVN is, but, it's easy so why not?

Makes me wonder if there's such a thing as an inactive SVN password?

There isn't, currently. An 'inactive SVN password' would be an account that doesn't have a svn password set, or that we expired it (some time in the future).

Copy link
Member Author

Choose a reason for hiding this comment

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

Noting the text was simplified significantly.

Do we need to explicitly define like "SVN (Subversion)"?

I wonder if people know it more as SVN or Subversion.. I actually suspect it's more the former in the WordPress sphere.

looking at other WordPress documentation:

I've experimented with <abbr> and Subversion (SVN), and have settled on using SVN everywhere but calling it Subversion (SVN) in the first sentence on the page. Additionally, linking to the plugins handbook, see 98fcc52

settings/src/components/account-status.js Outdated Show resolved Hide resolved
settings/src/components/screen-navigation.js Outdated Show resolved Hide resolved
settings/src/components/svn-password.js Outdated Show resolved Hide resolved
settings/src/components/svn-password.js Outdated Show resolved Hide resolved
settings/src/components/svn-password.js Outdated Show resolved Hide resolved
@StevenDufresne
Copy link
Contributor

StevenDufresne commented Aug 5, 2024

Regarding terminology, "SVN Password" makes me think that as a plugin committer, my wp.org account and SVN commit passwords are different.

Provided this isn't the only way to commit in the future (which I'm pretty sure it isn't), have we considered other options like:

  • Application Password
  • Application Token
  • Application Key
  • Deployment Password
  • Deployment Token
  • Deployment Key
  • SVN Token
  • SVN Key

I think avoiding "password" altogether would make for simpler documentation.

@dd32
Copy link
Member Author

dd32 commented Aug 7, 2024

Regarding terminology, "SVN Password" makes me think that as a plugin committer, my wp.org account and SVN commit passwords are different.

That's the intention here, they will be.

Provided this isn't the only way to commit in the future (which I'm pretty sure it isn't), have we considered other options like:

This will be the only manner to authenticate against SVN. Their account password will cease to work.

This specifically does not call it a 'Application Password' as it cannot be used elsewhere in WordPress where an Application password can be used. I didn't call it a token or key because SVN asks for a Password (Since it only does Username + Password auth).

@StevenDufresne
Copy link
Contributor

StevenDufresne commented Aug 23, 2024

I'm thinking since it's only relevant to SVN, we can probably keep it on the SVN page.

That's lead me to questioning the design and layout of the screen, how about something like this instead?

Yeah I think those are good additions, letting the user know that there was a password configured in this view which is currently missing. Here's what I came up with based on your designs using some of the existing UI patterns. I think we can remove some of the copy when a password is configured.

Screenshot 2024-08-23 at 11 49 25 AM Screenshot 2024-08-23 at 12 03 15 PM

@dd32
Copy link
Member Author

dd32 commented Aug 23, 2024

I don't personally see the harm in leaving some of the basic boilerplate text there, how's this?

Current status:

Screen.Recording.2024-08-23.at.4.44.31.PM.mov

@dd32 dd32 force-pushed the add/svn-password branch from c69541f to e94d95e Compare August 27, 2024 05:59
return (
<>
<p>
WordPress.org uses Subversion (SVN) for version control, every Plugin and Theme
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we shorten this to avoid using WordPress.org and SVN twice? It makes it a bit hard on the eyes.

WordPress.org uses Subversion (SVN) for version control, providing each hosted plugin and theme with a repository that the author can commit to.
Before After
Screenshot 2024-08-28 at 3 06 01 PM Screenshot 2024-08-28 at 3 07 12 PM

Copy link
Member Author

Choose a reason for hiding this comment

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

LGTM

</li>
<li>
Password:{ ' ' }
{ generatedPassword || userRecord.record.svn_password_created ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the generatedPassword check necessary? wouldn't userRecord.record.svn_password_created be set if a password was generated?

Copy link
Member Author

Choose a reason for hiding this comment

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

Technically you're probably right, it might not be required, since we set userRecord.record.svn_password_created above manually.

In practise, I found it to be required, as without it it caused the UI to "flash" as it re-rendered the branch.

'get_callback' => function( $user ) {
// Local environment doesn't have the SVN password system, just return false for that.
if ( ! function_exists( 'WordPressdotorg\Security\SVNPasswords\get_svn_password_creation_date' ) ) {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this returns false, it doesn't allow us to test locally because of this check. Can we return a hard-coded date for testing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, but not really at the same time.

You can return Dummy data here, but if you hard-code dummy data you can't then test the branch where you've not set a password.

The best option would probably be to add a local test variant of the svn password functionality that uses user meta.

@StevenDufresne
Copy link
Contributor

@dd32 I've added some commits, mostly style, language updates. Can you verify that they are ok.

The last thing on my mind is whether we should change the screen from "SVN Password" to "SVN Credentials".

@dd32
Copy link
Member Author

dd32 commented Aug 29, 2024

+1 for SVN Credentials.

The copy changes appear good to me. I haven't re-tested it yet.

Noting that the systems change has been made, so this can now be used in production.

@dd32 dd32 merged commit 19d8f88 into trunk Aug 29, 2024
2 checks passed
@dd32 dd32 deleted the add/svn-password branch August 29, 2024 04:59
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.

Add a way to define an svn password
4 participants