authorization: send websocket notifications when a user is created or deleted
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
400cefebc8
commit
1af7f7d550
|
@ -147,6 +147,8 @@ class Authorization:
|
||||||
self.server.register_endpoint(
|
self.server.register_endpoint(
|
||||||
"/access/oneshot_token", ['GET'],
|
"/access/oneshot_token", ['GET'],
|
||||||
self._handle_token_request, protocol=['http'])
|
self._handle_token_request, protocol=['http'])
|
||||||
|
self.server.register_notification("authorization:user_created")
|
||||||
|
self.server.register_notification("authorization:user_deleted")
|
||||||
|
|
||||||
async def _handle_apikey_request(self, web_request):
|
async def _handle_apikey_request(self, web_request):
|
||||||
action = web_request.get_action()
|
action = web_request.get_action()
|
||||||
|
@ -281,6 +283,11 @@ class Authorization:
|
||||||
refresh_token = self._generate_jwt(
|
refresh_token = self._generate_jwt(
|
||||||
username, jwt_secret, token_type="refresh",
|
username, jwt_secret, token_type="refresh",
|
||||||
exp_time=datetime.timedelta(days=self.login_timeout))
|
exp_time=datetime.timedelta(days=self.login_timeout))
|
||||||
|
if create:
|
||||||
|
IOLoop.current().call_later(
|
||||||
|
.005, self.server.send_event,
|
||||||
|
"authorization:user_created",
|
||||||
|
{'username': username})
|
||||||
return {
|
return {
|
||||||
'username': username,
|
'username': username,
|
||||||
'token': token,
|
'token': token,
|
||||||
|
@ -303,6 +310,10 @@ class Authorization:
|
||||||
if hashed_pass != user_info['password']:
|
if hashed_pass != user_info['password']:
|
||||||
raise self.server.error("Invalid Password")
|
raise self.server.error("Invalid Password")
|
||||||
del self.users[username]
|
del self.users[username]
|
||||||
|
IOLoop.current().call_later(
|
||||||
|
.005, self.server.send_event,
|
||||||
|
"authorization:user_deleted",
|
||||||
|
{'username': username})
|
||||||
return {
|
return {
|
||||||
"username": username,
|
"username": username,
|
||||||
"action": "user_deleted"
|
"action": "user_deleted"
|
||||||
|
|
Loading…
Reference in New Issue