Jump to content
stuartcryan

LastPass Workflow for Alfred - update v1.4.7 August 19, 2016

Recommended Posts

Simple LastPass Workflow for Alfred - quick and easy access to your LastPass vault

Simple yet powerful integration with the Lastpass CLI so you can now get your passwords out of your Lastpass vault and straight into the clipboard from within Alfred.

 

Version 1.4.7 update - Please Read

-----------------------------------------------------------

Ladies and gents, I am happy to present v 1.4.5 of the workflow. Before I continue, this has represented a SIGNIFICANT amount of work for me so if you like it and use it, please say thank you by donating towards my Diet Coke and cake fund.  :D Any amount will do, whatever you feel the value is for you/your business/your time.   :)

 

Please note you MUST update your LastPass CLI version to 0.7.1 or higher as this update relies on new functionality that I worked with the LastPass team on integrating into the official CLI. Additionally version 1.4.6 and higher of the workflow WILL ONLY SUPPORT ALFRED 3 (and are not backwards compatible)

 

If you haven't used LastPass before... you are crazy and you should it is the single greatest password manager package out there   :D so check it out at http://stu.link/LaStPaSs (Disclaimer, if you sign up through that link I get a free month otherwise you can go direct to http://www.lastpass.com).

-----------------------------------------------------------

 

Donations

This workflow represents many many hours effort of development, testing and rework. So if you love the workflow, and get use out of it every day, if you would like to donate as a thank you to buy me more caffeine giving Diet Coke, some Cake, or to put towards a shiny new gadget you can donate to me via Paypal.

 

Download

You can download the latest .alfredworkflow file directly or visit the official github repository (where you can log any issues, feedback or suggestions also).

 

Installation

  1. Ensure you have Alfred installed with the Alfred Powerpack License
  2. Install Capture::Tiny
    1. Open up a Terminal Window
    2. run the command 'sudo cpan install Capture::Tiny'
    3. Accept the default options and ensure Capture::Tiny installs successfully
  3. Install Homebrew (if you do not have it already installed)
    1. You should be able to just run the command in a terminal window (as your own user account NOT with sudo)
    2. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    3. Alternatively visit http://brew.sh/ for further instructions.
  4. Install LastPass command line interface
    1. In a terminal window run brew install lastpass-cli --with-pinentry --with-doc
  5. Download the .alfredworkflow file
  6. Open the .alfredworkflow file to import into Alfred
  7. Run 'lpsetemail yourloginemail@yourdomain.com' in Alfred to set your LastPass username.

Usage

  • lpsetemail yourname@example.com - must be run when you first install/upgrade to version 1.2 or higher
  • lpsettimeout NUMSEC - Set number of seconds until your login times out (where NUMSEC is an integer such as 28800, if you use 0 that will keep you logged in until your computer restarts)
  • lplogin - Log in to LastPass
  • lplogout - Log out of LastPass
  • lp Search Lastpass vault for item containing , press return to copy to clipboard.
  • Shift modifier can be used on lp to copy the username.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

History

  • Version 1.4.7
    1. Changed mechanism for copying to clipboard. Now marks passwords as transient, Alfred will no longer store them in the clipboard history.
    2. Updated icon submitted by Tom Conroy has been merged in (thanks for this Tom!)
  • Version 1.4.6
    1. Updated to work with Alfred 3 (long awaited official release of the long-in-testing beta version).
    2. Username display functionality submitted by Guillermo Moreno has been merged in with some minor changes (thanks for your hard work Guillermo!)
    3. Released with my apologies for the delay in getting this version out of beta... my masters course was INTENSE this semester, thank you to all of those that waited patiently.
  • Version 1.4.5
    1. Fixed detection for when login has timed out, now correctly requests login.
    2. Fixed rare cases of login-script loops.
    3. Improved speed of copying usernames.
    4. Updated documentation.
  • Version 1.4.4
    1. Merged in code submitted by Ariel Barreiro to better support two factor authentication (2FA).
  • Version 1.4.3
    1. NOTE: This has the same requirements as v1.4.2 below
    2. Fixes the binary version of the flow so that it is ACTUALLY updated
    3. Adds a fix so that the CLI's copy to clipboard is now lightening fast and should happen pretty much instantly.
  • Version 1.4.2
    1. NOTE: This version *requires* the LastPass CLI v 0.7.1 or higher due to this new feature --> Login process completely changed over to use AppleScript (cleaner and nicer). This was thanks to work between myself and Bob from LastPass who maintains the official LastPass CLI to add a feature allowing an external login prompt to be used.
    2. Login password prompt now uses an AppleScript password prompt.
    3. Fix to allow you to search for words in any order.
    4. Vault item's which now require re-authentication will pop up the AppleScript login prompt.
    5. Has now been tested with a Vault with over 30,000 items for performance tweaks. (I have since been told by LastPass support their soft limit is significantly lower than this at ~2500 items explains why I was having some issues in testing).
    6. More resilient escaping of text in the XML to ensure that special characters should not cause any issues.
    7. Fixed missing quotes in some areas that could cause issues with spaces.
    8. Squashed a little regex bug and wiped up the goo.
    9. Fixed issues with spaces in certain paths we referenced
    10. Fixed how the initial login process is run after a reboot. This required the changes made to how we manage the login process and it has subsequently been cleaned up significantly.
    11. Other minor general tweaks.
  • Version 1.2
    1. Bug - Removed deprecated framework code
    2. Bug - Merged pull request #4 from jsquyres "we-love-macports-too" to support macports installs of the lastpass-CLI
    3. Bug - Further improved on jsquyres code to support some additional install locations.
    4. Bug - Fixed bash script reliability, after two login attempts the script was often failing.
    5. Improvement - Improved sync behaviour to better support extremely large vaults.
    6. Improvement - Added new 'lpsync' command to force a sync on demand.
    7. Improvement - Changed behaviour to store login email in your Apple Keychain (set with 'lpsetemail yourname@example.com').
    8. Improvement - Added the ability to set the logout timeout and store in the keychain (set with 'lpsettimeout NUMSEC' where NUMSEC is an integer such as 28800, if you use 0 that will keep you logged in until your computer restarts).
    9. Improvement - Added hotkeys to the main functions.
  • Version 1.1
    1. Removed code that worked around an old buggy version of pinentry
    2. Fixed incorrect handling of no search results found (previously reported CLI tools were not installed)
  • Version 1.0 - Initial Release

Credits

Created by Stuart Ryan. If you would like to get into contact you can do so via:

License

Released under the GNU GENERAL PUBLIC LICENSE Version 2, June 1991

Notes

NOTE: This Alfred Workflow is not affiliated in any way with LastPass. The LastPass trademark and logo are owned by LastPass.com. The LastPass logo and product name have been used with permission of the LastPass team.

My thanks go out to LastPass for their awesome product and the new CLI!

Edited by stuartcryan

Share this post


Link to post

I was able to download this through your confluence site. Really cool workflow!

 

One possible enhancement - opening the URL associated to the site and copying password to clipboard upon clicking 'enter'.

 

Just my $.02

Share this post


Link to post

Your link seems broken. Receiving the following error:

 

 

My bad, :D referrer checking on my Akami CDN. I have pushed out a new config and she should be working now.

Edited by stuartcryan

Share this post


Link to post

I was able to download this through your confluence site. Really cool workflow!

 

One possible enhancement - opening the URL associated to the site and copying password to clipboard upon clicking 'enter'.

 

Just my $.02

 

Ooh good idea... I hadn't thought of that, will see what I can do.

Share this post


Link to post

Excellent. I have been waiting for a LastPass workflow. So fingers crossed and hope this hits the mark.

 

Fingers crossed it does for you too. Let me know if you have any issues. I do believe there is another LastPass workflow out there, but I didn't find out about that until after I wrote it LOL and this one seems much simpler under the hood. (I like the KISS principle)

Share this post


Link to post

I am having a bit of a problem. I can't install the LastPass command line interface. Getting this:

a2x --no-xmllint -f manpage lpass.1.txt
a2x: ERROR: "xsltproc"  --stringparam callout.graphics 0 --stringparam navig.graphics 0 --stringparam admon.textlabel 1 --stringparam admon.graphics 0  "/usr/local/Cellar/asciidoc/8.6.9/etc/asciidoc/docbook-xsl/manpage.xsl" "/private/tmp/lastpass-cli-BSVmgH/lastpass-cli-0.4.0/lpass.1.xml" returned non-zero exit status 5
make: *** [lpass.1] Error 1

**EDIT**

 

Ignore above. Ran brew update and upgrade and that fixed the errors. Everything installed fine.

 

It works perfect. Thanks.

Edited by MJD

Share this post


Link to post

Alright.. I think I might be going crazy.. It's almost 1 am and I've been at this for 4 hours now. And I simply cannot get this to work..

This same error keeps coming up:

Error 13 Permission Denied.

Please help.

Share this post


Link to post

Alright.. I think I might be going crazy.. It's almost 1 am and I've been at this for 4 hours now. And I simply cannot get this to work..

This same error keeps coming up:

Error 13 Permission Denied.

Please help.

Working with Dimitri on this offline (as it is requiring additional information) though it appears to be an isolated issue with the brew install I will keep everyone posted.

Share this post


Link to post

[update 12th July 2015 - Version 1.1 Release]


Howdy all, I am happy to announce this workflow is now up on Packal -->  http://www.packal.org/workflow/lastpass-cli-workflow-alfred (can be downloaded  from here)


 


Version 1.1 Changes:

Removed code that worked around an old buggy version of pinentry

Fixed incorrect handling of no search results found (previously reported CLI tools were not installed)

Share this post


Link to post

On 10.11 lplogin not work

Terminal window not appear, manual cli login is ok

 

Capture::Tiny - is works

 

TY

 

Hi Cka304h1k,

Thanks for that, I will have to see if I can spin up a VM and upgrade it (not tried this before). Will keep you posted.

Cheers

Stuart

Share this post


Link to post

Hi Cka304h1k,

Thanks for that, I will have to see if I can spin up a VM and upgrade it (not tried this before). Will keep you posted.

Cheers

Stuart

OK so it seems that El Capitan is not yet supported on VMs in Parallels. As soon as it is I will look into this (but don't have a machine to spare to install the beta just yet). I will keep you posted.

Share this post


Link to post

So I seem to be missing something since it is not currently working for me.

 

I can install (using brew) and use the CLI alone just fine, but when trying to use the workflow, I log in, but can't search. It just tells me that I'm not logged in.  Any ideas?

Share this post


Link to post

Hi Danjng,

You are the second person to report this... will DM you as I will likely need to set up a Teamviewer session with you so I can have a look at what is going wrong.

Cheers,
Stuart

Share this post


Link to post

So I seem to be missing something since it is not currently working for me.

 

I can install (using brew) and use the CLI alone just fine, but when trying to use the workflow, I log in, but can't search. It just tells me that I'm not logged in.  Any ideas?

All righty, seems I cant message you on the PM system:

 

So... instead could you please add me on Skype and I can chat to you there. My Skype username is StuartCRyan :) 
Cheers,
Stuart

Share this post


Link to post

I don't know if this issue is specific to this workflow but when I try to run 

lp foo

I get an error 

[ERROR: alfred.workflow.input.scriptfilter] Code 13: Can't locate strict.pm:   Permission denied at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

Seems to be some sort of permissions issue - What's the canonical way of fixing OS X Perl permission issues?

Share this post


Link to post

I don't know if this issue is specific to this workflow but when I try to run 

lp foo

I get an error 

[ERROR: alfred.workflow.input.scriptfilter] Code 13: Can't locate strict.pm:   Permission denied at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

Seems to be some sort of permissions issue - What's the canonical way of fixing OS X Perl permission issues?

Hmm that is a weird one. General way to fix all permissions issues in OSX is to run Disk Utility, select your Macintosh HD (or whatever you have renamed it to) and click Repair Disk Permissions.

 

Please give that a go and let me know how you go.

Cheers,
Stuart

Share this post


Link to post

 

Hmm that is a weird one. General way to fix all permissions issues in OSX is to run Disk Utility, select your Macintosh HD (or whatever you have renamed it to) and click Repair Disk Permissions.

 

Please give that a go and let me know how you go.

Cheers,
Stuart

 

Tried that - unfortunately that didn't help - it didn't find any bad permissions (pertaining to Perl...)   :(

 

(Thanks for the quick response :) )

Edited by hyshai

Share this post


Link to post

Tried that - unfortunately that didn't help - it didn't find any bad permissions (pertaining to Perl...)   :(

 

(Thanks for the quick response :) )

All good :) you caught me on lunch.

 

Can you please private message me with the outputs of the following terminal commands:

perl --version

 

system_profiler SPSoftwareDataType

 

cpan --version

 

cpan -l (will be a long output, may need to send as a file, message me for my email address)

 

sudo cpan -l (again, will potentially be quite a long output as above.

Share this post


Link to post

Hi Stuart, I've had the same issue as danjng -- were you guys able to figure out a fix by any chance?

Hi Klau,

I haven't had contact, the other person that had this issue it magically cleared up (I hate it when that happens).

 

I will PM you as I have a beta version of the workflow that may fix the issue for you.

Cheers,

Stuart

Share this post


Link to post

Hi Stuart, I've had the same issue as danjng -- were you guys able to figure out a fix by any chance?

OK can't seem to get you via PM (says you can't use it).

 

So instead -->

Could you please try downloading this new beta of the workflow --> [updated link August 18, 2015] https://dl.dropboxusercontent.com/u/9093155/alfred-workflows/stuartcryan-lastpass-cli/LastPassCLI_1.2.1_beta.alfredworkflow 
 
After you have installed the updated workflow you will need to run:
lpsetemail yourname@example.com
 
If you would like you can also use:
lpsettimeout NUMSEC
 
(where NUMSEC is either 0 - no timeout, or a number of seconds, otherwise a default of 28800 is used).
 
Please let me know if you have any more success with that.
Cheers,
Stuart
Edited by stuartcryan

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×