mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
feat(embedded): API get embedded dashboard config by uuid (#19650)
* feat(embedded): get embedded dashboard config by uuid * add tests and validation * remove accidentally commit * fix tests
This commit is contained in:
@@ -25,6 +25,9 @@ from flask_wtf.csrf import generate_csrf
|
||||
from marshmallow import EXCLUDE, fields, post_load, Schema, ValidationError
|
||||
from marshmallow_enum import EnumField
|
||||
|
||||
from superset.embedded_dashboard.commands.exceptions import (
|
||||
EmbeddedDashboardNotFoundError,
|
||||
)
|
||||
from superset.extensions import event_logger
|
||||
from superset.security.guest_token import GuestTokenResourceType
|
||||
|
||||
@@ -142,13 +145,16 @@ class SecurityRestApi(BaseApi):
|
||||
"""
|
||||
try:
|
||||
body = guest_token_create_schema.load(request.json)
|
||||
self.appbuilder.sm.validate_guest_token_resources(body["resources"])
|
||||
|
||||
# todo validate stuff:
|
||||
# make sure the resource ids are valid
|
||||
# make sure username doesn't reference an existing user
|
||||
# check rls rules for validity?
|
||||
token = self.appbuilder.sm.create_guest_access_token(
|
||||
body["user"], body["resources"], body["rls"]
|
||||
)
|
||||
return self.response(200, token=token)
|
||||
except EmbeddedDashboardNotFoundError as error:
|
||||
return self.response_400(message=error.message)
|
||||
except ValidationError as error:
|
||||
return self.response_400(message=error.messages)
|
||||
|
||||
Reference in New Issue
Block a user