py-auth-micro 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/PKG-INFO +1 -1
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/Core/_ldap_interactions.py +0 -1
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/LoginHandler/__init__.py +1 -1
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/LoginHandler/_loginldap.py +3 -2
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/LoginHandler/_loginlocal.py +3 -4
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/Models/_token.py +8 -7
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/Models/_user.py +7 -9
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/WorkFlows/_userworkflow.py +16 -22
- py_auth_micro-0.2.2/py_auth_micro/_version.py +1 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro.egg-info/PKG-INFO +1 -1
- py_auth_micro-0.2.1/py_auth_micro/_version.py +0 -1
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/LICENSE +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/README.rst +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/Config/__init__.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/Config/_appconfig.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/Config/_dbconfig.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/Config/_ldapconfig.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/Core/__init__.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/Core/_enums.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/Exceptions/__init__.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/LoginHandler/_loginbaseclass.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/Models/__init__.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/Models/_group.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/WorkFlows/__init__.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/WorkFlows/_groupworkflow.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/WorkFlows/_misc.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/WorkFlows/_sessionworkflow.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro/__init__.py +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro.egg-info/SOURCES.txt +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro.egg-info/dependency_links.txt +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro.egg-info/requires.txt +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/py_auth_micro.egg-info/top_level.txt +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/setup.cfg +0 -0
- {py_auth_micro-0.2.1 → py_auth_micro-0.2.2}/setup.py +0 -0
|
@@ -60,7 +60,7 @@ async def login(
|
|
|
60
60
|
password=password,
|
|
61
61
|
)
|
|
62
62
|
if not await login_handler.login():
|
|
63
|
-
logger.
|
|
63
|
+
logger.error(f"Could not log in User '{username}'!")
|
|
64
64
|
raise ValueError("could not log in")
|
|
65
65
|
logger.info(f"User '{username}' successfully logged in.")
|
|
66
66
|
return login_handler.user
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
try:
|
|
2
|
-
import ldap
|
|
2
|
+
import ldap # type: ignore
|
|
3
3
|
except ImportError:
|
|
4
4
|
pass
|
|
5
5
|
import logging
|
|
@@ -9,6 +9,8 @@ from ..Config import LDAPConfig
|
|
|
9
9
|
from ..Core import LDAPHelper
|
|
10
10
|
from ..Models import User, Group
|
|
11
11
|
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
12
14
|
|
|
13
15
|
class LoginLDAP(LoginBaseClass):
|
|
14
16
|
"""Login Provider for LDAP/AD Users
|
|
@@ -34,7 +36,6 @@ class LoginLDAP(LoginBaseClass):
|
|
|
34
36
|
Returns:
|
|
35
37
|
bool: Successfull Login
|
|
36
38
|
"""
|
|
37
|
-
logger = logging.getLogger(__name__)
|
|
38
39
|
|
|
39
40
|
if self.ldap_config is None:
|
|
40
41
|
logger.debug("no ldap_config provided... can't do ldap logins")
|
|
@@ -4,6 +4,8 @@ import logging
|
|
|
4
4
|
from ..Models import User
|
|
5
5
|
from ._loginbaseclass import LoginBaseClass
|
|
6
6
|
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
class LoginLocal(LoginBaseClass):
|
|
9
11
|
"""Login Handler for Local Users
|
|
@@ -27,13 +29,10 @@ class LoginLocal(LoginBaseClass):
|
|
|
27
29
|
Returns:
|
|
28
30
|
bool: Successfull Login
|
|
29
31
|
"""
|
|
30
|
-
logger = logging.getLogger(__name__)
|
|
31
|
-
logger.debug(f"tyring to login {self.username} Localy")
|
|
32
32
|
|
|
33
|
+
logger.debug(f"tyring to login {self.username} Localy")
|
|
33
34
|
pw_hash = self.user.password_hash
|
|
34
|
-
|
|
35
35
|
pw_matches = bcrypt.checkpw(self.password.encode("utf-8"), pw_hash)
|
|
36
|
-
|
|
37
36
|
logger.debug(f"PW matches for User '{self.username}': {pw_matches}")
|
|
38
37
|
|
|
39
38
|
return pw_matches
|
|
@@ -16,6 +16,9 @@ from jwt_helper import SignMethod, JWTEncoder, JWTValidator
|
|
|
16
16
|
from py_auth_micro.Config import AppConfig
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
|
|
19
22
|
class Token(Model):
|
|
20
23
|
"""Databse Entity Holding Information around issued Identity Tokens
|
|
21
24
|
|
|
@@ -84,8 +87,8 @@ Valid Options>
|
|
|
84
87
|
Returns:
|
|
85
88
|
str: The ID-JWT
|
|
86
89
|
"""
|
|
87
|
-
|
|
88
|
-
logger.
|
|
90
|
+
|
|
91
|
+
logger.debug(f"creating ID-Token JWT with id: {self.token_id}")
|
|
89
92
|
usergroups = await self.user.groups.all().values_list("name", flat=True)
|
|
90
93
|
|
|
91
94
|
token = jwt_encoder.create_jwt(
|
|
@@ -123,8 +126,7 @@ Valid Options>
|
|
|
123
126
|
Returns:
|
|
124
127
|
Token: the matched Database Token instance.
|
|
125
128
|
"""
|
|
126
|
-
logger
|
|
127
|
-
logger.info(f"verifying ID-Token from {ip}")
|
|
129
|
+
logger.debug(f"verifying ID-Token from {ip}")
|
|
128
130
|
logger.debug(f"token: {id_jwt}")
|
|
129
131
|
token_content = jwt_validator.get_jwt_as_dict(id_jwt) # type: dict[str, dict]
|
|
130
132
|
|
|
@@ -150,7 +152,7 @@ Valid Options>
|
|
|
150
152
|
logger.error("VHost missmatch!")
|
|
151
153
|
raise ValueError("VHost missmatch!")
|
|
152
154
|
|
|
153
|
-
logger.
|
|
155
|
+
logger.debug("Token is valid")
|
|
154
156
|
# return the Token from the Database
|
|
155
157
|
return token
|
|
156
158
|
|
|
@@ -167,8 +169,7 @@ Valid Options>
|
|
|
167
169
|
Returns:
|
|
168
170
|
str: a JWT Token
|
|
169
171
|
"""
|
|
170
|
-
logger
|
|
171
|
-
logger.info("creating Access-Token")
|
|
172
|
+
logger.debug("creating Access-Token")
|
|
172
173
|
usergroups = await (await self.user).groups.all().values_list("name", flat=True)
|
|
173
174
|
logger.debug(f"Token Groups: {usergroups}")
|
|
174
175
|
return jwt_encoder.create_jwt(
|
|
@@ -10,7 +10,7 @@ from tortoise.fields import (
|
|
|
10
10
|
BinaryField,
|
|
11
11
|
BooleanField,
|
|
12
12
|
ManyToManyField,
|
|
13
|
-
|
|
13
|
+
OneToOneRelation
|
|
14
14
|
)
|
|
15
15
|
from tortoise.models import Model
|
|
16
16
|
from jwt_helper import JWTEncoder
|
|
@@ -19,6 +19,8 @@ from py_auth_micro.Core import AuthSource
|
|
|
19
19
|
from py_auth_micro.Config import AppConfig
|
|
20
20
|
from py_auth_micro.Models._token import Token
|
|
21
21
|
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
22
24
|
|
|
23
25
|
class User(Model):
|
|
24
26
|
"""Model Representing a User
|
|
@@ -76,7 +78,7 @@ class User(Model):
|
|
|
76
78
|
backward_key="name",
|
|
77
79
|
)
|
|
78
80
|
|
|
79
|
-
token:
|
|
81
|
+
token: OneToOneRelation[Token]
|
|
80
82
|
|
|
81
83
|
async def create_id_token(
|
|
82
84
|
self,
|
|
@@ -96,8 +98,7 @@ class User(Model):
|
|
|
96
98
|
Returns:
|
|
97
99
|
Token: _description_
|
|
98
100
|
"""
|
|
99
|
-
logger
|
|
100
|
-
logger.info(f"creating token for {self.username}")
|
|
101
|
+
logger.debug(f"creating token for {self.username}")
|
|
101
102
|
# check if old Token exists
|
|
102
103
|
token = await Token.get_or_none(user=self.username)
|
|
103
104
|
|
|
@@ -130,12 +131,9 @@ class User(Model):
|
|
|
130
131
|
Returns:
|
|
131
132
|
bool: The Token got revoked.
|
|
132
133
|
"""
|
|
133
|
-
logger
|
|
134
|
-
logger.info(f"revoking ID-Token for {self.username}")
|
|
134
|
+
logger.debug(f"revoking ID-Token for {self.username}")
|
|
135
135
|
if self.token is not None:
|
|
136
|
-
|
|
137
|
-
for token in tokens:
|
|
138
|
-
await token.delete()
|
|
136
|
+
await self.token.delete()
|
|
139
137
|
return True
|
|
140
138
|
|
|
141
139
|
def __str__(self):
|
|
@@ -26,9 +26,7 @@ class UserWorkflow:
|
|
|
26
26
|
jwt_validator: JWTValidator
|
|
27
27
|
app_cfg: AppConfig
|
|
28
28
|
|
|
29
|
-
async def get_all(
|
|
30
|
-
self, *, access_token: str, **kwargs
|
|
31
|
-
) -> dict:
|
|
29
|
+
async def get_all(self, *, access_token: str, **kwargs) -> dict:
|
|
32
30
|
"""Returns a list of all Usernames.
|
|
33
31
|
|
|
34
32
|
Args:
|
|
@@ -181,34 +179,30 @@ class UserWorkflow:
|
|
|
181
179
|
if user.username != requesting_user and not is_admin:
|
|
182
180
|
return {"resp_code": 200, "resp_data": user_dict}
|
|
183
181
|
|
|
184
|
-
tokens = await user.token
|
|
185
|
-
# in theory a user could have multiple id tokens
|
|
186
|
-
|
|
187
182
|
# add groups
|
|
188
183
|
user_dict["groups"] = await user.groups.all().values_list("name", flat=True)
|
|
189
184
|
|
|
190
|
-
|
|
185
|
+
token = await user.token
|
|
186
|
+
|
|
187
|
+
if token is None:
|
|
191
188
|
user_dict["token_info"] = None
|
|
192
189
|
return {"resp_code": 200, "resp_data": user_dict}
|
|
193
190
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
"vhost": token.vhost,
|
|
200
|
-
}
|
|
191
|
+
user_dict["token_info"] = {
|
|
192
|
+
"valid_until": token.valid_until.isoformat(),
|
|
193
|
+
"last_use": token.last_use.isoformat(),
|
|
194
|
+
"vhost": token.vhost,
|
|
195
|
+
}
|
|
201
196
|
|
|
202
197
|
if is_admin:
|
|
203
198
|
user_dict["auth_type"] = user.auth_type.name
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
)
|
|
199
|
+
user_dict["token_info"].update(
|
|
200
|
+
{
|
|
201
|
+
"kid": token.token_id,
|
|
202
|
+
"ip": token.ip,
|
|
203
|
+
"sign_method": token.sign_method.value,
|
|
204
|
+
} # type: ignore
|
|
205
|
+
)
|
|
212
206
|
|
|
213
207
|
return {"resp_code": 200, "resp_data": user_dict}
|
|
214
208
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.2"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|