-
Notifications
You must be signed in to change notification settings - Fork 168
feat: add UI ssh key pair generator #809
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
Open
antoine-sh
wants to merge
6
commits into
nicotsx:main
Choose a base branch
from
antoine-sh:feat/ssh-key-generator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
788499b
Add ssh key generation button on sftp volume creation page
antoine-sh 9625939
Refactor ssh key generation function to a new ssh utils file
antoine-sh 10376da
Add ssh key generation button on sftp repository creation page
antoine-sh 1928b53
Add generateSshKeyPair function to ssh util
antoine-sh 8fac0d7
Add keypair generation and public key copy button to sftp repository …
antoine-sh e0d1fac
Add keypair generation and public key copy button to sftp volume form
antoine-sh 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 hidden or 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
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is duplicated exactly across both forms. Make it a re-usable component |
This file contains hidden or 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 hidden or 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,42 @@ | ||
| const arrayBufferToBase64 = (buffer: ArrayBuffer) => { | ||
| let binary = ""; | ||
| const bytes = new Uint8Array(buffer); | ||
| const chunkSize = 0x8000; | ||
|
|
||
| for (let i = 0; i < bytes.length; i += chunkSize) { | ||
| binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize)); | ||
| } | ||
|
|
||
| return btoa(binary); | ||
| }; | ||
|
|
||
| const toPem = (base64: string, label: string) => { | ||
| const wrapped = base64.match(/.{1,64}/g)?.join("\n") ?? base64; | ||
| return `-----BEGIN ${label}-----\n${wrapped}\n-----END ${label}-----`; | ||
| }; | ||
|
|
||
| export const generateSshKeyPairPem = async () => { | ||
| const keyPair = await crypto.subtle.generateKey( | ||
| { | ||
| name: "RSASSA-PKCS1-v1_5", | ||
| modulusLength: 4096, | ||
| publicExponent: new Uint8Array([1, 0, 1]), | ||
| hash: "SHA-256", | ||
| }, | ||
| true, | ||
| ["sign", "verify"], | ||
| ); | ||
|
|
||
| const privateKey = await crypto.subtle.exportKey("pkcs8", keyPair.privateKey); | ||
| const publicKey = await crypto.subtle.exportKey("spki", keyPair.publicKey); | ||
|
|
||
| return { | ||
| privateKeyPem: toPem(arrayBufferToBase64(privateKey), "PRIVATE KEY"), | ||
| publicKeyPem: toPem(arrayBufferToBase64(publicKey), "PUBLIC KEY"), | ||
| }; | ||
| }; | ||
|
|
||
| export const generatePrivateKeyPem = async () => { | ||
| const keyPair = await generateSshKeyPairPem(); | ||
| return keyPair.privateKeyPem; | ||
| }; |
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.
Copy to clipboard will never work if not on https or localhost. So a user using an ip 192.168.1.10 will never be able to get their public key. Maybe you could render a read-only input for the public key. I prefer to avoid the clipboard api altogether