FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
feast/sdk/python/feast/permissions/auth_model.py at master · feast-dev/feast · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
feast-dev
/
feast
Public
Notifications
You must be signed in to change notification settings
Fork
1.4k
Star
7.2k
Code
Issues
218
Pull requests
191
Discussions
Actions
Security and quality
1
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
feast
/
sdk
/
python
/
feast
/
permissions
/
auth_model.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
97 lines (77 loc) · 3.69 KB
Breadcrumbs
feast
/
sdk
/
python
/
feast
/
permissions
/
auth_model.py
Copy path
File metadata and controls
97 lines (77 loc) · 3.69 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from
__future__
import
annotations
from
typing
import
Literal
,
Optional
,
Tuple
from
pydantic
import
ConfigDict
,
Field
,
model_validator
from
feast
.
repo_config
import
FeastConfigBaseModel
def
_check_mutually_exclusive
(
**
groups
:
Tuple
[
object
, ...])
->
None
:
"""Validate that at most one named group is configured, and completely.
Each *group* is a tuple of field values.
A group is **active** only when *all* its values are truthy.
A group is **partial** (error) when *any* but not *all* values are truthy.
At most one active group may exist.
"""
partial
=
[
name
for
name
,
vals
in
groups
.
items
()
if
any
(
vals
)
and
not
all
(
vals
)]
if
partial
:
raise
ValueError
(
f"Incomplete configuration for '
{
partial
[
0
]
}
': "
f"configure all of these fields together, or none at all. "
f"Check the documentation for valid credential combinations."
)
active
=
[
name
for
name
,
vals
in
groups
.
items
()
if
all
(
vals
)]
if
len
(
active
)
>
1
:
raise
ValueError
(
f"Only one of [
{
', '
.
join
(
groups
)
}
] may be set, "
f"but got:
{
', '
.
join
(
active
)
}
"
)
class
AuthConfig
(
FeastConfigBaseModel
):
type
:
Literal
[
"oidc"
,
"kubernetes"
,
"no_auth"
]
=
"no_auth"
class
OidcAuthConfig
(
AuthConfig
):
auth_discovery_url
:
str
client_id
:
Optional
[
str
]
=
None
ui_client_id
:
Optional
[
str
]
=
None
verify_ssl
:
bool
=
True
ca_cert_path
:
str
=
""
# When set, incoming tokens must carry a matching `aud` / `iss` claim;
# when left unset (the default), the corresponding claim is not verified.
# Set these to the values your IdP puts in the token itself, which may
# differ from the discovery document (e.g. Entra ID v1.0 tokens validated
# against a v2.0 discovery URL).
audience
:
Optional
[
str
]
=
None
issuer
:
Optional
[
str
]
=
None
# How long the fetched JWK set is reused before the server refetches it.
# This also bounds how long a key the IdP has revoked keeps validating
# tokens, so lower it if your provider rotates or revokes aggressively;
# every reduction costs a corresponding increase in JWKS fetches.
jwks_cache_lifespan_seconds
:
int
=
Field
(
default
=
300
,
gt
=
0
)
# Network timeout for the JWKS fetch. This fetch happens inline on the
# request path, so an unresponsive IdP blocks serving for at most this
# long.
jwks_request_timeout_seconds
:
float
=
Field
(
default
=
10
,
gt
=
0
)
class
OidcClientAuthConfig
(
OidcAuthConfig
):
auth_discovery_url
:
Optional
[
str
]
=
None
# type: ignore[assignment]
client_id
:
Optional
[
str
]
=
None
username
:
Optional
[
str
]
=
None
password
:
Optional
[
str
]
=
None
client_secret
:
Optional
[
str
]
=
None
token
:
Optional
[
str
]
=
None
token_env_var
:
Optional
[
str
]
=
None
# Stop reusing an IdP-issued token this many seconds before it expires,
# so a reused token still has life left when the server validates it.
# Raise it if clients see sporadic 401s from clock skew or slow calls;
# lower it to squeeze more reuse out of short-lived tokens.
token_refresh_margin_seconds
:
float
=
Field
(
default
=
30
,
gt
=
0
)
@
model_validator
(
mode
=
"after"
)
def
_validate_credentials
(
self
):
network
=
(
self
.
client_secret
,
self
.
auth_discovery_url
,
self
.
client_id
)
if
self
.
username
or
self
.
password
:
network
+=
(
self
.
username
,
self
.
password
)
_check_mutually_exclusive
(
token
=
(
self
.
token
,),
token_env_var
=
(
self
.
token_env_var
,),
client_credentials
=
network
,
)
return
self
class
NoAuthConfig
(
AuthConfig
):
pass
class
KubernetesAuthConfig
(
AuthConfig
):
user_token
:
Optional
[
str
]
=
None
model_config
=
ConfigDict
(
arbitrary_types_allowed
=
True
,
extra
=
"allow"
)
Back
|
FazBrowse Home
|
New Git URL