-
Notifications
You must be signed in to change notification settings - Fork 5
/
info.plist
278 lines (259 loc) · 7.26 KB
/
info.plist
1
2
3
4
5
6
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
70
71
72
73
74
75
76
77
78
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>bundleid</key>
<string>com.kangaechu.aws-vault-alfred-workflow</string>
<key>category</key>
<string>Tools</string>
<key>connections</key>
<dict>
<key>2C99F6F1-EF16-4CF1-9762-5D05A1FFAA4D</key>
<array>
<dict>
<key>destinationuid</key>
<string>BCF9D88B-14B0-4B42-AE3C-411695BDC870</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>BCF9D88B-14B0-4B42-AE3C-411695BDC870</key>
<array>
<dict>
<key>destinationuid</key>
<string>16039760-F173-4AB8-9C73-DA7401D5DE23</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
</dict>
<key>createdby</key>
<string>kangaechu</string>
<key>description</key>
<string>Open AWS via aws-vault</string>
<key>disabled</key>
<false/>
<key>name</key>
<string>Open AWS via aws-vault</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<true/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<true/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
<integer>1</integer>
<key>escaping</key>
<integer>0</integer>
<key>keyword</key>
<string>aws</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
<true/>
<key>queuedelaymode</key>
<integer>0</integer>
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string></string>
<key>script</key>
<string>#!/bin/bash
set -e
# load system path
eval "$(/usr/libexec/path_helper -s)"
function fetch(){
result=$(aws-vault list)
if [[ $? -ne 0 ]]; then
echo "error on running aws-vault list"
echo "${result}" >&2
exit 1
fi
echo "${result}"
}
function parse(){
local aws_vault_result="$1"
echo "${aws_vault_result}" | tail +3 | cut -f 1 -d' ' | grep -Ev '^-$'
}
function format_alfred(){
local profiles="$1"
local profiles_max_lines=$(echo -n "${profiles}" | grep -c '^')
local i=0
echo '{"items": ['
for profile in ${profiles}; do
cat << EOS
{
"uid": "${profile}",
"title": "${profile}",
"arg": "${profile}",
"icon": {"path": "icon.png"},
"autocomplete": "${profile}"
EOS
i=$(( i+1 ))
if [[ $i -eq $profiles_max_lines ]]; then
echo ' }'
else
echo ' },'
fi
done
echo ']}'
}
aws_vault_result=$(fetch)
profiles=$(parse "${aws_vault_result}")
format_alfred "${profiles}"
</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string>format_aws_vault_profiles.sh</string>
<key>subtext</key>
<string>profiles</string>
<key>title</key>
<string>Open AWS via aws-vault</string>
<key>type</key>
<integer>0</integer>
<key>withspace</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>2C99F6F1-EF16-4CF1-9762-5D05A1FFAA4D</string>
<key>version</key>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>aws_account=${1:-$default_profile}
aws_account=${aws_account// /} # trim space
AWS_ASSUME_ROLE_TTL=${AWS_ASSUME_ROLE_TTL:-1h}
AWS_FEDERATION_TOKEN_TTL=${AWS_FEDERATION_TOKEN_TTL:-1h}
export AWS_VAULT_PROMPT="${AWS_VAULT_PROMPT:-osascript}"
# load system path
eval "$(/usr/libexec/path_helper -s)"
firefox-bin() {
"${firefox_path:-/Applications/Firefox.app/Contents/MacOS/firefox}" "$@"
}
login_url="$(aws-vault login "$aws_account" --stdout)"
if [[ $? -ne 0 ]] then;
osascript -e 'display dialog "AWS Authentication failed"'
echo ${login_url} > /tmp/aws-vault-login-${aws_account}-$(date +"%Y%m%d_%H%M%S").log
exit 1
fi
if [[ ${preferred_browser} == "firefox" ]]; then
open -na firefox --args --profile $HOME/Library/Application\ Support/Firefox/Profiles/aws-vault/${aws_account} ${login_url}
elif [[ ${preferred_browser} == "chrome" ]]; then
open -na "Google Chrome" --args --user-data-dir=$HOME/Library/Application\ Support/Google/Chrome/aws-vault/${aws_account} ${login_url}
elif [[ ${preferred_browser} == "firefox-containers" ]]; then
# to work install add-on:
# https://addons.mozilla.org/en-US/firefox/addon/open-url-in-container/
ENCODED_URL="${login_url//&/%26}"
URI_HANDLER="ext+container:name=${aws_account}&url=${ENCODED_URL}"
firefox-bin "${URI_HANDLER}"
fi
</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>5</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>16039760-F173-4AB8-9C73-DA7401D5DE23</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>argument</key>
<string>{query}</string>
<key>variables</key>
<dict>
<key>aws_vault_path</key>
<string>{var:aws_vault_path}</string>
<key>default_profile</key>
<string>{var:default_profile}</string>
</dict>
</dict>
<key>type</key>
<string>alfred.workflow.utility.argument</string>
<key>uid</key>
<string>BCF9D88B-14B0-4B42-AE3C-411695BDC870</string>
<key>version</key>
<integer>1</integer>
</dict>
</array>
<key>readme</key>
<string>Open the AWS management console via aws-vault.
aws-vault is a tool for securely managing AWS credentials and authenticating multiple AWS accounts via assumeRole. `aws-vault login` is useful, but the browser cannot open multiple AWS accounts at the same time. This workflow creates a browser profile for each AWS account and opens a window for each profile.
It allows you to open multiple AWS accounts at the same time.</string>
<key>uidata</key>
<dict>
<key>16039760-F173-4AB8-9C73-DA7401D5DE23</key>
<dict>
<key>xpos</key>
<integer>500</integer>
<key>ypos</key>
<real>60</real>
</dict>
<key>2C99F6F1-EF16-4CF1-9762-5D05A1FFAA4D</key>
<dict>
<key>xpos</key>
<integer>235</integer>
<key>ypos</key>
<integer>60</integer>
</dict>
<key>BCF9D88B-14B0-4B42-AE3C-411695BDC870</key>
<dict>
<key>xpos</key>
<integer>405</integer>
<key>ypos</key>
<integer>90</integer>
</dict>
</dict>
<key>variables</key>
<dict>
<key>aws_vault_path</key>
<string>/usr/local/bin/aws-vault</string>
<key>default_profile</key>
<string></string>
<key>firefox_path</key>
<string>/Applications/Firefox.app/Contents/MacOS/firefox</string>
<key>preferred_browser</key>
<string>chrome</string>
</dict>
<key>variablesdontexport</key>
<array>
<string>default_profile</string>
</array>
<key>version</key>
<string>0.0.7</string>
<key>webaddress</key>
<string>https://github.com/kangaechu/aws-vault-alfred-workflow</string>
</dict>
</plist>