mirrored from https://chromium.googlesource.com/infra/luci/luci-py
-
Notifications
You must be signed in to change notification settings - Fork 36
/
handlers_backend.py
91 lines (71 loc) · 2.55 KB
/
handlers_backend.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
# Copyright 2014 The LUCI Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
"""This module defines Auth Server backend url handlers."""
import webapp2
from components import decorators
from components.auth import change_log
import config
import gcs
import importer
import pubsub
import realms
import replication
class InternalRefreshReplicatedAuthDBCronHandler(webapp2.RequestHandler):
@decorators.require_cronjob
def get(self):
replication.refresh_replicated_authdb()
class InternalRevokePubSubAuthCronHandler(webapp2.RequestHandler):
@decorators.require_cronjob
def get(self):
pubsub.revoke_stale_authorization()
gcs.revoke_stale_authorization()
class InternalUpdateConfigCronHandler(webapp2.RequestHandler):
@decorators.require_cronjob
def get(self):
if config.is_remote_configured():
config.refetch_config()
class InternalUpdateRealmsCronHandler(webapp2.RequestHandler):
@decorators.require_cronjob
def get(self):
if config.is_remote_configured():
success = realms.refetch_config()
self.response.set_status(200 if success else 500)
class InternalImportGroupsCronHandler(webapp2.RequestHandler):
@decorators.require_cronjob
def get(self):
importer.import_external_groups()
class InternalReplicationTaskHandler(webapp2.RequestHandler):
@decorators.require_taskqueue('replication')
def post(self, auth_db_rev):
success = replication.update_replicas_task(int(auth_db_rev))
self.response.set_status(200 if success else 500)
def get_routes():
# Backend routes exposed by auth components.
routes = []
routes.extend(change_log.get_backend_routes())
# Auth service's own routes.
routes.extend([
webapp2.Route(
r'/internal/cron/refresh_replicated_authdb',
InternalRefreshReplicatedAuthDBCronHandler),
webapp2.Route(
r'/internal/cron/revoke_stale_pubsub_auth',
InternalRevokePubSubAuthCronHandler),
webapp2.Route(
r'/internal/cron/update_config',
InternalUpdateConfigCronHandler),
webapp2.Route(
r'/internal/cron/update_realms',
InternalUpdateRealmsCronHandler),
webapp2.Route(
r'/internal/cron/import_groups',
InternalImportGroupsCronHandler),
webapp2.Route(
r'/internal/taskqueue/replication/<auth_db_rev:\d+>',
InternalReplicationTaskHandler),
])
return routes
def create_application(debug):
replication.configure_as_primary()
return webapp2.WSGIApplication(get_routes(), debug=debug)