Skip to content

Commit fc44222

Browse files
allenovntkathole
authored andcommitted
feat(auth): support client-credentials & static token for OIDC client auth
Signed-off-by: allenov <allenov@webshark34.ru>
1 parent 795fc06 commit fc44222

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

sdk/python/feast/permissions/auth_model.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
from feast.repo_config import FeastConfigBaseModel
1515

1616
# pick the correct validator decorator for current Pydantic version
17-
try: # Pydantic ≥ 2.0
17+
try: # Pydantic ≥ 2.0
1818
from pydantic import model_validator as _v2 # type: ignore
1919

2020
def _cred_validator(fn):
21-
return _v2(mode="after")(fn) # run after field validation
22-
except ImportError: # Pydantic 1.x
21+
return _v2(mode="after")(fn) # run after field validation
22+
except ImportError: # Pydantic 1.x
2323
from pydantic import root_validator as _v1 # type: ignore
2424

2525
def _cred_validator(fn):
@@ -37,19 +37,19 @@ class OidcAuthConfig(AuthConfig):
3737

3838
class OidcClientAuthConfig(OidcAuthConfig):
3939
# any **one** of the four fields below is sufficient
40-
username: Optional[str] = None
41-
password: Optional[str] = None
40+
username: Optional[str] = None
41+
password: Optional[str] = None
4242
client_secret: Optional[str] = None
43-
token: Optional[str] = None # pre-issued `token`
43+
token: Optional[str] = None # pre-issued `token`
4444

4545
@_cred_validator
4646
def _validate_credentials(cls, values):
4747
"""Enforce exactly one valid credential set."""
4848
d = values.__dict__ if hasattr(values, "__dict__") else values
4949

50-
has_user_pass = bool(d.get("username")) and bool(d.get("password"))
51-
has_secret = bool(d.get("client_secret"))
52-
has_token = bool(d.get("token"))
50+
has_user_pass = bool(d.get("username")) and bool(d.get("password"))
51+
has_secret = bool(d.get("client_secret"))
52+
has_token = bool(d.get("token"))
5353

5454
# 1 static token
5555
if has_token and not (has_user_pass or has_secret):

sdk/python/feast/repo_config.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,13 +312,18 @@ def auth_config(self):
312312
# 1) ROPG – username + password + client_secret
313313
# 2) client-credentials – client_secret only
314314
# 3) static token – token
315-
is_oidc_client = (
316-
self.auth.get("type") == AuthType.OIDC.value
317-
and (
318-
("username" in self.auth and "password" in self.auth and "client_secret" in self.auth) # 1
319-
or ("client_secret" in self.auth and "username" not in self.auth and "password" not in self.auth) # 2
320-
or ("token" in self.auth) # 3
321-
)
315+
is_oidc_client = self.auth.get("type") == AuthType.OIDC.value and (
316+
(
317+
"username" in self.auth
318+
and "password" in self.auth
319+
and "client_secret" in self.auth
320+
) # 1
321+
or (
322+
"client_secret" in self.auth
323+
and "username" not in self.auth
324+
and "password" not in self.auth
325+
) # 2
326+
or ("token" in self.auth) # 3
322327
)
323328
self._auth = get_auth_config_from_type(
324329
"oidc_client" if is_oidc_client else self.auth.get("type")

0 commit comments

Comments
 (0)