-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.py
34 lines (30 loc) · 977 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# docker compose exec -it percona python3 /opt/test.py
import os
import pam
DJ_AUTH_USER = os.getenv("DJ_AUTH_USER", "")
DJ_AUTH_PASSWORD = os.getenv("DJ_AUTH_PASSWORD", "")
DJ_AUTH_TOKEN = os.getenv("DJ_AUTH_TOKEN", "")
# Test pam_unix via mysqld module
p = pam.pam()
response = p.authenticate(
'ap_user', 'password',
service='mysqld'
)
print(f"Authenticated (pam_unix)? {response}")
print(f"Reason (pam_unix): {p.reason}")
p.close_session()
# Test oidc with user:password
p = pam.pam()
print(f"Authenticating with {DJ_AUTH_USER=}")
response = p.authenticate(
DJ_AUTH_USER, DJ_AUTH_PASSWORD, service="oidc"
)
print(f"Authenticated (oidc user:pass)? {response}")
print(f"Reason (oidc user:pass): {p.reason}")
# Test oidc with user:token
print(f"Authenticating with {DJ_AUTH_USER=}")
response = p.authenticate(
DJ_AUTH_USER, DJ_AUTH_TOKEN, service="oidc"
)
print(f"Authenticated (oidc user:token)? {response}")
print(f"Reason (oidc user:token): {p.reason}")