diff --git a/dashboard/src/components/api/devfile-registry.factory.ts b/dashboard/src/components/api/devfile-registry.factory.ts index 1c02ccc6cf..4e47b1749b 100644 --- a/dashboard/src/components/api/devfile-registry.factory.ts +++ b/dashboard/src/components/api/devfile-registry.factory.ts @@ -46,6 +46,8 @@ export class DevfileRegistry { private jwtproxyMemoryLimitNumber: number; + private headers: { [name: string]: string; }; + /** * Default constructor that is using resource */ @@ -56,10 +58,17 @@ export class DevfileRegistry { this.devfilesMap = new Map(); this.isKeycloackPresent = cheKeycloak.isPresent(); this.jwtproxyMemoryLimitNumber = this.getMemoryLimit(DEFAULT_JWTPROXY_MEMORY_LIMIT); + + this.headers = { 'Authorization': undefined }; } fetchDevfiles(location: string): ng.IPromise> { - let promise = this.$http({ 'method': 'GET', 'url': location + '/devfiles/index.json' }); + let promise = this.$http({ + 'method': 'GET', + 'url': `${location}/devfiles/index.json`, + 'headers': this.headers + }); + return promise.then((result: any) => { return result.data.map((devfileMetaData: IDevfileMetaData) => { let globalMemoryLimitNumber = this.getMemoryLimit(devfileMetaData.globalMemoryLimit); @@ -74,9 +83,13 @@ export class DevfileRegistry { } fetchDevfile(location: string, link: string): ng.IPromise { - let promise = this.$http({ 'method': 'GET', 'url': location + link }); + let promise = this.$http({ + 'method': 'GET', + 'url': `${location}${link}`, + 'headers': this.headers + }); return promise.then((result: any) => { - let devfile = this.devfileYamlToJson(result.data) + let devfile = this.devfileYamlToJson(result.data); this.devfilesMap.set(location + link, devfile); return devfile; }); diff --git a/dashboard/src/components/api/plugin-registry.factory.ts b/dashboard/src/components/api/plugin-registry.factory.ts index 4996463c1f..5608e329df 100644 --- a/dashboard/src/components/api/plugin-registry.factory.ts +++ b/dashboard/src/components/api/plugin-registry.factory.ts @@ -59,12 +59,16 @@ export class PluginRegistry { private plugins = new Map>(); + private headers: { [name: string]: string; }; + /** * Default constructor that is using resource */ constructor($http: ng.IHttpService, $q: ng.IQService) { this.$http = $http; this.$q = $q; + + this.headers = { 'Authorization': undefined }; } static get EDITOR_TYPE(): string { @@ -72,7 +76,13 @@ export class PluginRegistry { } fetchPlugins(location: string): ng.IPromise> { - return this.$http({'method': 'GET', 'url': location + '/plugins/'}).then((result: ng.IHttpResponse) => { + const promise = this.$http({ + 'method': 'GET', + 'url': `${location}/plugins/`, + 'headers': this.headers + }); + + return promise.then((result: ng.IHttpResponse) => { this.plugins.set(location, result.data); return this.$q.when(result.data); }, (error: any) => { diff --git a/dashboard/src/components/interceptor/keycloak-token-interceptor.ts b/dashboard/src/components/interceptor/keycloak-token-interceptor.ts index 395be5f0d9..53547d9abc 100644 --- a/dashboard/src/components/interceptor/keycloak-token-interceptor.ts +++ b/dashboard/src/components/interceptor/keycloak-token-interceptor.ts @@ -15,6 +15,8 @@ import {HttpInterceptorBase} from './interceptor-base'; const GITHUB_API = 'api.github.com'; +const AUTHORIZATION = 'Authorization'; + /** * @author Oleksii Kurinnyi */ @@ -49,11 +51,15 @@ export class KeycloakTokenInterceptor extends HttpInterceptorBase { return config; } - if (config.headers.Authorization) { + const headers = config.headers; + if (headers && Object.keys(headers).indexOf(AUTHORIZATION) != -1) { + if (headers[AUTHORIZATION] === undefined) { + delete headers[AUTHORIZATION]; + } return config; } - + if (this.keycloak && this.keycloak.token) { let deferred = this.$q.defer(); this.keycloak.updateToken(5).success(() => {