-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ssh_tunnel): SQLAlchemy Form UI #22513
Merged
Merged
Changes from 146 commits
Commits
Show all changes
151 commits
Select commit
Hold shift + click to select a range
830a283
save
hughhhh 2c1e736
create migration
hughhhh f78df83
created schema and rename
hughhhh d482df4
linting
hughhhh 9edb581
fix encrpytions
hughhhh da27d8f
remove map tabl
hughhhh 773a6c8
fix linting
hughhhh 2f2dda2
add constraint
hughhhh fd0d7f2
add fk to migration
hughhhh 158da8d
init
hughhhh face73f
update all the examples
hughhhh 95d079e
change remaining bits
hughhhh d5926e3
add id
hughhhh f7a6a41
use factory instead
hughhhh 30e380a
Merge branch 'master' of https://github.com/apache/superset into crea…
hughhhh 87c0d79
Merge branch 'master' into ref-get-sqla-engine-2
hughhhh 11b240b
fix confict
hughhhh 1bfdbda
fix conflict
hughhhh 4146d5a
setup return value for contextmanager
hughhhh f8b877d
add sshtunnel pip
hughhhh 54fc147
updates test
hughhhh fdc6ca3
fix linting
hughhhh 66c0801
renaming function
hughhhh 1f9ec5e
fix test
hughhhh c698cf4
Merge branch 'ref-get-sqla-engine-2' of https://github.com/apache/sup…
hughhhh 41bd19b
add schema to test_connection api
hughhhh 8811a99
fix get engine to return contextmanager
hughhhh 82d7532
why
hughhhh 1f829ac
yerp
hughhhh d53d116
update typing
hughhhh 752161d
update comment
hughhhh 8c4b081
Merge branch 'ref-get-sqla-engine-2' of https://github.com/apache/sup…
hughhhh 1a19a97
save
hughhhh 58b9cce
save
hughhhh 0ac6fb1
Merge branch 'master' of https://github.com/apache/superset into ref-…
hughhhh 31f3c1d
fix pylint
hughhhh a0b30e6
Merge branch 'ref-get-sqla-engine-2' of https://github.com/apache/sup…
hughhhh e089a8d
last one
hughhhh 81b2f88
Merge branch 'ref-get-sqla-engine-2' of https://github.com/apache/sup…
hughhhh 45686b7
update naming on ssh tunnel
hughhhh 7ce5836
Merge branch 'master' into ref-get-sqla-engine-2
hughhhh d9c8d0d
Merge branch 'ref-get-sqla-engine-2' of https://github.com/apache/sup…
hughhhh ec27b80
fix renaming
hughhhh 65e3e29
fix renaming 2
hughhhh 9fa9db5
Merge branch 'master' of https://github.com/apache/superset into crea…
hughhhh 1a11ff4
oops
hughhhh 3f0dae1
fix linting errors
hughhhh 2777807
feat(ssh_tunnel): DAO Changes for SSH Tunnel (#22120)
Antonio-RiveroMartnez 8ed02cd
fix merge conflicts
hughhhh 6a68147
Merge branch 'create-sshtunnelconfig-tbl' of https://github.com/apach…
hughhhh 6bd32e8
feat(ssh_tunnel): Delete command & exceptions (#22131)
Antonio-RiveroMartnez 8a3ee35
Merge branch 'master' of https://github.com/apache/superset into crea…
hughhhh bc89194
Merge branch 'create-sshtunnelconfig-tbl' of https://github.com/apach…
hughhhh adb9451
fix indenting for superset/databases/commands/validate.py
hughhhh 16d960b
change tablename
hughhhh d2ab4a6
feat(ssh_tunnel): DELETE SSH Tunnels API (#22153)
Antonio-RiveroMartnez fb2acd0
Revert "feat(ssh_tunnel): DELETE SSH Tunnels API" (#22156)
hughhhh 4d807c9
feat(ssh_tunnel): Update command & exceptions (#22132)
Antonio-RiveroMartnez dc0c848
forgot server_port
hughhhh 21fcdf0
bind_port + bind_host :)
hughhhh 68cb75f
oops
hughhhh 44ca56b
fix linting
hughhhh 7e1461e
feat(ssh_tunnel): SSH Tunnel updates from Code Review (#22182)
Antonio-RiveroMartnez 92e41f1
Merge branch 'master' of https://github.com/apache/superset into crea…
hughhhh 6c59663
feat(ssh_tunnel): Create command & exceptions (#22148)
hughhhh 466703a
Update schemas.py
hughhhh 554de53
Merge branch 'master' of https://github.com/apache/superset into crea…
hughhhh 4448739
chore(ssh-tunnel): create `contextmanager` for sql.inspect (#22251)
hughhhh bb78055
fix lint
hughhhh f507385
fix migrations
hughhhh 45aa022
Merge branch 'master' of https://github.com/apache/superset into crea…
hughhhh 3d3b71b
Merge branch 'master' of https://github.com/apache/superset into crea…
hughhhh 86436b6
Revert "chore(ssh-tunnel): create `contextmanager` for sql.inspect (#…
hughhhh 54a8d7f
debugging
hughhhh 3f6afec
fix(ssh_tunnel): Address Base PR comments from peer review (#22306)
Antonio-RiveroMartnez 7625566
fix pre-commit
hughhhh 0578a8e
working changes
hughhhh ec20429
refactor bind_host and bind_port
hughhhh 1f57d4a
refactor create flow for temp ssh tunnels
hughhhh ed19a3e
remove logger
hughhhh 852c8bb
chore(ssh_tunnel): Add extra tests to SSHTunnel commands (#22372)
Antonio-RiveroMartnez be5c005
add flush to allow database.id to be populated
hughhhh 948f748
Merge branch 'create-sshtunnelconfig-tbl' of https://github.com/apach…
hughhhh c636ce7
make sure to use inspector with context
hughhhh 908896f
remove id and database_id
hughhhh e3ef835
uselist
hughhhh a4b1c28
refactor bind_host and bind_port
hughhhh 828d45c
debugging
hughhhh 862288a
SSH Tunnel:
Antonio-RiveroMartnez 5ca158e
SSH Tunnel:
Antonio-RiveroMartnez ade44d3
SSH Tunnel:
Antonio-RiveroMartnez bae36a0
SSH Tunnel:
Antonio-RiveroMartnez e3f99d2
SSH Tunnel:
Antonio-RiveroMartnez 6641f97
SSH Tunnel:
Antonio-RiveroMartnez c7dc836
SSH Tunnel:
Antonio-RiveroMartnez 89c20eb
SSH Tunnel:
Antonio-RiveroMartnez f4b34a2
SSH Tunnel:
Antonio-RiveroMartnez ce842a6
SSH Tunnel:
Antonio-RiveroMartnez 3ae8c86
SSH Tunnel:
Antonio-RiveroMartnez 3faf78c
SSH Tunnel:
Antonio-RiveroMartnez 66fb789
SSH Tunnel:
Antonio-RiveroMartnez cc243bf
SSH Tunnel:
Antonio-RiveroMartnez 8e910f1
SSH Tunnel:
Antonio-RiveroMartnez a5cf0e4
SSH Tunnel:
Antonio-RiveroMartnez c5c50ed
feat(ssh-tunnel): ssh manager config + feature flag (#22201)
hughhhh 06e115b
update kwarg function name
hughhhh 13ed50d
chore(ssh-tunnel): Move SSHManager to extensions pattern (#22433)
hughhhh 54d51e2
add flag to indicate ssh tunneling is enabled for this engine
hughhhh 53eaa63
Update superset/migrations/versions/2022-10-20_10-48_f3c2d8ec8595_cre…
hughhhh 8f8faff
Update superset/migrations/versions/2022-10-20_10-48_f3c2d8ec8595_cre…
hughhhh 607c682
fix linting
hughhhh 367efe6
Merge branch 'create-sshtunnelconfig-tbl' into api_ssh_tunnel
Antonio-RiveroMartnez dffc266
SSH Tunnel:
Antonio-RiveroMartnez 65d3fc9
SSH Tunnel:
Antonio-RiveroMartnez e1815da
SSH Tunnel:
Antonio-RiveroMartnez e16c52b
SSH Tunnel:
Antonio-RiveroMartnez 9da6987
SSH Tunnel:
Antonio-RiveroMartnez 110e0ba
SSH Tunnel:
Antonio-RiveroMartnez b328427
SSH Tunnel UI:
Antonio-RiveroMartnez 1ea0e8b
Merge branch 'master' of https://github.com/apache/superset into crea…
hughhhh d5b4ad2
Merge branch 'create-sshtunnelconfig-tbl' into api_ssh_tunnel
Antonio-RiveroMartnez 5fc7e09
Merge master into ssh_sqla_form
Antonio-RiveroMartnez 7cc7bc8
fix requirements
hughhhh 227029d
Merge branch 'create-sshtunnelconfig-tbl' into api_ssh_tunnel
Antonio-RiveroMartnez 422a86e
Merge branch 'api_ssh_tunnel' into ssh_sqla_form
Antonio-RiveroMartnez 28342a4
SSH Tunnel UI:
Antonio-RiveroMartnez 7c539d2
Merge branch 'master' of https://github.com/apache/superset into crea…
hughhhh 643d25e
SSH Tunnel:
Antonio-RiveroMartnez 846815e
SSH Tunnel:
Antonio-RiveroMartnez 394afc1
get df with get_raw_connection function
hughhhh 052eee1
SSH Tunnel:
Antonio-RiveroMartnez 9b09fc7
feat(ssh_tunnel): APIs for SSH Tunnels (#22199)
Antonio-RiveroMartnez af66b34
Merge branch 'api_ssh_tunnel' into ssh_sqla_form
Antonio-RiveroMartnez 2bb1140
Merge branch 'create-sshtunnelconfig-tbl' into api_ssh_tunnel
Antonio-RiveroMartnez 1170a34
Merge branch 'api_ssh_tunnel' into ssh_sqla_form
Antonio-RiveroMartnez 857e041
SSH Tunnel:
Antonio-RiveroMartnez 27587ec
Merge master
Antonio-RiveroMartnez 1cb7384
SSH Tunnel UI:
Antonio-RiveroMartnez 86db39d
Merge branch 'master' into ssh_sqla_form
Antonio-RiveroMartnez 6a03887
SSH Tunnel UI:
Antonio-RiveroMartnez ff5ec7f
SSH Tunnel UI:
Antonio-RiveroMartnez 213f57a
Merge branch 'master' into ssh_sqla_form
Antonio-RiveroMartnez 1e0161d
Merge branch 'master' into ssh_sqla_form
Antonio-RiveroMartnez e394e7a
SSH Tunnel UI:
Antonio-RiveroMartnez a096122
SSH Tunnel UI:
Antonio-RiveroMartnez 8df08f9
SSH Tunnel UI:
Antonio-RiveroMartnez 26a668d
Merge branch 'master' into ssh_sqla_form
Antonio-RiveroMartnez 97330e1
SSH Tunnel UI:
Antonio-RiveroMartnez 9dd84de
SSH Tunnel UI:
Antonio-RiveroMartnez 2ba8bdc
SSH Tunnel UI:
Antonio-RiveroMartnez cae95ae
SSH Tunnel UI:
Antonio-RiveroMartnez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
265 changes: 265 additions & 0 deletions
265
superset-frontend/src/views/CRUD/data/database/DatabaseModal/SSHTunnelForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,265 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import React, { EventHandler, ChangeEvent, useState } from 'react'; | ||
import { t, SupersetTheme, styled } from '@superset-ui/core'; | ||
import { AntdForm, AntdSwitch, Col, Row } from 'src/components'; | ||
import InfoTooltip from 'src/components/InfoTooltip'; | ||
import { Form, FormLabel } from 'src/components/Form'; | ||
import { Radio } from 'src/components/Radio'; | ||
import { Input, TextArea } from 'src/components/Input'; | ||
import { Input as AntdInput, Tooltip } from 'antd'; | ||
import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons'; | ||
import { isEmpty } from 'lodash'; | ||
import { infoTooltip, toggleStyle } from './styles'; | ||
|
||
import { DatabaseObject } from '../types'; | ||
import { AuthType } from '.'; | ||
|
||
const StyledDiv = styled.div` | ||
padding-top: ${({ theme }) => theme.gridUnit * 2}px; | ||
label { | ||
color: ${({ theme }) => theme.colors.grayscale.base}; | ||
text-transform: uppercase; | ||
margin-bottom: ${({ theme }) => theme.gridUnit * 2}px; | ||
} | ||
`; | ||
|
||
const StyledRow = styled(Row)` | ||
padding-bottom: ${({ theme }) => theme.gridUnit * 2}px; | ||
`; | ||
|
||
const StyledFormItem = styled(AntdForm.Item)` | ||
margin-bottom: 0 !important; | ||
`; | ||
|
||
const StyledInputPassword = styled(AntdInput.Password)` | ||
margin: ${({ theme }) => `${theme.gridUnit}px 0 ${theme.gridUnit * 2}px`}; | ||
`; | ||
|
||
const SSHTunnelForm = ({ | ||
db, | ||
dbFetched, | ||
isEditMode, | ||
sshTunneling, | ||
onSSHTunnelParametersChange, | ||
setSSHTunnelLoginMethod, | ||
removeSSHTunnelConfig, | ||
}: { | ||
db: DatabaseObject | null; | ||
dbFetched: DatabaseObject | null; | ||
isEditMode: boolean; | ||
sshTunneling: boolean; | ||
onSSHTunnelParametersChange: EventHandler< | ||
ChangeEvent<HTMLInputElement | HTMLTextAreaElement> | ||
>; | ||
setSSHTunnelLoginMethod: (method: AuthType) => void; | ||
removeSSHTunnelConfig: () => void; | ||
}) => { | ||
const [useSSHTunneling, setUseSSHTunneling] = useState<boolean>( | ||
!isEmpty(db?.ssh_tunnel), | ||
); | ||
const [usePassword, setUsePassword] = useState<AuthType>(AuthType.password); | ||
|
||
return ( | ||
<Form> | ||
<div css={(theme: SupersetTheme) => infoTooltip(theme)}> | ||
<AntdSwitch | ||
disabled={ | ||
!sshTunneling || (isEditMode && !isEmpty(dbFetched?.ssh_tunnel)) | ||
} | ||
checked={useSSHTunneling} | ||
onChange={changed => { | ||
setUseSSHTunneling(changed); | ||
if (!changed) removeSSHTunnelConfig(); | ||
}} | ||
data-test="ssh-tunnel-switch" | ||
/> | ||
<span css={toggleStyle}>SSH Tunnel</span> | ||
<InfoTooltip | ||
tooltip={t('SSH Tunnel configuration parameters')} | ||
placement="right" | ||
viewBox="0 -5 24 24" | ||
/> | ||
</div> | ||
{useSSHTunneling && ( | ||
<> | ||
<StyledRow gutter={16}> | ||
<Col xs={24} md={12}> | ||
<StyledDiv> | ||
<FormLabel htmlFor="server_address" required> | ||
{t('SSH Host')} | ||
</FormLabel> | ||
<Input | ||
name="server_address" | ||
type="text" | ||
placeholder={t('e.g. 127.0.0.1')} | ||
value={db?.ssh_tunnel?.server_address || ''} | ||
onChange={onSSHTunnelParametersChange} | ||
data-test="ssh-tunnel-server_address-input" | ||
/> | ||
</StyledDiv> | ||
</Col> | ||
<Col xs={24} md={12}> | ||
<StyledDiv> | ||
<FormLabel htmlFor="server_port" required> | ||
{t('SSH Port')} | ||
</FormLabel> | ||
<Input | ||
name="server_port" | ||
type="text" | ||
placeholder={t('22')} | ||
value={db?.ssh_tunnel?.server_port || ''} | ||
onChange={onSSHTunnelParametersChange} | ||
data-test="ssh-tunnel-server_port-input" | ||
/> | ||
</StyledDiv> | ||
</Col> | ||
</StyledRow> | ||
<StyledRow gutter={16}> | ||
<Col xs={24}> | ||
<StyledDiv> | ||
<FormLabel htmlFor="username" required> | ||
{t('Username')} | ||
</FormLabel> | ||
<Input | ||
name="username" | ||
type="text" | ||
placeholder={t('e.g. Analytics')} | ||
value={db?.ssh_tunnel?.username || ''} | ||
onChange={onSSHTunnelParametersChange} | ||
data-test="ssh-tunnel-username-input" | ||
/> | ||
</StyledDiv> | ||
</Col> | ||
</StyledRow> | ||
<StyledRow gutter={16}> | ||
<Col xs={24}> | ||
<StyledDiv> | ||
<FormLabel htmlFor="use_password" required> | ||
{t('Login with')} | ||
</FormLabel> | ||
<StyledFormItem name="use_password" initialValue={usePassword}> | ||
<Radio.Group | ||
onChange={({ target: { value } }) => { | ||
setUsePassword(value); | ||
setSSHTunnelLoginMethod(value); | ||
}} | ||
> | ||
<Radio | ||
value={AuthType.password} | ||
data-test="ssh-tunnel-use_password-radio" | ||
> | ||
{t('Password')} | ||
</Radio> | ||
<Radio | ||
value={AuthType.privateKey} | ||
data-test="ssh-tunnel-use_private_key-radio" | ||
> | ||
{t('Private Key & Password')} | ||
</Radio> | ||
</Radio.Group> | ||
</StyledFormItem> | ||
</StyledDiv> | ||
</Col> | ||
</StyledRow> | ||
{usePassword === AuthType.password && ( | ||
<StyledRow gutter={16}> | ||
<Col xs={24}> | ||
<StyledDiv> | ||
<FormLabel htmlFor="password" required> | ||
{t('SSH Password')} | ||
</FormLabel> | ||
<StyledInputPassword | ||
name="password" | ||
placeholder={t('e.g. ********')} | ||
value={db?.ssh_tunnel?.password || ''} | ||
onChange={onSSHTunnelParametersChange} | ||
data-test="ssh-tunnel-password-input" | ||
iconRender={visible => | ||
visible ? ( | ||
<Tooltip title="Hide password."> | ||
<EyeInvisibleOutlined /> | ||
</Tooltip> | ||
) : ( | ||
<Tooltip title="Show password."> | ||
<EyeOutlined /> | ||
</Tooltip> | ||
) | ||
} | ||
role="textbox" | ||
/> | ||
</StyledDiv> | ||
</Col> | ||
</StyledRow> | ||
)} | ||
{usePassword === AuthType.privateKey && ( | ||
<> | ||
<StyledRow gutter={16}> | ||
<Col xs={24}> | ||
<StyledDiv> | ||
<FormLabel htmlFor="private_key" required> | ||
{t('Private Key')} | ||
</FormLabel> | ||
<TextArea | ||
name="private_key" | ||
placeholder={t('Paste Private Key here')} | ||
value={db?.ssh_tunnel?.private_key || ''} | ||
onChange={onSSHTunnelParametersChange} | ||
data-test="ssh-tunnel-private_key-input" | ||
rows={4} | ||
/> | ||
</StyledDiv> | ||
</Col> | ||
</StyledRow> | ||
<StyledRow gutter={16}> | ||
<Col xs={24}> | ||
<StyledDiv> | ||
<FormLabel htmlFor="private_key_password" required> | ||
{t('Private Key Password')} | ||
</FormLabel> | ||
<StyledInputPassword | ||
name="private_key_password" | ||
placeholder={t('e.g. ********')} | ||
value={db?.ssh_tunnel?.private_key_password || ''} | ||
onChange={onSSHTunnelParametersChange} | ||
data-test="ssh-tunnel-private_key_password-input" | ||
iconRender={visible => | ||
visible ? ( | ||
<Tooltip title="Hide password."> | ||
<EyeInvisibleOutlined /> | ||
</Tooltip> | ||
) : ( | ||
<Tooltip title="Show password."> | ||
<EyeOutlined /> | ||
</Tooltip> | ||
) | ||
} | ||
role="textbox" | ||
/> | ||
</StyledDiv> | ||
</Col> | ||
</StyledRow> | ||
</> | ||
)} | ||
</> | ||
)} | ||
</Form> | ||
); | ||
}; | ||
export default SSHTunnelForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also we need to check the available endpoint to see if a given engine allows ssh tunneling
https://github.com/apache/superset/blob/master/superset/db_engine_specs/base.py#L196
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Ok, yeah, IIRC there a
engine_information
property we are getting in the UI with thesupports_file_upload
, so we might need to include this one there and use it. Thanks!