mirror of
https://github.com/Joxit/docker-registry-ui.git
synced 2025-04-29 00:19:54 +03:00
feat(token-auth): check the presence of www-authenticate
header before the status code
This commit is contained in:
parent
cd99f6e231
commit
3414d7b517
2 changed files with 4 additions and 4 deletions
|
@ -111,7 +111,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
onAuthentication: props.onAuthentication,
|
onAuthentication: props.onAuthentication,
|
||||||
withCredentials: props.isRegistrySecured,
|
withCredentials: props.isRegistrySecured,
|
||||||
});
|
});
|
||||||
oReq.addEventListener('load', function () {
|
oReq.addEventListener('loadend', function () {
|
||||||
if (this.status === 200) {
|
if (this.status === 200) {
|
||||||
const nbTags = (JSON.parse(this.responseText).tags || []).length;
|
const nbTags = (JSON.parse(this.responseText).tags || []).length;
|
||||||
self.update({ nbTags });
|
self.update({ nbTags });
|
||||||
|
|
|
@ -54,9 +54,9 @@ export class Http {
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case 'loadend': {
|
case 'loadend': {
|
||||||
self.oReq.addEventListener('loadend', function () {
|
self.oReq.addEventListener('loadend', function () {
|
||||||
if (this.status === 401 && !this.withCredentials) {
|
|
||||||
const tokenAuth =
|
const tokenAuth =
|
||||||
this.hasHeader('www-authenticate') && parseAuthenticateHeader(this.getResponseHeader('www-authenticate'));
|
this.hasHeader('www-authenticate') && parseAuthenticateHeader(this.getResponseHeader('www-authenticate'));
|
||||||
|
if (this.status === 401 && (!this.withCredentials || tokenAuth)) {
|
||||||
self.onAuthentication(tokenAuth, (bearer) => {
|
self.onAuthentication(tokenAuth, (bearer) => {
|
||||||
const req = new XMLHttpRequest();
|
const req = new XMLHttpRequest();
|
||||||
req._url = self._url;
|
req._url = self._url;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue