Commit b21af278 authored by Anton's avatar Anton

Add default env file to configure app externally at runtime

parent f17d734c
Pipeline #16887 passed with stage
in 1 minute and 17 seconds
...@@ -29,6 +29,8 @@ under `media/create` (playback possible using forked ...@@ -29,6 +29,8 @@ under `media/create` (playback possible using forked
[vue-video-player](https://github.com/dasantonym/vue-video-player)) [vue-video-player](https://github.com/dasantonym/vue-video-player))
- Export timelines as CSV - Export timelines as CSV
- Mobile compatiblity for MoSys Editor - Mobile compatiblity for MoSys Editor
- The file `statics/env.js` can be overwritten to configure
the frontend at runtime
### Changed ### Changed
......
...@@ -13,11 +13,11 @@ const ...@@ -13,11 +13,11 @@ const
keytarAccount = os.userInfo().username keytarAccount = os.userInfo().username
function getAuthenticationURL () { function getAuthenticationURL () {
return 'https://' + process.env.AUTH0_DOMAIN + '/authorize?' + return 'https://' + (window.AUTH0_DOMAIN || process.env.AUTH0_DOMAIN) + '/authorize?' +
'audience=' + process.env.AUTH0_AUDIENCE + '&' + 'audience=' + (window.AUTH0_AUDIENCE || process.env.AUTH0_AUDIENCE) + '&' +
'scope=openid profile offline_access&' + 'scope=openid profile offline_access&' +
'response_type=code&' + 'response_type=code&' +
'client_id=' + process.env.AUTH0_CLIENT_ID + '&' + 'client_id=' + (window.AUTH0_CLIENT_ID || process.env.AUTH0_CLIENT_ID) + '&' +
'redirect_uri=' + redirectUri 'redirect_uri=' + redirectUri
} }
...@@ -25,9 +25,9 @@ async function refreshTokens () { ...@@ -25,9 +25,9 @@ async function refreshTokens () {
const refreshToken = await keytar.getPassword(keytarService, keytarAccount) const refreshToken = await keytar.getPassword(keytarService, keytarAccount)
if (!refreshToken) return throw new Error('No refresh token found') if (!refreshToken) return throw new Error('No refresh token found')
const result = await axios.post(`https://${process.env.AUTH0_DOMAIN}/oauth/token`, { const result = await axios.post(`https://${window.AUTH0_DOMAIN || process.env.AUTH0_DOMAIN}/oauth/token`, {
grant_type: 'refresh_token', grant_type: 'refresh_token',
client_id: process.env.AUTH0_CLIENT_ID, client_id: window.AUTH0_CLIENT_ID || process.env.AUTH0_CLIENT_ID,
refresh_token: refreshToken refresh_token: refreshToken
}, { }, {
headers: {'Content-Type': 'application/json'} headers: {'Content-Type': 'application/json'}
...@@ -43,12 +43,12 @@ async function loadTokens (callbackURL) { ...@@ -43,12 +43,12 @@ async function loadTokens (callbackURL) {
const exchangeOptions = { const exchangeOptions = {
'grant_type': 'authorization_code', 'grant_type': 'authorization_code',
'client_id': process.env.AUTH0_CLIENT_ID, 'client_id': window.AUTH0_CLIENT_ID || process.env.AUTH0_CLIENT_ID,
'code': query.code, 'code': query.code,
'redirect_uri': redirectUri 'redirect_uri': redirectUri
} }
const result = await axios.post(`https://${process.env.AUTH0_DOMAIN}/oauth/token`, exchangeOptions, { const result = await axios.post(`https://${window.AUTH0_DOMAIN || process.env.AUTH0_DOMAIN}/oauth/token`, exchangeOptions, {
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
...@@ -66,7 +66,7 @@ async function logout () { ...@@ -66,7 +66,7 @@ async function logout () {
} }
function getLogOutUrl () { function getLogOutUrl () {
return `https://${process.env.AUTH0_DOMAIN}/v2/logout` return `https://${window.AUTH0_DOMAIN || process.env.AUTH0_DOMAIN}/v2/logout`
} }
export { export {
......
...@@ -9,7 +9,10 @@ ...@@ -9,7 +9,10 @@
<script> <script>
export default { export default {
name: 'App' name: 'App',
mounted () {
console.log(window.TRANSCODER_HOST)
}
} }
</script> </script>
......
...@@ -21,5 +21,6 @@ ...@@ -21,5 +21,6 @@
<div id="q-app"></div> <div id="q-app"></div>
<!-- built files will be auto injected here --> <!-- built files will be auto injected here -->
<script src="statics/env.js" language="JavaScript"></script>
</body> </body>
</html> </html>
...@@ -8,10 +8,10 @@ export default ({ Vue }) => { ...@@ -8,10 +8,10 @@ export default ({ Vue }) => {
} }
else { else {
authService = new AuthService({ authService = new AuthService({
domain: process.env.AUTH0_DOMAIN, domain: window.AUTH0_DOMAIN || process.env.AUTH0_DOMAIN,
clientID: process.env.AUTH0_CLIENT_ID, clientID: window.AUTH0_CLIENT_ID || process.env.AUTH0_CLIENT_ID,
redirectUri: process.env.AUTH0_REDIRECT_URL || `${document.location.origin}/users/callback`, redirectUri: `${document.location.origin}/users/callback`,
audience: process.env.AUTH0_AUDIENCE, audience: window.AUTH0_AUDIENCE || process.env.AUTH0_AUDIENCE,
scope: 'openid profile read write', scope: 'openid profile read write',
responseType: 'token id_token' responseType: 'token id_token'
}) })
......
Object.assign(window, {
//
// HOST CONFIG
//
API_HOST: 'https://api.motionbank.org',
TRANSCODER_HOST: 'https://transcoder.motionbank.org',
SOCKETS_HOST: 'https://sockets.motionbank.org',
STORAGE_HOST: 'https://storage.motionbank.org',
PACKAGER_HOST: 'https://packager.motionbank.org',
//
// AUTH
//
AUTH0_CLIENT_ID: '80t5TRU9MVhGDVnZ522CvX4hutBxDB6U',
AUTH0_DOMAIN: 'auth.motionbank.org',
AUTH0_AUDIENCE: 'https://api.motionbank.org'
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment