mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-09 09:02:12 +00:00
parent
ad341e8259
commit
cd6b28df1a
@ -58,7 +58,13 @@ class SupersetAuthenticationProvider(AuthenticationProvider):
|
|||||||
|
|
||||||
def __init__(self, config: SupersetConfig):
|
def __init__(self, config: SupersetConfig):
|
||||||
self.config = config
|
self.config = config
|
||||||
client_config = ClientConfig(base_url=config.url, api_version="api/v1")
|
client_config = ClientConfig(
|
||||||
|
base_url=config.url,
|
||||||
|
api_version="api/v1",
|
||||||
|
auth_token=lambda: ("no_token", 0),
|
||||||
|
auth_header="Authorization",
|
||||||
|
allow_redirects=True,
|
||||||
|
)
|
||||||
self.client = REST(client_config)
|
self.client = REST(client_config)
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
@ -69,7 +75,8 @@ class SupersetAuthenticationProvider(AuthenticationProvider):
|
|||||||
def auth_token(self) -> str:
|
def auth_token(self) -> str:
|
||||||
login_request = self._login_request()
|
login_request = self._login_request()
|
||||||
login_response = self.client.post("/security/login", login_request)
|
login_response = self.client.post("/security/login", login_request)
|
||||||
return login_response["access_token"]
|
self.generated_auth_token = login_response["access_token"]
|
||||||
|
self.expiry = 0
|
||||||
|
|
||||||
def _login_request(self) -> str:
|
def _login_request(self) -> str:
|
||||||
auth_request = {
|
auth_request = {
|
||||||
@ -80,6 +87,10 @@ class SupersetAuthenticationProvider(AuthenticationProvider):
|
|||||||
}
|
}
|
||||||
return json.dumps(auth_request)
|
return json.dumps(auth_request)
|
||||||
|
|
||||||
|
def get_access_token(self):
|
||||||
|
self.auth_token()
|
||||||
|
return (self.generated_auth_token, self.expiry)
|
||||||
|
|
||||||
|
|
||||||
class SupersetAPIClient:
|
class SupersetAPIClient:
|
||||||
"""
|
"""
|
||||||
@ -95,7 +106,7 @@ class SupersetAPIClient:
|
|||||||
client_config = ClientConfig(
|
client_config = ClientConfig(
|
||||||
base_url=config.url,
|
base_url=config.url,
|
||||||
api_version="api/v1",
|
api_version="api/v1",
|
||||||
auth_token=f"{self._auth_provider.auth_token()}",
|
auth_token=lambda: self._auth_provider.get_access_token(),
|
||||||
auth_header="Authorization",
|
auth_header="Authorization",
|
||||||
allow_redirects=True,
|
allow_redirects=True,
|
||||||
)
|
)
|
||||||
|
@ -278,17 +278,18 @@ class SupersetSource(Source[Entity]):
|
|||||||
entity=Lineage_Dashboard,
|
entity=Lineage_Dashboard,
|
||||||
fqdn=f"{self.config.service_name}.{dashboard['id']}",
|
fqdn=f"{self.config.service_name}.{dashboard['id']}",
|
||||||
)
|
)
|
||||||
lineage = AddLineageRequest(
|
if from_entity and to_entity:
|
||||||
edge=EntitiesEdge(
|
lineage = AddLineageRequest(
|
||||||
fromEntity=EntityReference(
|
edge=EntitiesEdge(
|
||||||
id=from_entity.id.__root__, type="table"
|
fromEntity=EntityReference(
|
||||||
),
|
id=from_entity.id.__root__, type="table"
|
||||||
toEntity=EntityReference(
|
),
|
||||||
id=to_entity.id.__root__, type="dashboard"
|
toEntity=EntityReference(
|
||||||
),
|
id=to_entity.id.__root__, type="dashboard"
|
||||||
|
),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
yield lineage
|
||||||
yield lineage
|
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.debug(traceback.print_exc())
|
logger.debug(traceback.print_exc())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user