You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New command wp (api|json) generate application-password #329
Note that the ; is mandatory otherwise it won't work in command line.
There is still a main issue for me with this solution.
In order to deploy WordPress websites accessible from my own tier application. I have to store generated password. However, the command above only creates an application password and do not return to you the generated value !
Plus, it does not seems to accept a given value for the password. (command is running but value is ignored) eg:
@swissspidy I'm currently working on implementing these new commands and going by what you've suggested above.
I'm surprised about the need to provide a user ID when retrieving an application password by UUID, which seems to also be a requirement by Core's API. Given a UUID should be unique even across users, I don't really understand the design of the data model... Was that for performance reasons that they are stored in user meta? A new table would have made much more sense (and would have been even more performant)...
Yeah that is a good question... Core never really adds new tables and perhaps user meta was considered to be a good fit because of the number of expected entries. I'd have to dig up the core trac ticket to get the context though.
Activity
[-]`wp (api|json) generate application-password*`[/-][+]`wp (api|json) generate application-password`[/+][-]`wp (api|json) generate application-password`[/-][+]New command `wp (api|json) generate application-password`[/+]swissspidy commentedon Mar 23, 2021
Since app passwords are stored per-user, this would fall under the
wp userumbrella (wp-cli/entity-command).Since app passwords can be added, listed and revoked, this could result in a new family of
wp usersub commands.In the meantime, you might be able to use
wp evalfor this (untested):pfefferle commentedon Mar 23, 2021
Good point, thanks for your answer @swissspidy !
Should I move the issue to the
entity-commandrepo?swissspidy commentedon Mar 23, 2021
We'll transfer it if needed. Can keep it here for discussion :)
DeLm0re commentedon Nov 22, 2021
Are there any news about this suggestion ?
After reading some documentation, and like @swissspidy said, the only working solution for now is to use the following command :
$ wp eval 'WP_Application_Passwords::create_new_application_password( 123, array( "name" => "test" ) );'Note that the
;is mandatory otherwise it won't work in command line.There is still a main issue for me with this solution.
In order to deploy WordPress websites accessible from my own tier application. I have to store generated password. However, the command above only creates an application password and do not return to you the generated value !
Plus, it does not seems to accept a given value for the password. (command is running but value is ignored) eg:
$ wp eval 'WP_Application_Passwords::create_new_application_password( 123, array( "name" => "test", "value" => "8lJB MyXY s3FC ArTF 81Kb QVAe") );'In conclusion, it would be very helpful if such a WP CLI command exists:
wp generate application-password <userId> <name> <password>or at least, make possible that eval command output the generated password.
I do already tried something like :
$ wp eval '$tmp = WP_Application_Passwords::create_new_application_password( 1, array( "name" => "test" ) ); echo($tmp[1]["password"]."\n");'Unfortunately, this method returns the hashed password ... not the real password value.
swissspidy commentedon Nov 22, 2021
Check the method's documentation; the unhashed password is the first array item.
So:
As for implementing this feature, I believe we are looking for the following commands:
wp user application-password list <user>wp user application-password get <user> <uuid>wp user application-password has <user> <name>wp user application-password update <user> <uuid> [--<field>=<value>]wp user application-password record-usage <user> <uuid>wp user application-password create <user> <name> [--app_id=<value>]DeLm0re commentedon Nov 22, 2021
@swissspidy Oh wow, thanks for the fast reply.
That is exactly what i'm looking for. Perfect 👍
schlessera commentedon Dec 1, 2021
@swissspidy I'm currently working on implementing these new commands and going by what you've suggested above.
I'm surprised about the need to provide a user ID when retrieving an application password by UUID, which seems to also be a requirement by Core's API. Given a UUID should be unique even across users, I don't really understand the design of the data model... Was that for performance reasons that they are stored in user meta? A new table would have made much more sense (and would have been even more performant)...
swissspidy commentedon Dec 5, 2021
Yeah that is a good question... Core never really adds new tables and perhaps user meta was considered to be a good fit because of the number of expected entries. I'd have to dig up the core trac ticket to get the context though.