Skip to content

Commit 5f9a9b9

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: [skip ci] Updated translations via Crowdin Ignore port for loopback redirect URIs (go-gitea#21293) Improve error descriptions for unauthorized_client (go-gitea#21292) Consolidate more CSS rules, fix inline code on arc-green (go-gitea#21260)
2 parents f59862b + 78c15da commit 5f9a9b9

File tree

8 files changed

+78
-51
lines changed

8 files changed

+78
-51
lines changed

models/auth/oauth2.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"encoding/base32"
1111
"encoding/base64"
1212
"fmt"
13+
"net"
1314
"net/url"
1415
"strings"
1516

@@ -56,6 +57,18 @@ func (app *OAuth2Application) PrimaryRedirectURI() string {
5657

5758
// ContainsRedirectURI checks if redirectURI is allowed for app
5859
func (app *OAuth2Application) ContainsRedirectURI(redirectURI string) bool {
60+
uri, err := url.Parse(redirectURI)
61+
// ignore port for http loopback uris following https://datatracker.ietf.org/doc/html/rfc8252#section-7.3
62+
if err == nil && uri.Scheme == "http" && uri.Port() != "" {
63+
ip := net.ParseIP(uri.Hostname())
64+
if ip != nil && ip.IsLoopback() {
65+
// strip port
66+
uri.Host = uri.Hostname()
67+
if util.IsStringInSlice(uri.String(), app.RedirectURIs, true) {
68+
return true
69+
}
70+
}
71+
}
5972
return util.IsStringInSlice(redirectURI, app.RedirectURIs, true)
6073
}
6174

models/auth/oauth2_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ func TestOAuth2Application_ContainsRedirectURI(t *testing.T) {
4343
assert.False(t, app.ContainsRedirectURI("d"))
4444
}
4545

46+
func TestOAuth2Application_ContainsRedirectURI_WithPort(t *testing.T) {
47+
app := &auth_model.OAuth2Application{
48+
RedirectURIs: []string{"http://127.0.0.1/", "http://::1/", "http://192.168.0.1/", "http://intranet/", "https://127.0.0.1/"},
49+
}
50+
51+
// http loopback uris should ignore port
52+
// https://datatracker.ietf.org/doc/html/rfc8252#section-7.3
53+
assert.True(t, app.ContainsRedirectURI("http://127.0.0.1:3456/"))
54+
assert.True(t, app.ContainsRedirectURI("http://127.0.0.1/"))
55+
assert.True(t, app.ContainsRedirectURI("http://[::1]:3456/"))
56+
57+
// not http
58+
assert.False(t, app.ContainsRedirectURI("https://127.0.0.1:3456/"))
59+
// not loopback
60+
assert.False(t, app.ContainsRedirectURI("http://192.168.0.1:9954/"))
61+
assert.False(t, app.ContainsRedirectURI("http://intranet:3456/"))
62+
// unparseable
63+
assert.False(t, app.ContainsRedirectURI(":"))
64+
}
65+
4666
func TestOAuth2Application_ValidateClientSecret(t *testing.T) {
4767
assert.NoError(t, unittest.PrepareTestDatabase())
4868
app := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1})

options/locale/locale_cs-CZ.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,7 @@ settings.confirm_delete=Smazat repozitář
18981898
settings.add_collaborator=Přidat spolupracovníka
18991899
settings.add_collaborator_success=Spolupracovník byl přidán.
19001900
settings.add_collaborator_inactive_user=Nelze přidat neaktivního uživatele jako spolupracovníka.
1901+
settings.add_collaborator_owner=Vlastníka nelze přidat jako spolupracovníka.
19011902
settings.add_collaborator_duplicate=Spolupracovník je již přidán k tomuto repozitáři.
19021903
settings.delete_collaborator=Odstranit
19031904
settings.collaborator_deletion=Odstranit spolupracovníka

options/locale/locale_pt-BR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,7 @@ settings.confirm_delete=Excluir repositório
18981898
settings.add_collaborator=Adicionar colaborador
18991899
settings.add_collaborator_success=O colaborador foi adicionado.
19001900
settings.add_collaborator_inactive_user=Não é possível adicionar um usuário inativo como colaborador.
1901+
settings.add_collaborator_owner=Não é possível adicionar um proprietário como um colaborador.
19011902
settings.add_collaborator_duplicate=O colaborador já está adicionado a este repositório.
19021903
settings.delete_collaborator=Remover
19031904
settings.collaborator_deletion=Remover colaborador

options/locale/locale_pt-PT.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,7 @@ settings.confirm_delete=Eliminar repositório
18981898
settings.add_collaborator=Adicionar colaborador
18991899
settings.add_collaborator_success=O colaborador foi adicionado.
19001900
settings.add_collaborator_inactive_user=Não é possível adicionar um utilizador desabilitado como colaborador.
1901+
settings.add_collaborator_owner=Não é possível adicionar um proprietário como um colaborador.
19011902
settings.add_collaborator_duplicate=O colaborador já tinha sido adicionado a este repositório.
19021903
settings.delete_collaborator=Remover
19031904
settings.collaborator_deletion=Remover colaborador

routers/web/auth/oauth.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ func handleRefreshToken(ctx *context.Context, form forms.AccessTokenForm, server
645645
if err != nil {
646646
handleAccessTokenError(ctx, AccessTokenError{
647647
ErrorCode: AccessTokenErrorCodeUnauthorizedClient,
648-
ErrorDescription: "client is not authorized",
648+
ErrorDescription: "unable to parse refresh token",
649649
})
650650
return
651651
}
@@ -688,14 +688,14 @@ func handleAuthorizationCode(ctx *context.Context, form forms.AccessTokenForm, s
688688
if !app.ValidateClientSecret([]byte(form.ClientSecret)) {
689689
handleAccessTokenError(ctx, AccessTokenError{
690690
ErrorCode: AccessTokenErrorCodeUnauthorizedClient,
691-
ErrorDescription: "client is not authorized",
691+
ErrorDescription: "invalid client secret",
692692
})
693693
return
694694
}
695695
if form.RedirectURI != "" && !app.ContainsRedirectURI(form.RedirectURI) {
696696
handleAccessTokenError(ctx, AccessTokenError{
697697
ErrorCode: AccessTokenErrorCodeUnauthorizedClient,
698-
ErrorDescription: "client is not authorized",
698+
ErrorDescription: "unexpected redirect URI",
699699
})
700700
return
701701
}
@@ -711,7 +711,7 @@ func handleAuthorizationCode(ctx *context.Context, form forms.AccessTokenForm, s
711711
if !authorizationCode.ValidateCodeChallenge(form.CodeVerifier) {
712712
handleAccessTokenError(ctx, AccessTokenError{
713713
ErrorCode: AccessTokenErrorCodeUnauthorizedClient,
714-
ErrorDescription: "client is not authorized",
714+
ErrorDescription: "failed PKCE code challenge",
715715
})
716716
return
717717
}

web_src/less/_base.less

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
--color-tooltip-bg: #000000f0;
159159
--color-tooltip-text: #ffffff;
160160
--color-header-bar: #ffffff;
161+
--color-label-active-bg: #d0d0d0;
161162
/* backgrounds */
162163
--checkbox-mask-checked: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-1 -1 18 18" width="16" height="16"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg>');
163164
--checkbox-mask-indeterminate: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2 7.75A.75.75 0 012.75 7h10a.75.75 0 010 1.5h-10A.75.75 0 012 7.75z"></path></svg>');
@@ -393,6 +394,12 @@ a.commit-statuses-trigger {
393394
background: var(--color-grey);
394395
}
395396

397+
.ui.active.label {
398+
background: var(--color-label-active-bg);
399+
border-color: var(--color-label-active-bg);
400+
color: var(--color-text-dark);
401+
}
402+
396403
.ui.link.menu .item:hover,
397404
.ui.menu .dropdown.item:hover,
398405
.ui.menu .link.item:hover,
@@ -478,11 +485,21 @@ a.commit-statuses-trigger {
478485
color: var(--color-text-light-2);
479486
}
480487

488+
.ui.list .list > .item .header,
489+
.ui.list > .item .header {
490+
color: var(--color-text-dark);
491+
}
492+
481493
.ui.list .list > .item > .content,
482494
.ui.list > .item > .content {
483495
color: var(--color-text);
484496
}
485497

498+
.ui.list .list > .item .description,
499+
.ui.list > .item .description {
500+
color: var(--color-text);
501+
}
502+
486503
.ui.secondary.menu .dropdown.item:hover,
487504
.ui.secondary.menu .link.item:hover,
488505
.ui.secondary.menu a.item:hover {
@@ -704,6 +721,12 @@ a.ui.card:hover,
704721
border-top-color: var(--color-secondary-alpha-50);
705722
}
706723

724+
.ui.ui.ui.ui.table tr.active,
725+
.ui.ui.table td.active {
726+
color: var(--color-text);
727+
background: var(--color-active);
728+
}
729+
707730
.ui.ui.selectable.table > tbody > tr:hover,
708731
.ui.table tbody tr td.selectable:hover {
709732
color: var(--color-text);
@@ -726,11 +749,22 @@ a.ui.card:hover,
726749
}
727750

728751
.ui.modal > .header {
752+
color: var(--color-text-dark);
753+
background: var(--color-secondary-bg);
729754
border-color: var(--color-secondary);
730755
border-top-left-radius: var(--border-radius);
731756
border-top-right-radius: var(--border-radius);
732757
}
733758

759+
.ui.modal > .content {
760+
background: var(--color-body);
761+
}
762+
763+
.ui.modal > .actions {
764+
background: var(--color-secondary-bg);
765+
border-color: var(--color-secondary);
766+
}
767+
734768
.ui.modal > .close.inside,
735769
.ui.fullscreen.modal > .close {
736770
top: 11px; /* align modal close icon, for example admin notices */
@@ -1591,6 +1625,7 @@ i.icon.centerlock {
15911625
.ui.labels a.label:hover,
15921626
a.ui.label:hover {
15931627
background: var(--color-hover);
1628+
border-color: var(--color-hover);
15941629
color: var(--color-text);
15951630
}
15961631

@@ -1615,7 +1650,7 @@ a.ui.label:hover {
16151650
padding-left: 10px;
16161651
padding-right: 10px;
16171652
text-align: right !important;
1618-
color: rgba(27, 31, 35, .3);
1653+
color: var(--color-text-light-1);
16191654
width: 1%;
16201655
font-family: var(--fonts-monospace);
16211656

web_src/less/themes/theme-arc-green.less

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
--color-menu: #2e323e;
119119
--color-card: #2e323e;
120120
--color-markup-table-row: #ffffff06;
121-
--color-markup-code-block: #292d39;
121+
--color-markup-code-block: #ffffff0d;
122122
--color-button: #353846;
123123
--color-code-bg: #2a2e3a;
124124
--color-code-sidebar-bg: #2e323e;
@@ -133,6 +133,7 @@
133133
--color-reaction-bg: #ffffff12;
134134
--color-reaction-active-bg: var(--color-primary-alpha-40);
135135
--color-header-bar: #2e323e;
136+
--color-label-active-bg: #4c525e;
136137
}
137138

138139
::-webkit-calendar-picker-indicator {
@@ -228,11 +229,6 @@ a.ui.basic.green.label:hover {
228229
background-color: #a0cc75;
229230
}
230231

231-
.repository .navbar .active.item,
232-
.repository .navbar .active.item:hover {
233-
border-color: transparent !important;
234-
}
235-
236232
.repository .diff-stats li {
237233
border-color: var(--color-secondary);
238234
}
@@ -247,37 +243,11 @@ a.ui.basic.green.label:hover {
247243
background-color: #984646;
248244
}
249245

250-
.ui.list .list > .item .header,
251-
.ui.list > .item .header {
252-
color: #dedede;
253-
}
254-
255-
.ui.list .list > .item .description,
256-
.ui.list > .item .description {
257-
color: var(--color-secondary-dark-6);
258-
}
259-
260-
.lines-num {
261-
color: var(--color-secondary-dark-6) !important;
262-
border-color: var(--color-secondary) !important;
263-
}
264-
265246
.lines-code.active,
266247
.lines-code .active {
267248
background: #534d1b !important;
268249
}
269250

270-
.ui.ui.ui.ui.table tr.active,
271-
.ui.ui.table td.active {
272-
color: #dbdbdb;
273-
}
274-
275-
.ui.active.label {
276-
background: #393d4a;
277-
border-color: #393d4a;
278-
color: #dbdbdb;
279-
}
280-
281251
.ui.header .sub.header {
282252
color: var(--color-secondary-dark-6);
283253
}
@@ -286,20 +256,6 @@ a.ui.basic.green.label:hover {
286256
border-bottom: 1px solid var(--color-secondary);
287257
}
288258

289-
.ui.modal > .header {
290-
background: var(--color-secondary);
291-
color: #dbdbdb;
292-
}
293-
294-
.ui.modal > .actions {
295-
background: var(--color-secondary);
296-
border-color: var(--color-secondary);
297-
}
298-
299-
.ui.modal > .content {
300-
background: #383c4a;
301-
}
302-
303259
.minicolors-panel {
304260
background: var(--color-secondary) !important;
305261
border-color: #6a737d !important;

0 commit comments

Comments
 (0)