Skip to content

Commit

Permalink
feat(sftp): added option for sftp connections with key and password a…
Browse files Browse the repository at this point in the history
…uth combined
  • Loading branch information
christopherpickering committed Aug 3, 2023
1 parent b7dbe51 commit f267813
Show file tree
Hide file tree
Showing 309 changed files with 1,766 additions and 1,186 deletions.
35 changes: 35 additions & 0 deletions migrations/versions/6b8978d637c5_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""empty message
Revision ID: 6b8978d637c5
Revises: 0fe33867bdbf
Create Date: 2023-08-03 12:53:03.650434
"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = '6b8978d637c5'
down_revision = '0fe33867bdbf'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('connection_sftp', schema=None) as batch_op:
batch_op.add_column(sa.Column('key_password', sa.Text(), nullable=True))

# ### end Alembic commands ###

# move passwords on connections that have a key into the key_password field and clear the
# password field.
op.execute('update connection_sftp set key_password=password where key is not null')
op.execute('update connection_sftp set password=null where key is not null and key_password=password')

def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('connection_sftp', schema=None) as batch_op:
batch_op.drop_column('key_password')

# ### end Alembic commands ###
10 changes: 7 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions runner/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ class ConnectionSftp(db.Model):
username = db.Column(db.String(120), nullable=True)
key = db.Column(db.String(8000), nullable=True)
password = db.Column(db.Text, nullable=True)
key_password = db.Column(db.Text, nullable=True)
task = db.relationship(
"Task",
backref="destination_sftp_conn",
Expand Down
4 changes: 2 additions & 2 deletions runner/scripts/em_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def run(self) -> Optional[List[Path]]:

# if output is not a file list, then swallow it.

if isinstance(self.output, List):
return self.output
if isinstance(eval(self.output), List):
return [Path(x) for x in eval(self.output)]
return None

def __build_env(self) -> None:
Expand Down
34 changes: 24 additions & 10 deletions runner/scripts/em_sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def connection_key(connection: ConnectionSftp) -> Optional[paramiko.pkey.PKey]:

key = paramiko.RSAKey.from_private_key_file(
key_file.name,
password=em_decrypt(connection.password, app.config["PASS_KEY"])
if connection.password
password=em_decrypt(connection.key_password, app.config["PASS_KEY"])
if connection.key_password
else None,
)

Expand All @@ -54,6 +54,7 @@ def connection_json(connection: ConnectionSftp) -> Dict:
"port": connection.port or 22,
"key": em_decrypt(connection.key, app.config["PASS_KEY"]),
"password": em_decrypt(connection.password, app.config["PASS_KEY"]),
"key_password": em_decrypt(connection.key_password, app.config["PASS_KEY"]),
"username": str(connection.username),
}

Expand All @@ -74,15 +75,28 @@ def connect(connection: ConnectionSftp) -> Tuple[Transport, SFTPClient]:

key = connection_key(connection)

transport.connect(
username=str(connection.username),
password=(
if key and connection.password and connection.username:
transport.start_client(event=None, timeout=15)
transport.get_remote_server_key()
transport.auth_publickey(connection.username, key, event=None)
transport.auth_password(
connection.username,
em_decrypt(connection.password, app.config["PASS_KEY"])
if key is None
else ""
),
pkey=key,
)
if connection.password
else "",
event=None,
)

else:
transport.connect(
username=str(connection.username),
password=(
em_decrypt(connection.password, app.config["PASS_KEY"])
if connection.password
else ""
),
pkey=key,
)

conn = paramiko.SFTPClient.from_transport(transport)
if conn is None:
Expand Down
1 change: 1 addition & 0 deletions scheduler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ class ConnectionSftp(db.Model):
username = db.Column(db.String(120), nullable=True)
key = db.Column(db.String(8000), nullable=True)
password = db.Column(db.Text, nullable=True)
key_password = db.Column(db.Text, nullable=True)
task = db.relationship(
"Task",
backref="destination_sftp_conn",
Expand Down
1 change: 1 addition & 0 deletions web/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ class ConnectionSftp(db.Model):
username = db.Column(db.String(120), nullable=True)
key = db.Column(db.String(8000), nullable=True)
password = db.Column(db.Text, nullable=True)
key_password = db.Column(db.Text, nullable=True)
task = db.relationship(
"Task",
backref="destination_sftp_conn",
Expand Down
2 changes: 1 addition & 1 deletion web/static/css/base.css

Large diffs are not rendered by default.

40 changes: 23 additions & 17 deletions web/static/fonts/inter/100.css
Original file line number Diff line number Diff line change
@@ -1,63 +1,69 @@
/* inter-cyrillic-ext-100-normal*/
/* inter-cyrillic-ext-100-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 100;
src: url('/static/fonts/inter/files/inter-cyrillic-ext-100-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-100-normal.woff') format('woff');
src: url(/static/fonts/inter/files/inter-cyrillic-ext-100-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-cyrillic-ext-100-normal.woff) format('woff');
unicode-range: U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}
/* inter-cyrillic-100-normal*/

/* inter-cyrillic-100-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 100;
src: url('/static/fonts/inter/files/inter-cyrillic-100-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-100-normal.woff') format('woff');
src: url(/static/fonts/inter/files/inter-cyrillic-100-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-cyrillic-100-normal.woff) format('woff');
unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
/* inter-greek-ext-100-normal*/

/* inter-greek-ext-100-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 100;
src: url('/static/fonts/inter/files/inter-greek-ext-100-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-100-normal.woff') format('woff');
src: url(/static/fonts/inter/files/inter-greek-ext-100-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-greek-ext-100-normal.woff) format('woff');
unicode-range: U+1F00-1FFF;
}
/* inter-greek-100-normal*/

/* inter-greek-100-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 100;
src: url('/static/fonts/inter/files/inter-greek-100-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-100-normal.woff') format('woff');
src: url(/static/fonts/inter/files/inter-greek-100-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-greek-100-normal.woff) format('woff');
unicode-range: U+0370-03FF;
}
/* inter-vietnamese-100-normal*/

/* inter-vietnamese-100-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 100;
src: url('/static/fonts/inter/files/inter-vietnamese-100-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-100-normal.woff') format('woff');
unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+1EA0-1EF9,U+20AB;
src: url(/static/fonts/inter/files/inter-vietnamese-100-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-vietnamese-100-normal.woff) format('woff');
unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}
/* inter-latin-ext-100-normal*/

/* inter-latin-ext-100-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 100;
src: url('/static/fonts/inter/files/inter-latin-ext-100-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-100-normal.woff') format('woff');
unicode-range: U+0100-024F,U+0259,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;
src: url(/static/fonts/inter/files/inter-latin-ext-100-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-latin-ext-100-normal.woff) format('woff');
unicode-range: U+0100-02AF,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
/* inter-latin-100-normal*/

/* inter-latin-100-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 100;
src: url('/static/fonts/inter/files/inter-latin-100-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-100-normal.woff') format('woff');
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
src: url(/static/fonts/inter/files/inter-latin-100-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-latin-100-normal.woff) format('woff');
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
40 changes: 23 additions & 17 deletions web/static/fonts/inter/200.css
Original file line number Diff line number Diff line change
@@ -1,63 +1,69 @@
/* inter-cyrillic-ext-200-normal*/
/* inter-cyrillic-ext-200-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 200;
src: url('/static/fonts/inter/files/inter-cyrillic-ext-200-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-200-normal.woff') format('woff');
src: url(/static/fonts/inter/files/inter-cyrillic-ext-200-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-cyrillic-ext-200-normal.woff) format('woff');
unicode-range: U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}
/* inter-cyrillic-200-normal*/

/* inter-cyrillic-200-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 200;
src: url('/static/fonts/inter/files/inter-cyrillic-200-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-200-normal.woff') format('woff');
src: url(/static/fonts/inter/files/inter-cyrillic-200-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-cyrillic-200-normal.woff) format('woff');
unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
/* inter-greek-ext-200-normal*/

/* inter-greek-ext-200-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 200;
src: url('/static/fonts/inter/files/inter-greek-ext-200-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-200-normal.woff') format('woff');
src: url(/static/fonts/inter/files/inter-greek-ext-200-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-greek-ext-200-normal.woff) format('woff');
unicode-range: U+1F00-1FFF;
}
/* inter-greek-200-normal*/

/* inter-greek-200-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 200;
src: url('/static/fonts/inter/files/inter-greek-200-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-200-normal.woff') format('woff');
src: url(/static/fonts/inter/files/inter-greek-200-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-greek-200-normal.woff) format('woff');
unicode-range: U+0370-03FF;
}
/* inter-vietnamese-200-normal*/

/* inter-vietnamese-200-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 200;
src: url('/static/fonts/inter/files/inter-vietnamese-200-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-200-normal.woff') format('woff');
unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+1EA0-1EF9,U+20AB;
src: url(/static/fonts/inter/files/inter-vietnamese-200-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-vietnamese-200-normal.woff) format('woff');
unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}
/* inter-latin-ext-200-normal*/

/* inter-latin-ext-200-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 200;
src: url('/static/fonts/inter/files/inter-latin-ext-200-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-200-normal.woff') format('woff');
unicode-range: U+0100-024F,U+0259,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;
src: url(/static/fonts/inter/files/inter-latin-ext-200-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-latin-ext-200-normal.woff) format('woff');
unicode-range: U+0100-02AF,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
/* inter-latin-200-normal*/

/* inter-latin-200-normal */
@font-face {
font-family: 'Inter';
font-style: normal;
font-display: swap;
font-weight: 200;
src: url('/static/fonts/inter/files/inter-latin-200-normal.woff2') format('woff2'), url('/static/fonts/inter/files/inter-all-200-normal.woff') format('woff');
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
src: url(/static/fonts/inter/files/inter-latin-200-normal.woff2) format('woff2'), url(/static/fonts/inter/files/inter-latin-200-normal.woff) format('woff');
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
Loading

0 comments on commit f267813

Please sign in to comment.