Ë "�—S­Ã§âãó4—dZGd„de«ZGd„de«Zy)a@ AAA concept ----------- AAA refers to Authentication, Authorization and Accounting. NDB provides a minimalistic API to integrate Authorization routines, leaving the rest -- Authentication and Accounting -- to the user. Some of NDB routines and RTNL object methods are guarded with a parametrized decorator. The decorator takes the only parameter `tag`:: @check_auth('obj:read') def __getitem__(self, key): ... @check_auth('obj:modify') def __setitem__(self, key, value): ... AuthManager ----------- The tag is checked by `AuthManager.check(...)` routine. The routine is the only method that must be provided by AuthManager-compatible objects, and must be defined as:: def check(self, obj, tag): # -> True: grant access to the tag # -> False: reject access # -> raise Exception(): reject access with a specific exception ... NDB module provides an example AuthManager:: from pyroute2 import NDB from pyroute2.ndb.auth_manager import AuthManager ndb = NDB(log='debug') am = AuthManager({'obj:list': False, # deny dump(), summary() 'obj:read': True, # permit reading RTNL attributes 'obj:modify': True}, # permit add_ip(), commit() etc. ndb.log.channel('auth')) ap = ndb.auth_proxy(am) ap.interfaces.summary() # <-- fails with PermissionError You can implement custom AuthManager classes, the only requirement -- they must provide `.check(self, obj, tag)` routine, which returns `True` or `False` or raises an exception. có—eZdZd„Zd„Zy)Ú check_authcó—||_y©N)Útag)Úselfrs ú>/usr/lib/python3.12/site-packages/pyroute2/ndb/auth_manager.pyÚ__init__zcheck_auth.__init__9s €Øˆ�ócó8‡‡—ˆˆfd„}‰j|_|S)Nc ó•—t|dd«s ‰|g|¢­i|¤ŽS|js td«‚t|jD�cgc]}|j |‰j «‘Œ c}«r ‰|g|¢­i|¤ŽStd«‚cc}w)NÚ_init_completeTzaccess rejected)ÚgetattrÚ auth_managersÚPermissionErrorÚallÚcheckr)ÚobjÚargvÚkwargÚxÚfrs €€rÚguardz"check_auth.__call__..guard=s�ø€Ü˜3Ð 0°$Ô7Ù˜Ð-˜tÒ- uÑ-Ð-Ø×$Ò$Ü%Ð&7Ó8Ð8ܰC×4EÒ4EÓFÑ4E¨q�A—G‘G˜C §¡Õ*Ð4EÑFÔGÙ˜Ð-˜tÒ- uÑ-Ð-Ü!Ð"3Ó4Ð 4ùòGsÁ#B)Ú__doc__)rrrs`` rÚ__call__zcheck_auth.__call__<sù€õ 5🠙 ˆŒ ؈ r N)Ú__name__Ú __module__Ú __qualname__r r©r rrr8s „òó r rcó—eZdZdd„Zd„Zy)Ú AuthManagercóD—||_||_||_t|_yr)ÚauthÚlogÚpolicyrÚ exception)rr"r#r$s rr zAuthManager.__init__Ks€ØˆŒ ؈ŒØˆŒ Ü(ˆ�r cóâ—|j}t|jt«r&|jj ||j«}|s |j r|j |›d�«‚|S)Nz access rejected)r$Ú isinstancer"ÚdictÚgetr%)rrrÚrets rrzAuthManager.checkQsQ€Ø�k‰kˆÜ �d—i‘i¤Ô &Ø—)‘)—-‘-  T§[¡[Ó1ˆCÙ�t—~’~Ø—.‘.ºÐ!>Ó?Ð ?؈ r N)F)rrrr rrr rr r Js „ó)ó r r N)rÚobjectrr rr rÚr,s#ðñ4ôn�ôô$ �&õ r