From ffb6d14baf5d8fd77ba8d8313b7c6e851c0b8828 Mon Sep 17 00:00:00 2001 From: Joxit Date: Tue, 6 Jun 2023 05:56:37 +0200 Subject: [PATCH] feat: add option `REGISTRY_SECURED` for registries with Basic Auth --- README.md | 1 + bin/90-docker-registry-ui.sh | 1 + src/components/catalog/catalog-element.riot | 2 ++ src/components/catalog/catalog.riot | 2 ++ src/components/dialogs/confirm-delete-image.riot | 9 +++++---- src/components/docker-registry-ui.riot | 3 +++ src/components/tag-history/tag-history.riot | 1 + src/components/tag-list/tag-list.riot | 5 +++++ src/components/tag-list/tag-table.riot | 2 ++ src/index.html | 2 ++ src/scripts/docker-image.js | 13 ++++++++++--- src/scripts/http.js | 2 +- 12 files changed, 35 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c87ad53..d8a23e6 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ Some env options are available for use this interface for **only one server** (w - `CATALOG_MIN_BRANCHES`: Set the minimum repository/namespace to expand (e.g. `joxit/docker-registry-ui` `joxit/` is the repository/namespace). Can be 0 to disable branching. (see [#319](https://github.com/Joxit/docker-registry-ui/pull/319)). (default: `1`). Since 2.5.0 - `CATALOG_MAX_BRANCHES`: Set the maximum repository/namespace to expand (e.g. `joxit/docker-registry-ui` `joxit/` is the repository/namespace). Can be 0 to disable branching. (see [#319](https://github.com/Joxit/docker-registry-ui/pull/319)). (default: `1`). Since 2.5.0 - `TAGLIST_PAGE_SIZE`: Set the number of tags to display in one page. (default: `100`). Since 2.5.0 +- `REGISTRY_SECURED`: By default, the UI will check on every requests if your registry is secured or not (you will see `401` responses in your console). Set to `true` if your registry uses Basic Authentication and divide by two the number of call to your registry. (default `false`). Since 2.5.0 There are some examples with [docker-compose](https://docs.docker.com/compose/) and docker-registry-ui as proxy [here](https://github.com/Joxit/docker-registry-ui/tree/main/examples/ui-as-proxy/) or docker-registry-ui as standalone [here](https://github.com/Joxit/docker-registry-ui/tree/main/examples/ui-as-standalone/). diff --git a/bin/90-docker-registry-ui.sh b/bin/90-docker-registry-ui.sh index be486ca..67c951e 100755 --- a/bin/90-docker-registry-ui.sh +++ b/bin/90-docker-registry-ui.sh @@ -16,6 +16,7 @@ sed -i "s~\${CATALOG_DEFAULT_EXPANDED}~${CATALOG_DEFAULT_EXPANDED}~" index.html sed -i "s~\${CATALOG_MIN_BRANCHES}~${CATALOG_MIN_BRANCHES}~" index.html sed -i "s~\${CATALOG_MAX_BRANCHES}~${CATALOG_MAX_BRANCHES}~" index.html sed -i "s~\${TAGLIST_PAGE_SIZE}~${TAGLIST_PAGE_SIZE}~" index.html +sed -i "s~\${REGISTRY_SECURED}~${REGISTRY_SECURED}~" index.html grep -o 'THEME[A-Z_]*' index.html | while read e; do sed -i "s~\${$e}~$(printenv $e)~" index.html diff --git a/src/components/catalog/catalog-element.riot b/src/components/catalog/catalog-element.riot index b235056..e3de4cc 100644 --- a/src/components/catalog/catalog-element.riot +++ b/src/components/catalog/catalog-element.riot @@ -50,6 +50,7 @@ along with this program. If not, see . on-notify="{ props.onnNotify }" on-authentication="{ props.onAuthentication }" show-catalog-nb-tags="{ props.showCatalogNbTags }" + is-registry-secured="{ props.isRegistrySecured }" class="animated {!state.expanded && !props.filterResults ? 'hide' : ''} {state.expanding ? 'expanding' : ''}" each="{item in state.images}" z-index="{ props.zIndex - 1 }" @@ -108,6 +109,7 @@ along with this program. If not, see . const self = this; const oReq = new Http({ onAuthentication: props.onAuthentication, + withCredentials: props.isRegistrySecured, }); oReq.addEventListener('load', function () { if (this.status === 200) { diff --git a/src/components/catalog/catalog.riot b/src/components/catalog/catalog.riot index 3365a2f..b8dc7c1 100644 --- a/src/components/catalog/catalog.riot +++ b/src/components/catalog/catalog.riot @@ -36,6 +36,7 @@ along with this program. If not, see . show-catalog-nb-tags="{ props.showCatalogNbTags }" catalog-default-expanded="{ props.catalogDefaultExpanded || state.nRepositories === 1 }" z-index="{ props.catalogMaxBranches - props.catalogMinBranches + 2 }" + is-registry-secured="{ props.isRegistrySecured }" >