-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobtain-secrets
executable file
·133 lines (120 loc) · 4.23 KB
/
obtain-secrets
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
#!/usr/bin/env bash
function browse_to {
if (which xdg-open >/dev/null); then
xdg-open $1
else
open $1
fi
}
function hash {
if (which sha256sum >/dev/null); then
sha256sum
else
md5
fi
}
function generate_password {
if (which openssl >/dev/null); then
openssl rand -hex 32
else
(hostname; date +%s; ls -la /) | rev | hash | base64 | head -c 32
fi
}
if [[ -f .env ]]; then
source .env
fi
echo "Welcome..."
if [[ -z "${gitlaboauth__client_id}${gitlaboauth__client_secret}" ]]; then
echo ""
echo "You need to create a GitLab Application to connect with GitLab"
echo "Application Name: Gitter User Dev"
echo "Redirect URI: http://localhost:5000/login/gitlab/callback"
echo "Select the \"api\" and \"read_user\" scope"
echo ""
echo "Press ENTER to open GitLab"
read nothing
browse_to https://gitlab.com/profile/applications
echo ""
echo "Paste the Application ID below and press ENTER"
read gitlaboauth__client_id
echo "Paste the Secret below and press ENTER"
read gitlaboauth__client_secret
echo ""
fi
if [[ -z "${github__user_client_id}${github__user_client_secret}" ]]; then
echo ""
echo "You need to create a GitHub Application to connect with GitHub"
echo "Application Name: Gitter User Dev"
echo "Homepage URL: http://localhost:5000"
echo "Authorisation callback URL: http://localhost:5000/login/callback"
echo ""
echo "Press ENTER to open GitHub"
read nothing
browse_to https://github.com/settings/applications/new
echo ""
echo "Paste the Client ID below and press ENTER"
read github__user_client_id
echo "Paste the Client Secret below and press ENTER"
read github__user_client_secret
echo ""
fi
if [[ -z "${github__client_id}${github__client_secret}" ]]; then
echo ""
echo "You need to do this again to create a scoped token for Private Repository access"
echo "Application Name: Gitter Private Dev"
echo "Homepage URL: http://localhost:5000"
echo "Authorisation callback URL: http://localhost:5000/login/callback"
echo ""
echo "Press ENTER to open GitHub"
read nothing
browse_to https://github.com/settings/applications/new
echo ""
echo "Paste the Client ID below and press ENTER"
read github__client_id
echo "Paste the Client Secret below and press ENTER"
read github__client_secret
clear
fi
if [[ -z "${twitteroauth__consumer_key}${twitteroauth__consumer_secret}" ]]; then
echo ""
echo "We also connect with Twitter, so, yeah, you need to create a Twitter App too."
echo "Name: Gitter Twitter YOURTWITTERUSERNAME"
echo "Description: Connect Gitter with Twitter"
echo "Website: http://test.gitter.im"
echo "Callback URL: http://localhost:5000/login/twitter/callback"
echo ""
echo "Press ENTER to open Twitter"
read nothing
browse_to https://developer.twitter.com/en/apps/create
echo "Click 'keys and tokens' to get your Consumer API Keys"
echo "Paste the Consumer API Key below and press ENTER"
read twitteroauth__consumer_key
echo "Paste the Consumer API Secret Key below and press ENTER"
read twitteroauth__consumer_secret
clear
fi
if [[ -f .env ]]; then
cp .env .env.backup.$(date +%s)
fi
cat <<EOF >.env
export web__sessionSecret="$(generate_password)"
export ws__superClientPassword="$(generate_password)"
export web__messageSecret="$(generate_password)"
export email__unsubscribeNotificationsSecret="$(generate_password)"
export integrations__secret="$(generate_password)"
export github__statePassphrase="$(generate_password)"
export twitteroauth__consumer_key="${twitteroauth__consumer_key}"
export twitteroauth__consumer_secret="${twitteroauth__consumer_secret}"
export gitlaboauth__client_id="${gitlaboauth__client_id}"
export gitlaboauth__client_secret="${gitlaboauth__client_secret}"
export github__client_id="${github__client_id}"
export github__client_secret="${github__client_secret}"
export github__user_client_id="${github__user_client_id}"
export github__user_client_secret="${github__user_client_secret}"
export github__anonymous_app__client_id="${github__user_client_id}"
export github__anonymous_app__client_secret="${github__user_client_secret}"
export tokens__anonymousPassword="$(generate_password)"
EOF
echo "You're good to go"
echo "Run 'source .env' to export your secret environment variables"
echo "Then run 'npm start'"