Skip to content

Commit

Permalink
add steamguard support
Browse files Browse the repository at this point in the history
  • Loading branch information
iganeshk committed Oct 14, 2019
1 parent da7b433 commit de54a79
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*.dwarf
a-totp
/workflow/

README.html
# Libraries don't need dependency lock
# Dependencies will be locked in applications that use them
/shard.lock
Expand Down
34 changes: 24 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
# Alfred TOTP

Alfred 2-factor authentication workflow
<h1 align="center">
<a href="https://github.com/iganeshk/alfred-totp" title="Alfred TOTP Workflow">
<img alt="Alfred TOTP" src="https://github.com/iganeshk/alfred-totp/raw/master/assets/alfred-totp.png" width="15%"/>
</a>
<br />
Alfred TOTP Workflow
</h1>
<p align="center">
Obtain one time passwords from alfred.
</p>

<br />

## Requirements

* AlfredApp
* Brew package manager
* [AlfredApp](https://www.alfredapp.com/) (Alfred 3 & 4 tested)
* [Brew](https://brew.sh/) package manager
* Python3 (SteamGuard OTP support)

## Installation

`$ brew install oauthtool`

Then insert your totp codes into the macOS keychain `alfred-totp.keychain` like so:
## Obtaining your TOTP secrets
You could either export it from the existing applications you're using or generate a new secret from the website's user control panel.

For SteamGuard OTP, follow [this guide](https://github.com/SteamTimeIdler/stidler/wiki/Getting-your-'shared_secret'-code-for-use-with-Auto-Restarter-on-Mobile-Authentication) to obtain your secret key.

Then insert your totp secret codes into the macOS keychain `alfred-totp.keychain` like so:

```
$ security -i
> create-keychain alfred-totp.keychain
> set-keychain-settings alfred-totp.keychain
> add-generic-password -a alfred-totp -s "Name of service" -w "TOTP CODE" alfred-totp.keychain
> add-generic-password -a alfred-totp -s "name of service" -w "totp secret" alfred-totp.keychain
> # repeat above command as needed, crtl-c to quit.
```

Expand All @@ -40,9 +55,8 @@ If you would like to display all the service's passwords at once, configure the

<img alt="alfred-totp-2" src="https://github.com/iganeshk/alfred-totp/raw/master/assets/alfred_totp_4_list_all.png" width="80%" />

## Finding your totp codes
On most websites you can login and see your totp code in the 2-factor setting page.
* Note: Icons reflected in the results are located at workflow's icon directory and follow service name as entered in the keychain.

## Thanks

Thanks to [aria.ia](https://www.aria.ai/blog/posts/storing-secrets-with-keychain.html) for the code on how to list items from macOS keychain.
Thanks to [waynehoover](https://github.com/waynehoover/) and [aria.ia](https://www.aria.ai/blog/posts/storing-secrets-with-keychain.html) for the code on how to list items from macOS keychain.
Binary file added assets/alfred-totp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 22 additions & 9 deletions src/a-totp.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "json"

module ATotp
VERSION = "0.1.2"
module AlfredTOTP
VERSION = "0.1.3"
ENV["PATH"] = "/usr/local/bin:/usr/bin"

# This could possibly be cached.
Expand All @@ -22,29 +22,42 @@ module ATotp
io.to_s.strip
end

def self.get_steam_otp(pass)
command = "python3 steam.py #{pass}"
io = IO::Memory.new
Process.run(command, shell: true, output: io)
io.to_s.strip
end

def self.alfred_out
ids.map do |id|
pass = get_pass id
code = gen_code pass
# if service is steam, run it's script to get otp
if id == "steam"
pass = get_pass id
code = get_steam_otp pass
else
pass = get_pass id
code = gen_code pass
end
workflow_path = Dir.current
if File.exists?("#{workflow_path}/icons/#{id}.png")
alfred_icon = "#{workflow_path}/icons/#{id}.png"
if File.exists?("./icons/#{id}.png")
alfred_icon = "./icons/#{id}.png"
else
alfred_icon = "#{workflow_path}/icon.png"
alfred_icon = "./icon.png"
end
{
uid: id,
title: id,
subtitle: code,
arg: pass,
arg: code,
icon: {
path: "#{alfred_icon}",
},
mods: {
alt: {
valid: true,
subtitle: "copy #{code}",
arg: pass,
arg: code,
},
},
}
Expand Down

0 comments on commit de54a79

Please sign in to comment.