Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e5be436c
Commit
e5be436c
authored
Jul 30, 2018
by
Luke Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Async regenerate public ssh key
parent
ff3de503
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
50 deletions
+85
-50
ee/app/assets/javascripts/mirrors/mirror_pull.js
ee/app/assets/javascripts/mirrors/mirror_pull.js
+81
-47
ee/app/views/projects/mirrors/pull/_authentication_method.html.haml
...ws/projects/mirrors/pull/_authentication_method.html.haml
+4
-3
No files found.
ee/app/assets/javascripts/mirrors/mirror_pull.js
View file @
e5be436c
...
...
@@ -35,6 +35,7 @@ export default class MirrorPull {
this
.
$dropdownAuthType
.
on
(
'
change
'
,
e
=>
this
.
handleAuthTypeChange
(
e
));
this
.
$btnDetectHostKeys
.
on
(
'
click
'
,
e
=>
this
.
handleDetectHostKeys
(
e
));
this
.
$btnSSHHostsShowAdvanced
.
on
(
'
click
'
,
e
=>
this
.
handleSSHHostsAdvanced
(
e
));
this
.
$regeneratePublicSshKeyButton
.
on
(
'
click
'
,
e
=>
this
.
regeneratePublicSshKey
(
e
));
}
/**
...
...
@@ -77,37 +78,42 @@ export default class MirrorPull {
// Make backOff polling to get data
backOff
((
next
,
stop
)
=>
{
axios
.
get
(
`
${
projectMirrorSSHEndpoint
}
?ssh_url=
${
repositoryUrl
}
`
)
.
then
(({
data
,
status
})
=>
{
if
(
status
===
204
)
{
this
.
backOffRequestCounter
+=
1
;
if
(
this
.
backOffRequestCounter
<
3
)
{
next
();
axios
.
get
(
`
${
projectMirrorSSHEndpoint
}
?ssh_url=
${
repositoryUrl
}
`
)
.
then
(({
data
,
status
})
=>
{
if
(
status
===
204
)
{
this
.
backOffRequestCounter
+=
1
;
if
(
this
.
backOffRequestCounter
<
3
)
{
next
();
}
else
{
stop
(
data
);
}
}
else
{
stop
(
data
);
}
}
else
{
stop
(
data
);
})
.
catch
(
stop
);
})
.
then
(
res
=>
{
$btnLoadSpinner
.
addClass
(
'
hidden
'
);
// Once data is received, we show verification info along with Host keys and fingerprints
this
.
$hostKeysInformation
.
find
(
'
.js-fingerprint-verification
'
)
.
collapse
(
res
.
changes_project_import_data
?
'
hide
'
:
'
show
'
);
if
(
res
.
known_hosts
&&
res
.
fingerprints
)
{
this
.
showSSHInformation
(
res
);
}
})
.
catch
(
stop
);
})
.
then
((
res
)
=>
{
$btnLoadSpinner
.
addClass
(
'
hidden
'
);
// Once data is received, we show verification info along with Host keys and fingerprints
this
.
$hostKeysInformation
.
find
(
'
.js-fingerprint-verification
'
).
collapse
(
res
.
changes_project_import_data
?
'
hide
'
:
'
show
'
);
if
(
res
.
known_hosts
&&
res
.
fingerprints
)
{
this
.
showSSHInformation
(
res
);
}
})
.
catch
(({
response
})
=>
{
// Show failure message when there's an error and re-enable Detect host keys button
const
failureMessage
=
response
.
data
?
response
.
data
.
message
:
__
(
'
An error occurred while detecting host keys
'
);
Flash
(
failureMessage
);
.
catch
(({
response
})
=>
{
// Show failure message when there's an error and re-enable Detect host keys button
const
failureMessage
=
response
.
data
?
response
.
data
.
message
:
__
(
'
An error occurred while detecting host keys
'
);
Flash
(
failureMessage
);
$btnLoadSpinner
.
addClass
(
'
hidden
'
);
this
.
$btnDetectHostKeys
.
enable
();
});
$btnLoadSpinner
.
addClass
(
'
hidden
'
);
this
.
$btnDetectHostKeys
.
enable
();
});
}
/**
...
...
@@ -151,31 +157,31 @@ export default class MirrorPull {
// This request should happen only if selected Auth type was SSH
// and SSH Public key was not present on page load
if
(
selectedAuthType
===
AUTH_METHOD
.
SSH
&&
!
$sshPublicKey
.
text
().
trim
())
{
if
(
selectedAuthType
===
AUTH_METHOD
.
SSH
&&
!
$sshPublicKey
.
text
().
trim
())
{
this
.
$wellAuthTypeChanging
.
collapse
(
'
show
'
);
this
.
$dropdownAuthType
.
disable
();
axios
.
put
(
projectMirrorAuthTypeEndpoint
,
JSON
.
stringify
(
authTypeData
),
{
headers
:
{
'
Content-Type
'
:
'
application/json; charset=utf-8
'
,
},
})
.
then
(({
data
})
=>
{
// Show SSH public key container and fill in public key
this
.
toggleAuthWell
(
selectedAuthType
);
this
.
toggleSSHAuthWellMessage
(
true
);
this
.
setSSHPublicKey
(
data
.
import_data_attributes
.
ssh_public_key
);
axios
.
put
(
projectMirrorAuthTypeEndpoint
,
JSON
.
stringify
(
authTypeData
),
{
headers
:
{
'
Content-Type
'
:
'
application/json; charset=utf-8
'
,
},
})
.
then
(({
data
})
=>
{
// Show SSH public key container and fill in public key
this
.
toggleAuthWell
(
selectedAuthType
);
this
.
toggleSSHAuthWellMessage
(
true
);
this
.
setSSHPublicKey
(
data
.
import_data_attributes
.
ssh_public_key
);
this
.
$wellAuthTypeChanging
.
collapse
(
'
hide
'
);
this
.
$dropdownAuthType
.
enable
();
})
.
catch
(()
=>
{
Flash
(
__
(
'
Something went wrong on our end.
'
));
this
.
$wellAuthTypeChanging
.
collapse
(
'
hide
'
);
this
.
$dropdownAuthType
.
enable
();
})
.
catch
(()
=>
{
Flash
(
__
(
'
Something went wrong on our end.
'
));
this
.
$wellAuthTypeChanging
.
collapse
(
'
hide
'
);
this
.
$dropdownAuthType
.
enable
();
});
this
.
$wellAuthTypeChanging
.
collapse
(
'
hide
'
);
this
.
$dropdownAuthType
.
enable
();
});
}
else
{
this
.
toggleAuthWell
(
selectedAuthType
);
this
.
$wellSSHAuth
.
find
(
'
.js-ssh-public-key-present
'
).
collapse
(
'
show
'
);
...
...
@@ -189,7 +195,7 @@ export default class MirrorPull {
showSSHInformation
(
sshHostKeys
)
{
const
$fingerprintsList
=
this
.
$hostKeysInformation
.
find
(
'
.js-fingerprints-list
'
);
let
fingerprints
=
''
;
sshHostKeys
.
fingerprints
.
forEach
(
(
fingerprint
)
=>
{
sshHostKeys
.
fingerprints
.
forEach
(
fingerprint
=>
{
const
escFingerprints
=
_
.
escape
(
fingerprint
.
fingerprint
);
fingerprints
+=
`<code>
${
escFingerprints
}
</code>`
;
});
...
...
@@ -223,6 +229,34 @@ export default class MirrorPull {
*/
setSSHPublicKey
(
sshPublicKey
)
{
this
.
$sshPublicKeyWrap
.
find
(
'
.ssh-public-key
'
).
text
(
sshPublicKey
);
this
.
$sshPublicKeyWrap
.
find
(
'
.btn-copy-ssh-public-key
'
).
attr
(
'
data-clipboard-text
'
,
sshPublicKey
);
this
.
$sshPublicKeyWrap
.
find
(
'
.btn-copy-ssh-public-key
'
)
.
attr
(
'
data-clipboard-text
'
,
sshPublicKey
);
}
regeneratePublicSshKey
(
event
)
{
event
.
preventDefault
();
const
button
=
this
.
$regeneratePublicSshKeyButton
;
if
(
!
window
.
confirm
(
button
.
data
(
'
confirm
'
)))
return
;
// eslint-disable-line no-alert
const
spinner
=
$
(
'
.js-spinner
'
,
button
);
const
endpoint
=
button
.
data
(
'
endpoint
'
);
button
.
attr
(
'
disabled
'
,
'
disabled
'
);
spinner
.
removeClass
(
'
hide
'
);
axios
.
patch
(
endpoint
)
.
then
(({
data
})
=>
{
button
.
removeAttr
(
'
disabled
'
);
spinner
.
addClass
(
'
hide
'
);
this
.
setSSHPublicKey
(
data
.
import_data_attributes
.
ssh_public_key
);
})
.
catch
(()
=>
{
Flash
(
_
(
'
Unable to regenerate public ssh key.
'
));
});
}
}
ee/app/views/projects/mirrors/pull/_authentication_method.html.haml
View file @
e5be436c
...
...
@@ -26,8 +26,9 @@
=
import_data
.
ssh_public_key
=
clipboard_button
(
text:
import_data
.
ssh_public_key
,
title:
_
(
"Copy SSH public key to clipboard"
),
class:
'prepend-top-10 btn-copy-ssh-public-key'
)
=
button_tag
_
(
'Regenerate key'
),
type:
'button'
,
=
button_tag
type:
'button'
,
data:
{
endpoint:
project_mirror_path
(
@project
,
project:
{
import_data_attributes:
regen_data
}),
confirm:
_
(
'Are you sure you want to regenerate public key? You will have to update the public key on the remote server before mirroring will work again.'
)
},
class:
"btn btn-inverted btn-warning prepend-top-10 js-btn-regenerate-ssh-key
#{
' collapse'
unless
ssh_public_key_present
}
"
class:
"btn btn-inverted btn-warning prepend-top-10 js-btn-regenerate-ssh-key
#{
' collapse'
unless
ssh_public_key_present
}
"
do
=
sprite_icon
(
'spinner'
,
css_class:
'fa-spin hide js-spinner'
)
=
_
(
'Regenerate key'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment