X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fauthconn.py;h=15d0d99747c6461153ad91a1d7f7de1abfd6b1e8;hp=b408052d3b762fffea015f8107c4d2f3c633af8b;hb=a50357015c2cc8b3392dd8313cd592b38775bb9f;hpb=1f029d84b9597d3986a33dcd847b0d97d2bad077 diff --git a/osm_nbi/authconn.py b/osm_nbi/authconn.py index b408052..15d0d99 100644 --- a/osm_nbi/authconn.py +++ b/osm_nbi/authconn.py @@ -31,13 +31,20 @@ from http import HTTPStatus class AuthException(Exception): """ - Authentication error. + Authentication error, because token, user password not recognized """ def __init__(self, message, http_code=HTTPStatus.UNAUTHORIZED): super(AuthException, self).__init__(message) self.http_code = http_code +class AuthExceptionUnauthorized(AuthException): + """ + Authentication error, because not having rights to make this operation + """ + pass + + class AuthconnException(Exception): """ Common and base class Exception for all authconn exceptions. @@ -112,13 +119,13 @@ class Authconn: """ self.config = config - def authenticate(self, user, password, project=None, token=None): + def authenticate(self, user, password, project=None, token_info=None): """ - Authenticate a user using username/password or token, plus project + Authenticate a user using username/password or token_info, plus project :param user: user: name, id or None :param password: password or None :param project: name, id, or None. If None first found project will be used to get an scope token - :param token: previous token to obtain authorization + :param token_info: previous token_info to obtain authorization :return: the scoped token info or raises an exception. The token is a dictionary with: _id: token string id, username: username,