Merge pull request #129 from dinukadesilva/externalize-custos-api-url-to-env
Externalize custos api url to the envs
diff --git a/.env b/.env
index 5819f5c..3d8d53b 100644
--- a/.env
+++ b/.env
@@ -1,3 +1,5 @@
-VUE_APP_CLIENT_ID="custos-su8y67qnckn5eejwusnz-10000641"
-VUE_APP_CLIENT_SEC="wGo5SGduOofjqFpl3UrR8ngrTafGHMOQDInz3bF0"
+VUE_APP_CLIENT_ID=""
+VUE_APP_CLIENT_SEC=""
VUE_APP_REDIRECT_URI="http://localhost:8080/callback"
+VUE_APP_CUSTOS_API_URL="https://custos.scigap.org/apiserver"
+VUE_APP_SUPER_CLIENT_ID=""
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
index e9c2f1f..f8d11e5 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -11,4 +11,5 @@
VUE_APP_CLIENT_ID: ''
VUE_APP_CLIENT_SEC: ''
VUE_APP_REDIRECT_URI: 'http://localhost:8080/callback'
-
+ VUE_APP_CUSTOS_API_URL: 'https://custos.scigap.org/apiserver'
+ VUE_APP_SUPER_CLIENT_ID: ''
diff --git a/entrypoint.sh b/entrypoint.sh
index 9b9b603..cddc10c 100644
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -11,7 +11,7 @@
cp $file $file.tmpl.js
fi
- envsubst '$VUE_APP_CLIENT_ID,$VUE_APP_CLIENT_SEC,$VUE_APP_REDIRECT_URI' < $file.tmpl.js > $file
+ envsubst '$VUE_APP_CLIENT_ID,$VUE_APP_CLIENT_SEC,$VUE_APP_REDIRECT_URI,$VUE_APP_CUSTOS_API_URL,$VUE_APP_SUPER_CLIENT_ID' < $file.tmpl.js > $file
done
echo "Starting Nginx"
diff --git a/src/config.js b/src/config.js
index 9a39d23..f03df5c 100644
--- a/src/config.js
+++ b/src/config.js
@@ -6,7 +6,9 @@
return {
clientId: '$VUE_APP_CLIENT_ID',
clientSec: '$VUE_APP_CLIENT_SEC',
- redirectURI: '$VUE_APP_REDIRECT_URI'
+ redirectURI: '$VUE_APP_REDIRECT_URI',
+ custosApiUrl: '$VUE_APP_CUSTOS_API_URL',
+ superClientId: '$VUE_APP_SUPER_CLIENT_ID'
}
}
diff --git a/src/lib/service/custos-service/custos-service-tenants.js b/src/lib/service/custos-service/custos-service-tenants.js
index 8be454b..9a87087 100644
--- a/src/lib/service/custos-service/custos-service-tenants.js
+++ b/src/lib/service/custos-service/custos-service-tenants.js
@@ -1,4 +1,5 @@
import CustosService from "./index";
+import config from "@/config";
export default class CustosTenants {
/**
@@ -26,7 +27,7 @@
};
// TODO fix.
- if (parentClientId !== "custos-6nwoqodstpe5mvcq09lh-10000101") {
+ if (parentClientId !== config.value('superClientId')) {
url = `${CustosService.ENDPOINTS.TENANTS}/child/tenants`;
params["parent_client_id"] = parentClientId;
} else {
@@ -95,7 +96,7 @@
async createTenant({username, firstName, lastName, email, password, tenantName, redirectUris, scope, domain, clientUri, logoUri, comment, applicationType, parentClientId, parentClientSecret}) {
let axiosInstance;
- if (parentClientId !== "custos-6nwoqodstpe5mvcq09lh-10000101") {
+ if (parentClientId !== config.value('superClientId')) {
axiosInstance = await this.custosService.getAxiosInstanceWithClientAuthorization({
clientId: parentClientId,
clientSecret: parentClientSecret
diff --git a/src/lib/store/modules/tenant.store.js b/src/lib/store/modules/tenant.store.js
index b8bd2fc..e4f8e80 100644
--- a/src/lib/store/modules/tenant.store.js
+++ b/src/lib/store/modules/tenant.store.js
@@ -1,4 +1,5 @@
import {custosService} from "../util/custos.util";
+import config from "@/config";
const getDefaultState = () => {
return {
@@ -37,7 +38,7 @@
let currentUsername = rootGetters["auth/currentUsername"];
// TODO fix
- if (client_id === "custos-6nwoqodstpe5mvcq09lh-10000101") {
+ if (client_id === config.value('superClientId')) {
type = "SUPER_TENANT";
} else if (parent_tenant_id === "0") {
type = "ADMIN_TENANT";
@@ -88,7 +89,7 @@
let currentUsername = rootGetters["auth/currentUsername"];
// TODO fix
- if (clientId === "custos-6nwoqodstpe5mvcq09lh-10000101") {
+ if (clientId === config.value('superClientId')) {
type = "SUPER_TENANT";
} else if (parent_tenant_id === "0") {
type = "ADMIN_TENANT";
diff --git a/src/lib/store/util/custos.util.js b/src/lib/store/util/custos.util.js
index 839bb95..8756695 100644
--- a/src/lib/store/util/custos.util.js
+++ b/src/lib/store/util/custos.util.js
@@ -5,5 +5,5 @@
clientId: config.value('clientId'),
clientSecret: config.value('clientSec'),
redirectURI: config.value('redirectURI'),
- baseURL: "https://custos.scigap.org/apiserver/"
+ baseURL: config.value('custosApiUrl')
});