-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #38124 - Invalidate tokens for specific user/users
- Loading branch information
1 parent
fb0970e
commit 1c01cfc
Showing
3 changed files
with
134 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module HammerCLIForeman | ||
class RegistrationTokens < HammerCLIForeman::Command | ||
resource :registration_tokens | ||
command_name 'registration-tokens' | ||
desc _('Manage registration tokens') | ||
|
||
class UpdateCommand < HammerCLIForeman::UpdateCommand | ||
action :invalidate_jwt_tokens | ||
command_name 'invalidate_multiple' | ||
success_message _("Successfully invalidated registration tokens.\n") | ||
|
||
build_options | ||
end | ||
|
||
class InvalidateCommand < HammerCLIForeman::SingleResourceCommand | ||
action :invalidate_jwt | ||
command_name 'invalidate' | ||
success_message _("Successfully invalidated registration tokens.\n") | ||
|
||
build_options | ||
end | ||
|
||
autoload_subcommands | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,89 @@ | ||
module HammerCLIForeman | ||
|
||
class User < HammerCLIForeman::Command | ||
|
||
resource :users | ||
|
||
class ListCommand < HammerCLIForeman::ListCommand | ||
|
||
output do | ||
field :id, _("Id") | ||
field :login, _("Login") | ||
field :full_name, _("Name") | ||
field :mail, _("Email") | ||
field :admin, _("Admin"), Fields::Boolean | ||
field :disabled, _("Disabled"), Fields::Boolean | ||
field :last_login_on, _("Last login"), Fields::Date | ||
field nil, _("Authorized by"), Fields::SingleReference, :key => :auth_source | ||
field :id, _('Id') | ||
field :login, _('Login') | ||
field :full_name, _('Name') | ||
field :mail, _('Email') | ||
field :admin, _('Admin'), Fields::Boolean | ||
field :disabled, _('Disabled'), Fields::Boolean | ||
field :last_login_on, _('Last login'), Fields::Date | ||
field nil, _('Authorized by'), Fields::SingleReference, key: :auth_source | ||
end | ||
|
||
def extend_data(user) | ||
user["full_name"] = [user["firstname"], user["lastname"]].join(' ') | ||
user['full_name'] = [user['firstname'], user['lastname']].join(' ') | ||
user | ||
end | ||
|
||
build_options | ||
end | ||
|
||
|
||
class InfoCommand < HammerCLIForeman::InfoCommand | ||
|
||
output ListCommand.output_definition do | ||
field :mail_enabled, _("Email enabled"), Fields::Boolean | ||
field :effective_admin, _("Effective admin"), Fields::Boolean | ||
field :locale, _("Locale") | ||
field :timezone, _("Timezone") | ||
field :description, _("Description") | ||
custom_field Fields::Reference, :label => _("Default organization"), :path => [:default_organization] | ||
custom_field Fields::Reference, :label => _("Default location"), :path => [:default_location] | ||
field :mail_enabled, _('Email enabled'), Fields::Boolean | ||
field :effective_admin, _('Effective admin'), Fields::Boolean | ||
field :locale, _('Locale') | ||
field :timezone, _('Timezone') | ||
field :description, _('Description') | ||
custom_field Fields::Reference, label: _('Default organization'), path: [:default_organization] | ||
custom_field Fields::Reference, label: _('Default location'), path: [:default_location] | ||
HammerCLIForeman::References.roles(self) | ||
HammerCLIForeman::References.usergroups(self) | ||
HammerCLIForeman::References.taxonomies(self) | ||
HammerCLIForeman::References.timestamps(self) | ||
end | ||
|
||
def extend_data(user) | ||
user["locale"] ||= _('default') if user.has_key?("locale") | ||
user["timezone"] ||= _('default') if user.has_key?("timezone") | ||
user["full_name"] = [user["firstname"], user["lastname"]].join(' ') | ||
user["cached_usergroups"] = user.fetch('cached_usergroups', []) - user["usergroups"] | ||
user['locale'] ||= _('default') if user.has_key?('locale') | ||
user['timezone'] ||= _('default') if user.has_key?('timezone') | ||
user['full_name'] = [user['firstname'], user['lastname']].join(' ') | ||
user['cached_usergroups'] = user.fetch('cached_usergroups', []) - user['usergroups'] | ||
user | ||
end | ||
|
||
build_options | ||
end | ||
|
||
class CreateCommand < HammerCLIForeman::CreateCommand | ||
success_message _("User [%{login}] created.") | ||
failure_message _("Could not create the user") | ||
success_message _('User [%{login}] created.') | ||
failure_message _('Could not create the user') | ||
|
||
build_options | ||
|
||
extend_with(HammerCLIForeman::CommandExtensions::User.new) | ||
end | ||
|
||
|
||
class UpdateCommand < HammerCLIForeman::UpdateCommand | ||
success_message _("User [%{login}] updated.") | ||
failure_message _("Could not update the user") | ||
success_message _('User [%{login}] updated.') | ||
failure_message _('Could not update the user') | ||
|
||
build_options | ||
|
||
extend_with(HammerCLIForeman::CommandExtensions::User.new) | ||
end | ||
|
||
|
||
class DeleteCommand < HammerCLIForeman::DeleteCommand | ||
success_message _("User [%{login}] deleted.") | ||
failure_message _("Could not delete the user") | ||
success_message _('User [%{login}] deleted.') | ||
failure_message _('Could not delete the user') | ||
|
||
build_options | ||
end | ||
|
||
HammerCLIForeman::AssociatingCommands::Role.extend_command(self) | ||
lazy_subcommand('ssh-keys', _("Managing User SSH Keys."), | ||
'HammerCLIForeman::SSHKeys', 'hammer_cli_foreman/ssh_keys' | ||
) | ||
lazy_subcommand('access-token', _("Managing personal access tokens"), | ||
'HammerCLIForeman::PersonalAccessToken', 'hammer_cli_foreman/personal_access_token' | ||
) | ||
lazy_subcommand('mail-notification', _("Managing personal mail notifications"), | ||
'HammerCLIForeman::UserMailNotification', 'hammer_cli_foreman/user_mail_notification' | ||
) | ||
lazy_subcommand('table-preference', _("Managing table preferences"), | ||
'HammerCLIForeman::TablePreference', 'hammer_cli_foreman/table_preference' | ||
) | ||
lazy_subcommand('ssh-keys', _('Managing User SSH Keys.'), | ||
'HammerCLIForeman::SSHKeys', 'hammer_cli_foreman/ssh_keys') | ||
lazy_subcommand('access-token', _('Managing personal access tokens'), | ||
'HammerCLIForeman::PersonalAccessToken', 'hammer_cli_foreman/personal_access_token') | ||
lazy_subcommand('mail-notification', _('Managing personal mail notifications'), | ||
'HammerCLIForeman::UserMailNotification', 'hammer_cli_foreman/user_mail_notification') | ||
lazy_subcommand('table-preference', _('Managing table preferences'), | ||
'HammerCLIForeman::TablePreference', 'hammer_cli_foreman/table_preference') | ||
lazy_subcommand('registration-tokens', _('Managing registration tokens'), | ||
'HammerCLIForeman::RegistrationTokens', 'hammer_cli_foreman/registration_tokens') | ||
autoload_subcommands | ||
end | ||
|
||
end |