@@ -94,13 +94,23 @@ def check_nonce():
9494 g .api_server = get_api_server (g .tenant )
9595 logger .debug ("tenant associated with nonce: {}" .format (g .tenant ))
9696 # get the actor_id base on the request path
97- actor_id = get_db_id ()
98- logger .debug ("db_id: {}" .format (actor_id ))
97+ actor_id , actor_identifier = get_db_id ()
98+ logger .debug ("db_id: {}; actor_identifier: {} " .format (actor_id , actor_identifier ))
9999 level = required_level (request )
100- Nonce .check_and_redeem_nonce (actor_id , nonce_id , level )
100+
101+ # if the actor_identifier is an alias, then the nonce must be attached to that, so we must pass that in the
102+ # nonce check:
103+ if is_hashid (actor_identifier ):
104+ Nonce .check_and_redeem_nonce (actor_id = actor_id , alias = None , nonce_id = nonce_id , level = level )
105+ else :
106+ alias_id = Alias .generate_alias_id (tenant = g .tenant , alias = actor_identifier )
107+ Nonce .check_and_redeem_nonce (actor_id = None , alias = alias_id , nonce_id = nonce_id , level = level )
101108 # if we were able to redeem the nonce, update auth context with the actor owner data:
102109 logger .debug ("nonce valid and redeemed." )
103- nonce = Nonce .get_nonce (actor_id , nonce_id )
110+ if is_hashid (actor_identifier ):
111+ nonce = Nonce .get_nonce (actor_id = actor_id , alias = None , nonce_id = nonce_id )
112+ else :
113+ nonce = Nonce .get_nonce (actor_id = None , alias = alias_id , nonce_id = nonce_id )
104114 g .user = nonce .owner
105115 # update roles data with that stored on the nonce:
106116 g .roles = nonce .roles
@@ -137,7 +147,7 @@ def authorization():
137147 else :
138148 # every other route should have an actor identifier
139149 logger .debug ("fetching db_id; rule: {}" .format (request .url_rule .rule ))
140- db_id = get_db_id ()
150+ db_id , _ = get_db_id ()
141151 g .db_id = db_id
142152 logger .debug ("db_id: {}" .format (db_id ))
143153
@@ -307,7 +317,7 @@ def check_permissions(user, identifier, level):
307317
308318
309319def get_db_id ():
310- """Get the db_id from the request path."""
320+ """Get the db_id and actor_identifier from the request path."""
311321 # logger.debug("top of get_db_id. request.path: {}".format(request.path))
312322 path_split = request .path .split ("/" )
313323 if len (path_split ) < 3 :
@@ -327,7 +337,7 @@ def get_db_id():
327337 logger .error (msg )
328338 raise ResourceError (msg )
329339 logger .debug ("actor_id: {}" .format (actor_id ))
330- return Actor .get_dbid (g .tenant , actor_id )
340+ return Actor .get_dbid (g .tenant , actor_id ), actor_identifier
331341
332342def get_alias_id ():
333343 """Get the alias from the request path."""
0 commit comments