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:
Lily Kuang
2022-04-12 15:14:08 -07:00
committed by GitHub
parent 59dda1fa05
commit 224769bd45
7 changed files with 246 additions and 3 deletions

View File

@@ -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)