detached 784ca95

fix: use page origin for website_data_access permission, not requesting domain

commit
784ca95ed33f61f55823cd170ba77fc589708ea3
author
brice · · 2026-03-25 12:35 UTC
parent
2f35bdf
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +8 -21
M internal/application/usecase/handle_permission_test.go +7 -7
@@ -542,7 +542,7 @@ func TestHandlePermissionUseCase_WebsiteDataAccess_ShowsDialogAndPersists(t *tes
542542 uc := usecase.NewHandlePermissionUseCase(permRepo, dialog, permissionLoggerFromContext)
543543
544544 // No stored permission
545- permRepo.EXPECT().Get(mock.Anything, "https://accounts.google.com", entity.PermissionTypeWebsiteDataAccess).
545+ permRepo.EXPECT().Get(mock.Anything, "https://shop.example.com", entity.PermissionTypeWebsiteDataAccess).
546546 Return(nil, nil)
547547
548548 allowed := false
@@ -554,7 +554,7 @@ func TestHandlePermissionUseCase_WebsiteDataAccess_ShowsDialogAndPersists(t *tes
554554 // Dialog shows and user clicks "Always Allow"
555555 dialog.EXPECT().ShowPermissionDialog(
556556 mock.Anything,
557- "https://accounts.google.com",
557+ "https://shop.example.com",
558558 []entity.PermissionType{entity.PermissionTypeWebsiteDataAccess},
559559 mock.Anything,
560560 ).Run(func(_ context.Context, _ string, _ []entity.PermissionType, cb func(port.PermissionDialogResult)) {
@@ -564,12 +564,12 @@ func TestHandlePermissionUseCase_WebsiteDataAccess_ShowsDialogAndPersists(t *tes
564564 // Should persist the granted permission
565565 permRepo.EXPECT().Set(mock.Anything, mock.AnythingOfType("*entity.PermissionRecord")).
566566 Run(func(_ context.Context, r *entity.PermissionRecord) {
567- assert.Equal(t, "https://accounts.google.com", r.Origin)
567+ assert.Equal(t, "https://shop.example.com", r.Origin)
568568 assert.Equal(t, entity.PermissionTypeWebsiteDataAccess, r.Type)
569569 assert.Equal(t, entity.PermissionGranted, r.Decision)
570570 }).Return(nil)
571571
572- uc.HandlePermissionRequest(ctx, "https://accounts.google.com", []entity.PermissionType{
572+ uc.HandlePermissionRequest(ctx, "https://shop.example.com", []entity.PermissionType{
573573 entity.PermissionTypeWebsiteDataAccess,
574574 }, callback)
575575
@@ -584,9 +584,9 @@ func TestHandlePermissionUseCase_WebsiteDataAccess_UsesStoredGrant(t *testing.T)
584584 uc := usecase.NewHandlePermissionUseCase(permRepo, dialog, permissionLoggerFromContext)
585585
586586 // Stored granted permission
587- permRepo.EXPECT().Get(mock.Anything, "https://accounts.google.com", entity.PermissionTypeWebsiteDataAccess).
587+ permRepo.EXPECT().Get(mock.Anything, "https://shop.example.com", entity.PermissionTypeWebsiteDataAccess).
588588 Return(&entity.PermissionRecord{
589- Origin: "https://accounts.google.com",
589+ Origin: "https://shop.example.com",
590590 Type: entity.PermissionTypeWebsiteDataAccess,
591591 Decision: entity.PermissionGranted,
592592 }, nil)
@@ -597,7 +597,7 @@ func TestHandlePermissionUseCase_WebsiteDataAccess_UsesStoredGrant(t *testing.T)
597597 Deny: func() {},
598598 }
599599
600- uc.HandlePermissionRequest(ctx, "https://accounts.google.com", []entity.PermissionType{
600+ uc.HandlePermissionRequest(ctx, "https://shop.example.com", []entity.PermissionType{
601601 entity.PermissionTypeWebsiteDataAccess,
602602 }, callback)
603603
@@ -542,7 +542,7 @@ func TestHandlePermissionUseCase_WebsiteDataAccess_ShowsDialogAndPersists(t *tes
542 uc := usecase.NewHandlePermissionUseCase(permRepo, dialog, permissionLoggerFromContext)542 uc := usecase.NewHandlePermissionUseCase(permRepo, dialog, permissionLoggerFromContext)
543 543
544 // No stored permission544 // No stored permission
545- permRepo.EXPECT().Get(mock.Anything, "https://accounts.google.com", entity.PermissionTypeWebsiteDataAccess).545+ permRepo.EXPECT().Get(mock.Anything, "https://shop.example.com", entity.PermissionTypeWebsiteDataAccess).
546 Return(nil, nil)546 Return(nil, nil)
547 547
548 allowed := false548 allowed := false
@@ -554,7 +554,7 @@ func TestHandlePermissionUseCase_WebsiteDataAccess_ShowsDialogAndPersists(t *tes
554 // Dialog shows and user clicks "Always Allow"554 // Dialog shows and user clicks "Always Allow"
555 dialog.EXPECT().ShowPermissionDialog(555 dialog.EXPECT().ShowPermissionDialog(
556 mock.Anything,556 mock.Anything,
557- "https://accounts.google.com",557+ "https://shop.example.com",
558 []entity.PermissionType{entity.PermissionTypeWebsiteDataAccess},558 []entity.PermissionType{entity.PermissionTypeWebsiteDataAccess},
559 mock.Anything,559 mock.Anything,
560 ).Run(func(_ context.Context, _ string, _ []entity.PermissionType, cb func(port.PermissionDialogResult)) {560 ).Run(func(_ context.Context, _ string, _ []entity.PermissionType, cb func(port.PermissionDialogResult)) {
@@ -564,12 +564,12 @@ func TestHandlePermissionUseCase_WebsiteDataAccess_ShowsDialogAndPersists(t *tes
564 // Should persist the granted permission564 // Should persist the granted permission
565 permRepo.EXPECT().Set(mock.Anything, mock.AnythingOfType("*entity.PermissionRecord")).565 permRepo.EXPECT().Set(mock.Anything, mock.AnythingOfType("*entity.PermissionRecord")).
566 Run(func(_ context.Context, r *entity.PermissionRecord) {566 Run(func(_ context.Context, r *entity.PermissionRecord) {
567- assert.Equal(t, "https://accounts.google.com", r.Origin)567+ assert.Equal(t, "https://shop.example.com", r.Origin)
568 assert.Equal(t, entity.PermissionTypeWebsiteDataAccess, r.Type)568 assert.Equal(t, entity.PermissionTypeWebsiteDataAccess, r.Type)
569 assert.Equal(t, entity.PermissionGranted, r.Decision)569 assert.Equal(t, entity.PermissionGranted, r.Decision)
570 }).Return(nil)570 }).Return(nil)
571 571
572- uc.HandlePermissionRequest(ctx, "https://accounts.google.com", []entity.PermissionType{572+ uc.HandlePermissionRequest(ctx, "https://shop.example.com", []entity.PermissionType{
573 entity.PermissionTypeWebsiteDataAccess,573 entity.PermissionTypeWebsiteDataAccess,
574 }, callback)574 }, callback)
575 575
@@ -584,9 +584,9 @@ func TestHandlePermissionUseCase_WebsiteDataAccess_UsesStoredGrant(t *testing.T)
584 uc := usecase.NewHandlePermissionUseCase(permRepo, dialog, permissionLoggerFromContext)584 uc := usecase.NewHandlePermissionUseCase(permRepo, dialog, permissionLoggerFromContext)
585 585
586 // Stored granted permission586 // Stored granted permission
587- permRepo.EXPECT().Get(mock.Anything, "https://accounts.google.com", entity.PermissionTypeWebsiteDataAccess).587+ permRepo.EXPECT().Get(mock.Anything, "https://shop.example.com", entity.PermissionTypeWebsiteDataAccess).
588 Return(&entity.PermissionRecord{588 Return(&entity.PermissionRecord{
589- Origin: "https://accounts.google.com",589+ Origin: "https://shop.example.com",
590 Type: entity.PermissionTypeWebsiteDataAccess,590 Type: entity.PermissionTypeWebsiteDataAccess,
591 Decision: entity.PermissionGranted,591 Decision: entity.PermissionGranted,
592 }, nil)592 }, nil)
@@ -597,7 +597,7 @@ func TestHandlePermissionUseCase_WebsiteDataAccess_UsesStoredGrant(t *testing.T)
597 Deny: func() {},597 Deny: func() {},
598 }598 }
599 599
600- uc.HandlePermissionRequest(ctx, "https://accounts.google.com", []entity.PermissionType{600+ uc.HandlePermissionRequest(ctx, "https://shop.example.com", []entity.PermissionType{
601 entity.PermissionTypeWebsiteDataAccess,601 entity.PermissionTypeWebsiteDataAccess,
602 }, callback)602 }, callback)
603 603
M internal/infrastructure/webkit/webview.go +1 -14
@@ -1086,20 +1086,7 @@ func (wv *WebView) determinePermissionTypes(ctx context.Context, requestPtr uint
10861086 Str("current_domain", currentDomain).
10871087 Str("requesting_domain", requestingDomain).
10881088 Msg("website data access permission request")
1089- override := ""
1090- if requestingDomain != "" {
1091- candidate := "https://" + requestingDomain
1092- if normalized, err := urlutil.ExtractOrigin(candidate); err == nil {
1093- override = normalized
1094- } else {
1095- wv.logger.Warn().
1096- Str("requesting_domain", requestingDomain).
1097- Err(err).
1098- Msg("website data access: failed to normalize requesting domain, using raw")
1099- override = candidate
1100- }
1101- }
1102- return classifyPermissionRequestTypes(ctx, requestKind, false, false, false), override
1089+ return classifyPermissionRequestTypes(ctx, requestKind, false, false, false), ""
11031090 default:
11041091 if requestPtr != 0 {
11051092 typeName := permissionRequestTypeName(ctx, requestPtr)
@@ -1086,20 +1086,7 @@ func (wv *WebView) determinePermissionTypes(ctx context.Context, requestPtr uint
1086 Str("current_domain", currentDomain).1086 Str("current_domain", currentDomain).
1087 Str("requesting_domain", requestingDomain).1087 Str("requesting_domain", requestingDomain).
1088 Msg("website data access permission request")1088 Msg("website data access permission request")
1089- override := ""1089+ return classifyPermissionRequestTypes(ctx, requestKind, false, false, false), ""
1090- if requestingDomain != "" {
1091- candidate := "https://" + requestingDomain
1092- if normalized, err := urlutil.ExtractOrigin(candidate); err == nil {
1093- override = normalized
1094- } else {
1095- wv.logger.Warn().
1096- Str("requesting_domain", requestingDomain).
1097- Err(err).
1098- Msg("website data access: failed to normalize requesting domain, using raw")
1099- override = candidate
1100- }
1101- }
1102- return classifyPermissionRequestTypes(ctx, requestKind, false, false, false), override
1103 default:1090 default:
1104 if requestPtr != 0 {1091 if requestPtr != 0 {
1105 typeName := permissionRequestTypeName(ctx, requestPtr)1092 typeName := permissionRequestTypeName(ctx, requestPtr)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close