FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
feast/sdk/python/feast/permissions/user.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
/
user.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
87 lines (69 loc) · 2.7 KB
Breadcrumbs
feast
/
sdk
/
python
/
feast
/
permissions
/
user.py
Copy path
File metadata and controls
87 lines (69 loc) · 2.7 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
import
logging
from
typing
import
Optional
logger
=
logging
.
getLogger
(
__name__
)
class
User
:
_username
:
str
_roles
:
Optional
[
list
[
str
]]
_groups
:
Optional
[
list
[
str
]]
_namespaces
:
Optional
[
list
[
str
]]
def
__init__
(
self
,
username
:
str
,
roles
:
Optional
[
list
[
str
]]
=
None
,
groups
:
Optional
[
list
[
str
]]
=
None
,
namespaces
:
Optional
[
list
[
str
]]
=
None
,
):
self
.
_username
=
username
self
.
_roles
=
roles
if
roles
is
not
None
else
[]
self
.
_groups
=
groups
if
groups
is
not
None
else
[]
self
.
_namespaces
=
namespaces
if
namespaces
is
not
None
else
[]
@
property
def
username
(
self
):
return
self
.
_username
@
property
def
roles
(
self
):
return
self
.
_roles
@
property
def
groups
(
self
):
return
self
.
_groups
@
property
def
namespaces
(
self
):
return
self
.
_namespaces
def
has_matching_role
(
self
,
requested_roles
:
list
[
str
])
->
bool
:
"""
Verify that the user has at least one of the requested roles.
Args:
requested_roles: The list of requested roles.
Returns:
bool: `True` only if the user has any registered role and all the given roles are registered.
"""
logger
.
debug
(
f"Check
{
self
.
username
}
has all
{
requested_roles
}
: currently
{
self
.
roles
}
"
)
return
any
(
role
in
self
.
roles
for
role
in
requested_roles
)
def
has_matching_group
(
self
,
requested_groups
:
list
[
str
])
->
bool
:
"""
Verify that the user has at least one of the requested groups.
Args:
requested_groups: The list of requested groups.
Returns:
bool: `True` only if the user has any registered group and all the given groups are registered.
"""
logger
.
debug
(
f"Check
{
self
.
username
}
has all
{
requested_groups
}
: currently
{
self
.
groups
}
"
)
return
any
(
group
in
self
.
groups
for
group
in
requested_groups
)
def
has_matching_namespace
(
self
,
requested_namespaces
:
list
[
str
])
->
bool
:
"""
Verify that the user has at least one of the requested namespaces.
Args:
requested_namespaces: The list of requested namespaces.
Returns:
bool: `True` only if the user has any registered namespace and all the given namespaces are registered.
"""
logger
.
debug
(
f"Check
{
self
.
username
}
has all
{
requested_namespaces
}
: currently
{
self
.
namespaces
}
"
)
return
any
(
namespace
in
self
.
namespaces
for
namespace
in
requested_namespaces
)
def
__str__
(
self
):
return
f"
{
self
.
username
}
(roles:
{
self
.
roles
}
, groups:
{
self
.
groups
}
, namespaces:
{
self
.
namespaces
}
)"
Back
|
FazBrowse Home
|
New Git URL