Class: Fastlane::Actions::LastpassAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::LastpassAction
- Defined in:
- lib/fastlane/plugin/lastpass/actions/lastpass_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
75 76 77 |
# File 'lib/fastlane/plugin/lastpass/actions/lastpass_action.rb', line 75 def self. ["Antoine Lamy"] end |
.available_options ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/fastlane/plugin/lastpass/actions/lastpass_action.rb', line 79 def self. [ FastlaneCore::ConfigItem.new(key: :username, env_name: "LASTPASS_USERNAME", description: "Your LastPass username", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :password, env_name: "LASTPASS_PASSWORD", description: "Your LastPass password", optional: false, type: String, sensitive: true), FastlaneCore::ConfigItem.new(key: :overwrite, env_name: "LASTPASS_OVERWRITE", description: "In case the passwords don't match, should the existing passwords be replaced", default_value: false, optional: true, type: Boolean, sensitive: true), FastlaneCore::ConfigItem.new(key: :list, env_name: "LASTPASS_LIST", description: "List available credentials in the account, do not modify the keychain", default_value: false, optional: true, type: Boolean, sensitive: false) ] end |
.description ⇒ Object
71 72 73 |
# File 'lib/fastlane/plugin/lastpass/actions/lastpass_action.rb', line 71 def self.description "Easily sync your Apple ID credentials stored in LastPass with your keychain using CredentialManager" end |
.is_supported?(platform) ⇒ Boolean
109 110 111 |
# File 'lib/fastlane/plugin/lastpass/actions/lastpass_action.rb', line 109 def self.is_supported?(platform) [:ios, :mac, :android].include?(platform) end |
.run(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fastlane/plugin/lastpass/actions/lastpass_action.rb', line 7 def self.run(params) require 'lastpass.rb' require 'yaml' require 'credentials_manager' begin unless params[:list] credentials = YAML.load_file "lastpass.yaml" vault_items = credentials["vault-items"] end begin vault = LastPass::Vault.open_remote params[:username], params[:password] rescue LastPass::LastPassIncorrectGoogleAuthenticatorCodeError => e multifactor_password = other_action.prompt(text: "Enter Google Authenticator code: ") vault = LastPass::Vault.open_remote params[:username], params[:password], multifactor_password rescue LastPass::LastPassIncorrectYubikeyPasswordError => e multifactor_password = other_action.prompt(text: "Enter Yubikey password: ") vault = LastPass::Vault.open_remote params[:username], params[:password], multifactor_password end if params[:list] puts "Account id | Account name" puts "-----------------------------------------" end vault.accounts.each_with_index do |account, index| if params[:list] puts "#{account.id} | #{account.name}" else if vault_items.include? account.id UI.("Adding account \"#{account.name} (#{account.id})\" to keychain") account_manager = CredentialsManager::AccountManager.new(user: account.username) existingPassword = account_manager.password(ask_if_missing: false) if existingPassword != account.password && existingPassword != nil if params[:overwrite] account_manager = CredentialsManager::AccountManager.new(user: account.username) account_manager.remove_from_keychain account_manager = CredentialsManager::AccountManager.new(user: account.username, password: account.password) account_manager.add_to_keychain UI.success("Account successfully overwrited with updated credentials") else UI.important("Account is already in the keychain with a different password, use force option to overwrite") end else if existingPassword == nil account_manager = CredentialsManager::AccountManager.new(user: account.username, password: account.password) account_manager.add_to_keychain UI.success("Account successfully added to keychain") else UI.success("Account is already in the keychain, skipping") end end end end end; nil rescue Errno::ENOENT UI.error("No lastpass.yaml file found, read the Readme to get started. Aborting...") end end |