Skip to content

Commit 361e05f

Browse files
authored
Merge branch 'main' into add-cardtype-to-org-project
2 parents 0d10847 + 91c8261 commit 361e05f

File tree

9 files changed

+64
-25
lines changed

9 files changed

+64
-25
lines changed

custom/conf/app.example.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ RUN_MODE = ; prod
186186
;; default is the system temporary directory.
187187
;SSH_KEY_TEST_PATH =
188188
;;
189-
;; Path to ssh-keygen, default is 'ssh-keygen' which means the shell is responsible for finding out which one to call.
190-
;SSH_KEYGEN_PATH = ssh-keygen
189+
;; Use `ssh-keygen` to parse public SSH keys. The value is passed to the shell. By default, Gitea does the parsing itself.
190+
;SSH_KEYGEN_PATH =
191191
;;
192192
;; Enable SSH Authorized Key Backup when rewriting all keys, default is true
193193
;SSH_AUTHORIZED_KEYS_BACKUP = true

docs/content/doc/administration/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
345345
- `SSH_SERVER_MACS`: **[email protected], hmac-sha2-256, hmac-sha1**: For the built-in SSH server, choose the MACs to support for SSH connections, for system SSH this setting has no effect
346346
- `SSH_SERVER_HOST_KEYS`: **ssh/gitea.rsa, ssh/gogs.rsa**: For the built-in SSH server, choose the keypairs to offer as the host key. The private key should be at `SSH_SERVER_HOST_KEY` and the public `SSH_SERVER_HOST_KEY.pub`. Relative paths are made absolute relative to the `APP_DATA_PATH`. If no key exists a 4096 bit RSA key will be created for you.
347347
- `SSH_KEY_TEST_PATH`: **/tmp**: Directory to create temporary files in when testing public keys using ssh-keygen, default is the system temporary directory.
348-
- `SSH_KEYGEN_PATH`: **ssh-keygen**: Path to ssh-keygen, default is 'ssh-keygen' which means the shell is responsible for finding out which one to call.
348+
- `SSH_KEYGEN_PATH`: **\<empty\>**: Use `ssh-keygen` to parse public SSH keys. The value is passed to the shell. By default, Gitea does the parsing itself.
349349
- `SSH_EXPOSE_ANONYMOUS`: **false**: Enable exposure of SSH clone URL to anonymous visitors, default is false.
350350
- `SSH_PER_WRITE_TIMEOUT`: **30s**: Timeout for any write to the SSH connections. (Set to
351351
-1 to disable all timeouts.)

models/asymkey/ssh_key_parse.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func CheckPublicKeyString(content string) (_ string, err error) {
179179
keyType string
180180
length int
181181
)
182-
if setting.SSH.StartBuiltinServer {
182+
if len(setting.SSH.KeygenPath) == 0 {
183183
fnName = "SSHNativeParsePublicKey"
184184
keyType, length, err = SSHNativeParsePublicKey(content)
185185
} else {
@@ -285,7 +285,12 @@ func SSHKeyGenParsePublicKey(key string) (string, int, error) {
285285
}
286286
}()
287287

288-
stdout, stderr, err := process.GetManager().Exec("SSHKeyGenParsePublicKey", setting.SSH.KeygenPath, "-lf", tmpName)
288+
keygenPath := setting.SSH.KeygenPath
289+
if len(keygenPath) == 0 {
290+
keygenPath = "ssh-keygen"
291+
}
292+
293+
stdout, stderr, err := process.GetManager().Exec("SSHKeyGenParsePublicKey", keygenPath, "-lf", tmpName)
289294
if err != nil {
290295
return "", 0, fmt.Errorf("fail to parse public key: %s - %s", err, stderr)
291296
}

models/asymkey/ssh_key_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ func Test_SSHParsePublicKey(t *testing.T) {
5757
assert.Equal(t, tc.keyType, keyTypeK)
5858
assert.EqualValues(t, tc.length, lengthK)
5959
})
60+
t.Run("SSHParseKeyNative", func(t *testing.T) {
61+
keyTypeK, lengthK, err := SSHNativeParsePublicKey(tc.content)
62+
if err != nil {
63+
assert.Fail(t, "%v", err)
64+
}
65+
assert.Equal(t, tc.keyType, keyTypeK)
66+
assert.EqualValues(t, tc.length, lengthK)
67+
})
6068
})
6169
}
6270
}

modules/setting/ssh.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ var SSH = struct {
5858
ServerCiphers: []string{"[email protected]", "aes128-ctr", "aes192-ctr", "aes256-ctr", "[email protected]", "[email protected]"},
5959
ServerKeyExchanges: []string{"curve25519-sha256", "ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521", "diffie-hellman-group14-sha256", "diffie-hellman-group14-sha1"},
6060
ServerMACs: []string{"[email protected]", "hmac-sha2-256", "hmac-sha1"},
61-
KeygenPath: "ssh-keygen",
61+
KeygenPath: "",
6262
MinimumKeySizeCheck: true,
6363
MinimumKeySizes: map[string]int{"ed25519": 256, "ed25519-sk": 256, "ecdsa": 256, "ecdsa-sk": 256, "rsa": 2047},
6464
ServerHostKeys: []string{"ssh/gitea.rsa", "ssh/gogs.rsa"},
@@ -134,7 +134,7 @@ func loadSSHFrom(rootCfg ConfigProvider) {
134134
}
135135
}
136136

137-
SSH.KeygenPath = sec.Key("SSH_KEYGEN_PATH").MustString("ssh-keygen")
137+
SSH.KeygenPath = sec.Key("SSH_KEYGEN_PATH").String()
138138
SSH.Port = sec.Key("SSH_PORT").MustInt(22)
139139
SSH.ListenPort = sec.Key("SSH_LISTEN_PORT").MustInt(SSH.Port)
140140
SSH.UseProxyProtocol = sec.Key("SSH_SERVER_USE_PROXY_PROTOCOL").MustBool(false)

options/locale/locale_en-US.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@ footer = Footer
120120
footer.software = About Software
121121
footer.links = Links
122122

123+
[editor]
124+
buttons.heading.tooltip = Add heading
125+
buttons.bold.tooltip = Add bold text
126+
buttons.italic.tooltip = Add italic text
127+
buttons.quote.tooltip = Quote text
128+
buttons.code.tooltip = Add code
129+
buttons.link.tooltip = Add a link
130+
buttons.list.unordered.tooltip = Add a bullet list
131+
buttons.list.ordered.tooltip = Add a numbered list
132+
buttons.list.task.tooltip = Add a list of tasks
133+
buttons.mention.tooltip = Mention a user or team
134+
buttons.ref.tooltip = Reference an issue or pull request
135+
buttons.switch_to_legacy.tooltip = Use the legacy editor instead
136+
123137
[filter]
124138
string.asc = A - Z
125139
string.desc = Z - A

templates/shared/combomarkdowneditor.tmpl

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,28 @@ Template Attributes:
1919
</div>
2020
{{end}}
2121
<div class="ui tab active" data-tab-panel="markdown-writer">
22-
<markdown-toolbar class="gt-df">
22+
<markdown-toolbar class="gt-df gt-ac gt-gap-3">
2323
<div class="markdown-toolbar-group">
24-
<md-header class="markdown-toolbar-button">{{svg "octicon-heading"}}</md-header>
25-
<md-bold class="markdown-toolbar-button">{{svg "octicon-bold"}}</md-bold>
26-
<md-italic class="markdown-toolbar-button">{{svg "octicon-italic"}}</md-italic>
24+
<md-header role="button" class="markdown-toolbar-button btn-link muted" data-tooltip-content="{{.locale.Tr "editor.buttons.heading.tooltip"}}">{{svg "octicon-heading"}}</md-header>
25+
<md-bold role="button" class="markdown-toolbar-button btn-link muted" data-tooltip-content="{{.locale.Tr "editor.buttons.bold.tooltip"}}">{{svg "octicon-bold"}}</md-bold>
26+
<md-italic role="button" class="markdown-toolbar-button btn-link muted" data-tooltip-content="{{.locale.Tr "editor.buttons.italic.tooltip"}}">{{svg "octicon-italic"}}</md-italic>
2727
</div>
2828
<div class="markdown-toolbar-group">
29-
<md-quote class="markdown-toolbar-button">{{svg "octicon-quote"}}</md-quote>
30-
<md-code class="markdown-toolbar-button">{{svg "octicon-code"}}</md-code>
31-
<md-link class="markdown-toolbar-button">{{svg "octicon-link"}}</md-link>
29+
<md-quote role="button" class="markdown-toolbar-button btn-link muted" data-tooltip-content="{{.locale.Tr "editor.buttons.quote.tooltip"}}">{{svg "octicon-quote"}}</md-quote>
30+
<md-code role="button" class="markdown-toolbar-button btn-link muted" data-tooltip-content="{{.locale.Tr "editor.buttons.code.tooltip"}}">{{svg "octicon-code"}}</md-code>
31+
<md-link role="button" class="markdown-toolbar-button btn-link muted" data-tooltip-content="{{.locale.Tr "editor.buttons.link.tooltip"}}">{{svg "octicon-link"}}</md-link>
3232
</div>
3333
<div class="markdown-toolbar-group">
34-
<md-unordered-list class="markdown-toolbar-button">{{svg "octicon-list-unordered"}}</md-unordered-list>
35-
<md-ordered-list class="markdown-toolbar-button">{{svg "octicon-list-ordered"}}</md-ordered-list>
36-
<md-task-list class="markdown-toolbar-button">{{svg "octicon-tasklist"}}</md-task-list>
34+
<md-unordered-list role="button" class="markdown-toolbar-button btn-link muted" data-tooltip-content="{{.locale.Tr "editor.buttons.list.unordered.tooltip"}}">{{svg "octicon-list-unordered"}}</md-unordered-list>
35+
<md-ordered-list role="button" class="markdown-toolbar-button btn-link muted" data-tooltip-content="{{.locale.Tr "editor.buttons.list.ordered.tooltip"}}">{{svg "octicon-list-ordered"}}</md-ordered-list>
36+
<md-task-list role="button" class="markdown-toolbar-button btn-link muted" data-tooltip-content="{{.locale.Tr "editor.buttons.list.task.tooltip"}}">{{svg "octicon-tasklist"}}</md-task-list>
3737
</div>
3838
<div class="markdown-toolbar-group">
39-
<md-mention class="markdown-toolbar-button">{{svg "octicon-mention"}}</md-mention>
40-
<md-ref class="markdown-toolbar-button">{{svg "octicon-cross-reference"}}</md-ref>
39+
<md-mention role="button" class="markdown-toolbar-button btn-link muted" data-tooltip-content="{{.locale.Tr "editor.buttons.mention.tooltip"}}">{{svg "octicon-mention"}}</md-mention>
40+
<md-ref role="button" class="markdown-toolbar-button btn-link muted" data-tooltip-content="{{.locale.Tr "editor.buttons.ref.tooltip"}}">{{svg "octicon-cross-reference"}}</md-ref>
4141
</div>
42-
<div class="markdown-toolbar-group gt-f1"></div>
43-
<div class="markdown-toolbar-group">
44-
<span class="markdown-toolbar-button markdown-switch-easymde">{{svg "octicon-arrow-switch"}}</span>
42+
<div class="markdown-toolbar-group gt-f1 gt-je">
43+
<button class="markdown-toolbar-button markdown-switch-easymde btn-link muted" data-tooltip-content="{{.locale.Tr "editor.buttons.switch_to_legacy.tooltip"}}">{{svg "octicon-arrow-switch"}}</button>
4544
</div>
4645
</markdown-toolbar>
4746
<text-expander keys=": @">

web_src/css/base.css

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,21 +328,35 @@ progress::-moz-progress-bar {
328328
user-select: none;
329329
}
330330

331+
.btn-link {
332+
background: none;
333+
border: none;
334+
color: var(--color-primary);
335+
}
336+
337+
a:hover,
338+
.btn-link:hover {
339+
text-decoration: underline;
340+
}
341+
331342
a,
332-
.ui.breadcrumb a {
343+
.ui.breadcrumb a,
344+
.btn-link {
333345
color: var(--color-primary);
334346
cursor: pointer;
335347
text-decoration-skip-ink: all;
336348
}
337349

338350
a.muted,
351+
.btn-link.muted,
339352
.muted-links a {
340353
color: inherit;
341354
}
342355

343356
a:hover,
344357
a.muted:hover,
345358
a.muted:hover [class*="color-text"],
359+
.btn-link.muted:hover,
346360
.muted-links a:hover,
347361
.ui.breadcrumb a:hover {
348362
color: var(--color-primary);

web_src/css/editor-markdown.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
}
1010

1111
.combo-markdown-editor .markdown-toolbar-group {
12-
display: inline-block;
12+
display: flex;
1313
}
1414

1515
.combo-markdown-editor .markdown-toolbar-button {
1616
user-select: none;
1717
padding: 5px;
18-
cursor: pointer;
1918
}
2019

2120
.ui.form .combo-markdown-editor textarea.markdown-text-editor,

0 commit comments

Comments
 (0)