FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
feast/sdk/python/feast/permissions/decorator.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
/
decorator.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (33 loc) · 1.41 KB
Breadcrumbs
feast
/
sdk
/
python
/
feast
/
permissions
/
decorator.py
Copy path
File metadata and controls
42 lines (33 loc) · 1.41 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
import
logging
from
typing
import
Union
from
feast
.
permissions
.
action
import
AuthzedAction
from
feast
.
permissions
.
matcher
import
is_a_feast_object
from
feast
.
permissions
.
security_manager
import
assert_permissions
logger
=
logging
.
getLogger
(
__name__
)
def
require_permissions
(
actions
:
Union
[
list
[
AuthzedAction
],
AuthzedAction
]):
"""
A decorator to define the actions that are executed from the decorated class method and that must be protected
against unauthorized access.
The first parameter of the protected method must be `self`
Args:
actions: The list of actions that must be permitted to the current user.
"""
def
require_permissions_decorator
(
func
):
def
permission_checker
(
*
args
,
**
kwargs
):
logger
.
debug
(
f"permission_checker for
{
args
}
,
{
kwargs
}
"
)
resource
=
args
[
0
]
if
not
is_a_feast_object
(
resource
):
raise
NotImplementedError
(
f"The first argument is not of a managed type but
{
type
(
resource
)
}
"
)
return
assert_permissions
(
resource
=
resource
,
actions
=
actions
,
)
logger
.
debug
(
f"Current User can invoke
{
actions
}
on
{
resource
.
name
}
:
{
type
(
resource
)
}
"
)
result
=
func
(
*
args
,
**
kwargs
)
return
result
return
permission_checker
return
require_permissions_decorator
Back
|
FazBrowse Home
|
New Git URL