LaunchBar & 1Password

General discussions about LaunchBar
waywalker
Posts: 16
Joined: Tue Oct 27, 2009 6:55 pm

Re: LaunchBar & 1Password

Postby waywalker » Wed Dec 09, 2009 1:23 am

Here is an Applescript that I've written up to integrate LaunchBar & 1Password.
It parses all 1Password files and creates 1Click bookmarks in Camino, which then are indexed by LaunchBar.
Cmd-Space, a couple of keystrokes and... boom! You are automagically logged in! :D

To use the script:
* install Camino
* save the script as 1P-to-Camino.scpt and run it
* add Camino Bookmarks to LaunchBar (LaunchBar Index > "+" > Web Bookmarks > Camino)
* optionally, you may want to schedule 1P-to-Camino.scpt to run periodically (e.g. http://www.tuaw.com/2008/04/14/mac-101- ... r-scripts/)

Code: Select all

-- Using the default keychain location. Change this line if necessary.
property OnePassKeychain : (path to home folder as string) & "Library:Application Support:1Password:1Password.agilekeychain:data:default:"

-- This tag will be appended to the end of bookmark names. Change this line if necessary.
property OnePassTag : " (1P)"

property BookmarkURLStart : "\"location\":\""
property BookmarkNameStart : "\"title\":\""
property UUIDStart : "\"UUID\":\""
property ItemEnd : "\",\""
property AlternateItemEnd : "\"}"
property IsWebForm : "webforms.WebForm"
property IsTrashed : "\"trashed\":true"

-- a handler that parses values from 1Password files
on ParseValue(ValueName, DelimiterName, DataFile)
   set AppleScript's text item delimiters to {DelimiterName}
   set ValueName to text item 2 of DataFile
   set AppleScript's text item delimiters to {ItemEnd}
   set ValueName to text item 1 of ValueName
   if ValueName contains {AlternateItemEnd} then
      set AppleScript's text item delimiters to {AlternateItemEnd}
      set ValueName to text item 1 of ValueName
   end if
   return ValueName
end ParseValue

-- a handler that makes a bookmark URL
to MakeURL(BookmarkURL, UUID)
   if BookmarkURL contains "?" then
      set BookmarkURL to BookmarkURL & "&onepasswdfill=" & UUID
   else
      set BookmarkURL to BookmarkURL & "?onepasswdfill=" & UUID
   end if
   return BookmarkURL
end MakeURL

-- a handler that makes bookmarks in Camino
to MakeBookmark(BookmarkName, BookmarkURL)
   tell application "Camino"
      tell bookmark folder "1Password"
         make new bookmark with properties {name:BookmarkName, URL:BookmarkURL}
      end tell
   end tell
end MakeBookmark

-- deleting and recreating the 1Password folder in Camino
tell application "Camino"
   if exists bookmark folder "1Password" then
      delete bookmark folder "1Password"
   end if
   make new bookmark folder with properties {name:"1Password"}
end tell

tell application "Finder"
   
   set PassFolder to OnePassKeychain as alias
   set PassFileList to every file in PassFolder whose name ends with ".1password"
   
   repeat with i from 1 to number of items in PassFileList
      set PassFile to (read (item i of PassFileList as alias))
      
      if PassFile contains IsWebForm and PassFile does not contain IsTrashed then
         
         set BookmarkURL to ParseValue("BookmarkURL", BookmarkURLStart, PassFile) of me
         set BookmarkName to ParseValue("BookmarkName", BookmarkNameStart, PassFile) of me
         set UUID to ParseValue("UUID", UUIDStart, PassFile) of me
         set BookmarkURL to MakeURL(BookmarkURL, UUID) of me
         MakeBookmark(BookmarkName & OnePassTag, BookmarkURL) of me
         
      end if
      
   end repeat
   
end tell

tell application "Camino" to quit


Change log:

2010-01-15
* Added property OnePassKeychain for easy customization of the 1Password Keychain location.
* Added property OnePassTag to be appended to the end of bookmark names.
* Added a condition to exclude trashed logins.
Last edited by waywalker on Fri Jan 15, 2010 9:18 pm, edited 2 times in total.

waywalker
Posts: 16
Joined: Tue Oct 27, 2009 6:55 pm

Re: Feature Request: 1Password Integration

Postby waywalker » Wed Dec 09, 2009 1:27 am

I've written up a script that integrates 1Password with LaunchBar.
See LaunchBar & 1Password
Comments are welcome :)

twynne
Posts: 6
Joined: Fri Jan 08, 2010 11:06 am

Re: LaunchBar & 1Password

Postby twynne » Fri Jan 08, 2010 7:54 pm

I was really glad to find this script, and I find it really useful.

Two minor adjustments though which you might consider in a future update:

1. If not possible to pick up the path of the agile keychain automatically, you might want to remind users to update it prior to use. In my case I keep mine on Dropbox, and found that the script was creating launchbar entries from an old agile keychain which remained in the default location.

2. I've changed the code to append a '1P' to the end of bookmark names. This way I can tell in Launchbar which one is the 1Password entry. (Let me know if you want the code change - it's really minor.)

Lastly, as there seemed to be a lot of opposition in the other thread, just wanted to +1 that some sort of direct Launchbar/1P integration would be really useful to me. Security is not a concern for me as I manage security outside of 1P.

twynne
Posts: 6
Joined: Fri Jan 08, 2010 11:06 am

Re: Feature Request: 1Password Integration

Postby twynne » Fri Jan 08, 2010 7:57 pm

+1 to this as I would find it really useful as well. I manage security outside of 1Password so that's not a concern for me.

The script works great for now, but more direct integration would eliminate the need to keep manually syncing each time a login is added/changed in 1P.

To answer the question above of 'how' it would be useful (though it seems obvious):

A simple Launchbar shortcut that opens a link in the default browser and then logs in (one keystroke) vs.

- Launch/restore default browser
- Browse for the bookmark for the site you want
- Either manually enter your details or use the 1P keyboard shortcut

sjk
Wizard
Wizard
Posts: 315
Joined: Thu Sep 13, 2007 9:46 pm
Location: Eugene
Contact:

Re: LaunchBar & 1Password

Postby sjk » Sat Jan 09, 2010 1:54 am

Moderator:

Perhaps merge this thread with Feature Request: 1Password Integration since the topic is overlapping? Thanks.

sjk
Wizard
Wizard
Posts: 315
Joined: Thu Sep 13, 2007 9:46 pm
Location: Eugene
Contact:

Re: Feature Request: 1Password Integration

Postby sjk » Sat Jan 09, 2010 1:54 am

Moderator:

Perhaps merge this thread with LaunchBar & 1Password since the topic is overlapping? Thanks.

twynne
Posts: 6
Joined: Fri Jan 08, 2010 11:06 am

Re: LaunchBar & 1Password

Postby twynne » Tue Jan 12, 2010 4:00 pm

One more thing about the script I've just realised - it doesn't ignore logins that are in your 'Trash' folder in 1Password. Not sure if there's a change that can be made to prevent these being created as bookmarks? Of course you can just empty the trash before running the script, but it kinda defeats the purpose of the folder in 1Password. Thoughts? :D

waywalker
Posts: 16
Joined: Tue Oct 27, 2009 6:55 pm

Re: LaunchBar & 1Password

Postby waywalker » Tue Jan 12, 2010 5:16 pm

Thanks for your suggestions, twynne!
And I'm glad you liked the script :D

I'll look into making the changes and report back.

Jaharmi
Rank 2
Rank 2
Posts: 48
Joined: Sat Dec 02, 2006 6:50 am

Re: LaunchBar & 1Password

Postby Jaharmi » Thu Jan 14, 2010 7:36 pm

I’d be happy to be able to look up items from my standard Mac OS X keychains, as well.

waywalker
Posts: 16
Joined: Tue Oct 27, 2009 6:55 pm

Re: LaunchBar & 1Password

Postby waywalker » Fri Jan 15, 2010 9:26 pm

@twynne
The script has been updated, check it out :-)

@Jaharmi
I run 1Password 3 and I believe it only supports Agile Keychain.

sjk
Wizard
Wizard
Posts: 315
Joined: Thu Sep 13, 2007 9:46 pm
Location: Eugene
Contact:

Re: LaunchBar & 1Password

Postby sjk » Fri Jan 15, 2010 10:54 pm

waywalker wrote:I run 1Password 3 and I believe it only supports Agile Keychain.

That's correct. See Why 1Password 3 No Longer Stores Data in the OS X Keychain Format in Upgrading to the Agile Keychain for the summary explanation and follow the links for the gory details.

twynne
Posts: 6
Joined: Fri Jan 08, 2010 11:06 am

Re: LaunchBar & 1Password

Postby twynne » Sat Jan 16, 2010 2:55 pm

Working great so far - thanks for the update.

I do have a slight issue (not directly related to the script) where I don't believe deleted bookmarks get removed from the index in Launchbar. To be sure I've just deleted Camino bookmarks from the index, run the script, the added Camino back.

Since using this I've realised that my 1P bookmarks need some cleaning up, but it's still SO nice to enter a quick LB shortcut and be signed straight into the sites I access most often.

Thanks again!

Tom

waywalker
Posts: 16
Joined: Tue Oct 27, 2009 6:55 pm

Re: LaunchBar & 1Password

Postby waywalker » Sat Jan 16, 2010 6:35 pm

twynne wrote:I do have a slight issue (not directly related to the script) where I don't believe deleted bookmarks get removed from the index in Launchbar. To be sure I've just deleted Camino bookmarks from the index, run the script, the added Camino back.


I might have had a similar issue before. Here it what fixed it for me:

  • go to LaunchBar Index > Camino Bookmarks > Schedule
  • check "Update periodically" and set it to "Every 5 minutes"
  • check "Update automatically"

twynne wrote:SO nice to enter a quick LB shortcut and be signed straight into the sites I access most often.


It's so much fun that I almost giggle every time I do it! :lol:

garyh
Posts: 4
Joined: Thu Dec 03, 2009 11:23 pm

Re: LaunchBar & 1Password

Postby garyh » Mon Aug 09, 2010 5:40 pm

Has anyone ever updated this for Safari? :D

waywalker
Posts: 16
Joined: Tue Oct 27, 2009 6:55 pm

Re: LaunchBar & 1Password

Postby waywalker » Tue Aug 10, 2010 2:46 pm

garyh wrote:Has anyone ever updated this for Safari? :D


Last time I checked, Safari didn't support creating bookmarks via Applescript. Hence, Camino 8)


Return to “LaunchBar General”

Who is online

Users browsing this forum: No registered users and 5 guests