-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsettings.py
352 lines (309 loc) · 10.1 KB
/
settings.py
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
####################################################
# #
# DO NOT INCLUDE CLIENT SECRETS IN THIS FILE !!!!! #
# #
# Instead, copy the file config-template.py to #
# config.py (which is not committed to the repo) #
# and put client secrets there. #
# #
####################################################
import os
TESTING = os.environ.get('SERVER_SOFTWARE', '').startswith('Development')
APP_DOMAIN = 'change-me-in-config-py.appspot.com'
APP_NAME = 'CHANGE-ME-IN-CONFIG.PY'
SERVICE_DISPLAYNAME = APP_NAME + ' OAuth Handler'
DEFAULT_TOKEN_VERSION = 1
API_KEY = ''
WORKER_URLS = []
WORKER_OFFLOAD_RATIO = 0
WL_CLIENT_ID = 'XXXXXXXXXXXXXXXXXXXX'
WL_CLIENT_SECRET = 'XXXXXXXXXXXXXXXXXXXX'
MSGRAPH_CLIENT_ID = 'XXXXXXXXXXXXXXXXXXXX'
MSGRAPH_CLIENT_SECRET = 'XXXXXXXXXXXXXXXXXXXX'
GD_CLIENT_ID = 'XXXXXXXXXXXXXXXXXXXX'
GD_CLIENT_SECRET = 'XXXXXXXXXXXXXXXXXXXX'
HC_CLIENT_ID = 'XXXXXXXXXXXXXXXXXXXX'
HC_CLIENT_SECRET = 'XXXXXXXXXXXXXXXXXXXX'
AMZ_CLIENT_ID = 'XXXXXXXXXXXXXXXXXXXX'
AMZ_CLIENT_SECRET = 'XXXXXXXXXXXXXXXXXXXX'
BOX_CLIENT_ID = 'XXXXXXXXXXXXXXXXXXXX'
BOX_CLIENT_SECRET = 'XXXXXXXXXXXXXXXXXXXX'
DROPBOX_CLIENT_ID = 'XXXXXXXXXXXXXXXXXXXX'
DROPBOX_CLIENT_SECRET = 'XXXXXXXXXXXXXXXXXXXX'
RATE_LIMIT = 0
try:
from config import WL_CLIENT_ID
from config import WL_CLIENT_SECRET
except ImportError:
pass
try:
from config import MSGRAPH_CLIENT_ID
from config import MSGRAPH_CLIENT_SECRET
except ImportError:
pass
try:
from config import GD_CLIENT_ID
from config import GD_CLIENT_SECRET
except ImportError:
pass
try:
from config import HC_CLIENT_ID
from config import HC_CLIENT_SECRET
except ImportError:
pass
try:
from config import AMZ_CLIENT_ID
from config import AMZ_CLIENT_SECRET
except ImportError:
pass
try:
from config import BOX_CLIENT_ID
from config import BOX_CLIENT_SECRET
except ImportError:
pass
try:
from config import DROPBOX_CLIENT_ID
from config import DROPBOX_CLIENT_SECRET
except ImportError:
pass
try:
from config import APP_DOMAIN
except ImportError:
pass
try:
from config import APP_NAME
except ImportError:
pass
try:
from config import SERVICE_DISPLAYNAME
except ImportError:
pass
try:
from config import RATE_LIMIT
except ImportError:
pass
try:
from config import TESTING
except ImportError:
pass
try:
from config import API_KEY
except ImportError:
pass
try:
from config import WORKER_URLS
except ImportError:
pass
try:
from config import WORKER_OFFLOAD_RATIO
except ImportError:
pass
try:
from config import DEFAULT_TOKEN_VERSION
except ImportError:
pass
OAUTH_CALLBACK_URI = 'https://' + APP_DOMAIN + '/logged-in'
try:
from config import OAUTH_CALLBACK_URI
except ImportError:
pass
WL_REDIRECT_URI = OAUTH_CALLBACK_URI
WL_AUTH_URL = 'https://login.live.com/oauth20_token.srf'
WL_LOGIN_URL = 'https://login.live.com/oauth20_authorize.srf'
MSGRAPH_REDIRECT_URI = OAUTH_CALLBACK_URI
MSGRAPH_AUTH_URL = 'https://login.microsoftonline.com/common/oauth2/v2.0/token'
MSGRAPH_LOGIN_URL = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize'
GD_REDIRECT_URI = OAUTH_CALLBACK_URI
GD_AUTH_URL = 'https://www.googleapis.com/oauth2/v3/token'
GD_LOGIN_URL = 'https://accounts.google.com/o/oauth2/auth'
HC_REDIRECT_URI = OAUTH_CALLBACK_URI
HC_AUTH_URL = 'https://api.hubic.com/oauth/token/'
HC_LOGIN_URL = 'https://api.hubic.com/oauth/auth/'
AMZ_REDIRECT_URI = OAUTH_CALLBACK_URI
AMZ_AUTH_URL = 'https://api.amazon.com/auth/o2/token'
AMZ_LOGIN_URL = 'https://www.amazon.com/ap/oa'
BOX_REDIRECT_URI = OAUTH_CALLBACK_URI
BOX_AUTH_URL = 'https://api.box.com/oauth2/token'
BOX_LOGIN_URL = 'https://app.box.com/api/oauth2/authorize'
DROPBOX_REDIRECT_URI = OAUTH_CALLBACK_URI
DROPBOX_AUTH_URL = 'https://api.dropboxapi.com/oauth2/token'
DROPBOX_LOGIN_URL = 'https://www.dropbox.com/oauth2/authorize'
JOTTACLOUD_AUTH_URL = 'https://id.jottacloud.com/auth/realms/jottacloud/protocol/openid-connect/token'
LOOKUP = {
'wl': {
'display': 'Windows Live',
'client-id': WL_CLIENT_ID,
'client-secret': WL_CLIENT_SECRET,
'redirect-uri': WL_REDIRECT_URI,
'auth-url': WL_AUTH_URL,
'login-url': WL_LOGIN_URL
},
'msgraph': {
'display': 'Microsoft Graph',
'client-id': MSGRAPH_CLIENT_ID,
'client-secret': MSGRAPH_CLIENT_SECRET,
'redirect-uri': MSGRAPH_REDIRECT_URI,
'auth-url': MSGRAPH_AUTH_URL,
'login-url': MSGRAPH_LOGIN_URL
},
'gd': {
'display': 'Google',
'client-id': GD_CLIENT_ID,
'client-secret': GD_CLIENT_SECRET,
'redirect-uri': GD_REDIRECT_URI,
'auth-url': GD_AUTH_URL,
'login-url': GD_LOGIN_URL
},
'hc': {
'display': 'HubiC',
'client-id': HC_CLIENT_ID,
'client-secret': HC_CLIENT_SECRET,
'redirect-uri': HC_REDIRECT_URI,
'auth-url': HC_AUTH_URL,
'login-url': HC_LOGIN_URL
},
'amz': {
'display': 'Amazon',
'client-id': AMZ_CLIENT_ID,
'client-secret': AMZ_CLIENT_SECRET,
'redirect-uri': AMZ_REDIRECT_URI,
'auth-url': AMZ_AUTH_URL,
'login-url': AMZ_LOGIN_URL
},
'box': {
'display': 'Box.com',
'client-id': BOX_CLIENT_ID,
'client-secret': BOX_CLIENT_SECRET,
'redirect-uri': BOX_REDIRECT_URI,
'auth-url': BOX_AUTH_URL,
'login-url': BOX_LOGIN_URL
},
'dropbox': {
'display': 'Dropbox',
'client-id': DROPBOX_CLIENT_ID,
'client-secret': DROPBOX_CLIENT_SECRET,
'redirect-uri': DROPBOX_REDIRECT_URI,
'auth-url': DROPBOX_AUTH_URL,
'login-url': DROPBOX_LOGIN_URL,
# Docs say state is supported, but server rejects
'no-state-for-token-request': True,
# Dropbox is a little picky
'no-redirect_uri-for-refresh-request': True
},
'jottacloud': {
'display': 'Jottacloud',
'client-id': "jottacli",
'auth-url': JOTTACLOUD_AUTH_URL,
'cli-token': True
}
}
SERVICES = [
{
'display': 'Google Drive (limited)',
'type': 'gd',
'id': 'googledrive',
'scope': 'https://www.googleapis.com/auth/drive.file',
'extraurl': 'access_type=offline&approval_prompt=force',
'servicelink': 'https://drive.google.com',
'deauthlink': 'https://security.google.com/settings/security/permissions',
'brandimage': '/google-btn.png'
},
{
'display': 'Google Drive (full access)',
'type': 'gd',
'id': 'googledocs',
'scope': 'https://www.googleapis.com/auth/drive',
'extraurl': 'access_type=offline&approval_prompt=force',
'servicelink': 'https://drive.google.com',
'deauthlink': 'https://security.google.com/settings/security/permissions',
'brandimage': '/google-btn.png'
},
{
'display': 'Google Cloud Storage',
'type': 'gd',
'id': 'gcs',
'scope': 'https://www.googleapis.com/auth/devstorage.read_write',
'extraurl': 'access_type=offline&approval_prompt=force',
'servicelink': 'https://cloud.google.com/storage/',
'deauthlink': 'https://security.google.com/settings/security/permissions',
'brandimage': '/google-btn.png'
},
{
'display': 'Microsoft OneDrive (Live Connect API)',
'type': 'wl',
'id': 'onedrive',
'scope': 'wl.offline_access wl.skydrive_update wl.skydrive',
'servicelink': 'https://onedrive.live.com',
'notes': '<p style="font-size: small">By using the OAuth login service for OneDrive you agree to the <a href="https://www.microsoft.com/en-us/servicesagreement" target="_blank">Microsoft Service Agreement</a> and <a href="https://privacy.microsoft.com/en-us/privacystatement" target="_blank">Microsoft Online Privacy Statement</a></p>'
},
{
'display': 'Microsoft OneDrive (Microsoft Graph API)',
'type': 'msgraph',
'id': 'onedrivev2',
'scope': 'offline_access Files.ReadWrite',
'servicelink': 'https://onedrive.live.com'
},
{
'display': 'Microsoft SharePoint (Microsoft Graph API)',
'type': 'msgraph',
'id': 'sharepoint',
'scope': 'offline_access Files.ReadWrite.All',
'servicelink': 'https://products.office.com/en-us/sharepoint'
},
{
'display': 'Microsoft Office 365 Groups (Microsoft Graph API)',
'type': 'msgraph',
'id': 'msgroup',
'scope': 'offline_access Files.ReadWrite.All Group.Read.All',
'servicelink': 'https://support.office.com/en-us/article/Learn-about-Office-365-groups-b565caa1-5c40-40ef-9915-60fdb2d97fa2'
},
{
'display': 'HubiC',
'type': 'hc',
'id': 'hubic',
'scope': 'credentials.r',
'servicelink': 'https://hubic.com'
},
{
'display': 'Amazon Cloud Drive',
'type': 'amz',
'id': 'amzcd',
'scope': 'clouddrive:read_other clouddrive:write',
'servicelink': 'https://www.amazon.com/clouddrive/home'
},
{
'display': 'Box.com',
'type': 'box',
'id': 'box.com',
'scope': 'root_readwrite',
'servicelink': 'https://www.box.com/pricing/personal/'
},
{
'display': 'Box.com',
'type': 'box',
'id': 'box',
'scope': 'root_readwrite',
'servicelink': 'https://www.box.com/pricing/personal/',
'hidden': True
},
{
'display': 'Dropbox',
'type': 'dropbox',
'id': 'dropbox',
'scope': 'files.content.write files.content.read files.metadata.read files.metadata.write',
'extraurl': 'token_access_type=offline',
'servicelink': 'https://dropbox.com'
},
{
'display': 'Jottacloud',
'type': 'jottacloud',
'id': 'jottacloud',
'scope': 'openid offline_access',
'servicelink': 'https://jottacloud.com'
}
]
try:
from config import POST_CONFIG
POST_CONFIG(LOOKUP, SERVICES)
except ImportError:
pass