Skip to content

Commit b7c3ec3

Browse files
author
Taras Ivashchenko
committed
Add option for OIDC login button title
1 parent 964c517 commit b7c3ec3

File tree

6 files changed

+32
-15
lines changed

6 files changed

+32
-15
lines changed

docker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ services:
2222
# - "OIDC_CLIENT_ID="
2323
# - "OIDC_SCOPE="
2424
# - "OIDC_FLOW="
25+
# - "OIDC_LOGIN_BUTTON_TEXT="
2526
# volumes:
2627
# - "/host/path/to/config.json:/app/static/config.json"
2728
ports:

docker/docker-entrypoint.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ if mount | grep '/static/config.json'; then
77
echo "config.json is mounted from host - ENV configuration will be ignored"
88
else
99
# Apply ENV vars to temporary config.json
10-
jq --arg apiBaseUrl "$API_BASE_URL" \
11-
--arg oidcIssuer "$OIDC_ISSUER" \
12-
--arg oidcClientId "$OIDC_CLIENT_ID" \
13-
--arg oidcScope "$OIDC_SCOPE" \
14-
--arg oidcFlow "$OIDC_FLOW" \
15-
'.API_BASE_URL = $apiBaseUrl
16-
| .OIDC_ISSUER = $oidcIssuer
17-
| .OIDC_CLIENT_ID = $oidcClientId
18-
| .OIDC_SCOPE = $oidcScope
19-
| .OIDC_FLOW = $oidcFlow' \
10+
jq --arg apiBaseUrl "$API_BASE_URL" \
11+
--arg oidcIssuer "$OIDC_ISSUER" \
12+
--arg oidcClientId "$OIDC_CLIENT_ID" \
13+
--arg oidcScope "$OIDC_SCOPE" \
14+
--arg oidcFlow "$OIDC_FLOW" \
15+
--arg oidcLoginButtonText "$OIDC_LOGIN_BUTTON_TEXT" \
16+
'.API_BASE_URL = $apiBaseUrl
17+
| .OIDC_ISSUER = $oidcIssuer
18+
| .OIDC_CLIENT_ID = $oidcClientId
19+
| .OIDC_SCOPE = $oidcScope
20+
| .OIDC_FLOW = $oidcFlow
21+
| .OIDC_LOGIN_BUTTON_TEXT = $oidcLoginButtonText' \
2022
./static/config.json > /tmp/config.json
2123

2224
# Override default config file

public/static/config.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"OIDC_ISSUER": "",
44
"OIDC_CLIENT_ID": "",
55
"OIDC_SCOPE": "openid email profile",
6-
"OIDC_FLOW": "code"
7-
}
6+
"OIDC_FLOW": "code",
7+
"OIDC_LOGIN_BUTTON_TEXT" : ""
8+
}

src/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ axios.get(contextPath + "/static/config.json").then(response => {
4949
Vue.prototype.$oidc.CLIENT_ID = response.data.OIDC_CLIENT_ID;
5050
Vue.prototype.$oidc.SCOPE = response.data.OIDC_SCOPE;
5151
Vue.prototype.$oidc.FLOW = response.data.OIDC_FLOW;
52+
if (response.data.OIDC_LOGIN_BUTTON_TEXT) {
53+
Vue.prototype.$oidc.LOGIN_BUTTON_TEXT = response.data.OIDC_LOGIN_BUTTON_TEXT;
54+
} else {
55+
Vue.prototype.$oidc.LOGIN_BUTTON_TEXT = "";
56+
}
5257
createVueApp();
5358
}).catch(function (error) {
5459
console.log("Cannot retrieve static/config.json from host. This is expected behavior in development environments.");

src/shared/oidc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"ISSUER": "",
33
"CLIENT_ID": "",
44
"SCOPE": "",
5-
"FLOW": ""
6-
}
5+
"FLOW": "",
6+
"LOGIN_BUTTON_TEXT": ""
7+
}

src/views/pages/Login.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
</b-col>
4444
<b-col cols="6" v-show="oidcAvailable">
4545
<b-button style="float: right" v-on:click="oidcLogin()">
46-
<img alt="OpenID Logo" src="@/assets/img/openid-logo.svg" width="60px" />
46+
<span v-if="oidcCheckLoginButtonTextSetted()">{{ oidcLoginButtonText() }}</span>
47+
<img alt="OpenID Logo" src="@/assets/img/openid-logo.svg" width="60px" v-else />
4748
</b-button>
4849
</b-col>
4950
</b-row>
@@ -177,6 +178,12 @@ export default {
177178
console.log(err);
178179
this.$toastr.e(this.$t("message.oidc_redirect_failed"));
179180
});
181+
},
182+
oidcCheckLoginButtonTextSetted() {
183+
return this.$oidc.LOGIN_BUTTON_TEXT.length > 0;
184+
},
185+
oidcLoginButtonText() {
186+
return this.$oidc.LOGIN_BUTTON_TEXT;
180187
}
181188
},
182189
mounted() {

0 commit comments

Comments
 (0)