Skip to content

Commit 301d1f3

Browse files
committed
Allow package publishing with basic auth
Users that authenticate using basic auth are not logged in to the domain. With this patch applied you can publish a package using curl: ```bash curl \ -F 'files[][email protected]' \ -u repo:repo \ http://localhost:8080/exist/apps/public-repo/put-package ```
1 parent c5278d2 commit 301d1f3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modules/publish-package.xq

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ declare function local:log-put-package-event($filename as xs:string) as empty-se
3131
log:event($event)
3232
};
3333

34-
declare function local:upload-and-publish($xar-filename as xs:string, $xar-binary as xs:base64Binary) {
34+
declare function local:upload-and-publish($xar-filename as xs:string, $xar-binary as xs:base64Binary) as map(*) {
3535
let $path := scanrepo:store($config:packages-col, $xar-filename, $xar-binary)
3636
let $publish := scanrepo:publish-package($xar-filename)
3737
return
@@ -48,7 +48,12 @@ declare function local:upload-and-publish($xar-filename as xs:string, $xar-binar
4848

4949
let $xar-filename := request:get-uploaded-file-name("files[]")
5050
let $xar-binary := request:get-uploaded-file-data("files[]")
51-
let $user := request:get-attribute($config:login-domain || ".user")
51+
let $user :=
52+
(
53+
request:get-attribute($config:login-domain || ".user"),
54+
sm:id()//sm:username/string()
55+
)[1]
56+
5257
let $required-group := config:repo-permissions()?group
5358
return
5459
if (exists($user) and sm:get-user-groups($user) = $required-group) then

0 commit comments

Comments
 (0)