Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple domains #338

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions sequent-ui/repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
dest: /home/ui_user/{{ item }}/SequentConfig.js
owner: ui_user
group: ui_user
mode: '0600'
mode: "0600"
with_items:
- admin-console
- election-portal
Expand All @@ -70,34 +70,34 @@
replace:
dest: /home/ui_user/admin-console/SequentConfig.js
regexp: " timeoutSeconds:.*"
replace: ' timeoutSeconds: {{config.iam.admin_auth_token_expiration_seconds}},'
replace: " timeoutSeconds: {{config.iam.admin_auth_token_expiration_seconds}},"

- name: sequent-ui, setting admin timeout correctly in admin-console, 2
become: true
become_user: ui_user
replace:
dest: /home/ui_user/admin-console/SequentConfig.js
regexp: "expires:.*"
replace: ' expires: {{ (config.iam.admin_auth_token_expiration_seconds / 60) | int }},'
regexp: "expires:.*"
replace: " expires: {{ (config.iam.admin_auth_token_expiration_seconds / 60) | int }},"

- name: sequent-ui, modifying admin-console SequentConfig.js for securing the api calls
become: true
become_user: ui_user
replace:
dest: /home/ui_user/admin-console/SequentConfig.js
regexp: '{{ item.regexp }}'
replace: '{{ item.replace }}'
regexp: "{{ item.regexp }}"
replace: "{{ item.replace }}"
with_items:
- regexp: 'baseUrl:.*$'
replace: 'baseUrl: "https://{{config.ballot_box.domain}}/admin-api/elections/api/",'
- regexp: 'publicURL:.*$'
replace: 'publicURL: "https://{{config.ballot_box.domain}}/admin-api/elections/public/",'
- regexp: 'authAPI:.*$'
replace: 'authAPI: "https://{{config.ballot_box.domain}}/admin-api/iam/api/",'
- regexp: 'dnieUrl:.*$'
replace: 'dnieUrl: "https://{{config.ballot_box.domain}}/admin-api/iam/api/authmethod/dnie/auth/",'
- regexp: 'electionsAPI:.*$'
replace: 'electionsAPI: "https://{{config.ballot_box.domain}}/admin-api/elections/api/",'
- regexp: "baseUrl:.*$"
replace: 'baseUrl: "/admin-api/elections/api/",'
- regexp: "publicURL:.*$"
replace: 'publicURL: "/admin-api/elections/public/",'
- regexp: "authAPI:.*$"
replace: 'authAPI: "/admin-api/iam/api/",'
- regexp: "dnieUrl:.*$"
replace: 'dnieUrl: "/admin-api/iam/api/authmethod/dnie/auth/",'
- regexp: "electionsAPI:.*$"
replace: 'electionsAPI: "/admin-api/elections/api/",'

# this is not slow because yarn caches dependencies
- name: sequent-ui, removing node_modules directory to start fresh
Expand Down
18 changes: 12 additions & 6 deletions sequent-ui/templates/SequentConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var SequentConfigData = {
// 'https://foo/api/v3/' and always ends in '/'.
base: '',
theme: "{{ config.sequent_ui.theme }}",
baseUrl: "https://{{config.ballot_box.domain}}/elections/api/",
baseUrl: "/elections/api/",
freeAuthId: 1,

// Configurable Sign Up link
Expand Down Expand Up @@ -57,10 +57,10 @@ var SequentConfigData = {
preventSiteTranslation: {% if config.sequent_ui.prevent_site_translation %}true{% else %}false{% endif %},

// AuthApi base url
authAPI: "https://{{config.ballot_box.domain}}/iam/api/",
dnieUrl: "https://{{config.ballot_box.domain}}/iam/api/authmethod/dnie/auth/",
authAPI: "/iam/api/",
dnieUrl: "/iam/api/authmethod/dnie/auth/",
// Agora Elections base url
electionsAPI: "https://{{config.ballot_box.domain}}/elections/api/",
electionsAPI: "/elections/api/",

// Agora Admin help url
helpUrl: "{{ config.sequent_ui.technology.documentation }}",
Expand Down Expand Up @@ -285,7 +285,7 @@ var SequentConfigData = {
{% if config.sequent_ui.custom_public_download_url %}
publicURL: "{{ config.sequent_ui.custom_public_download_url }}",
{% else %}
publicURL: "https://{{config.ballot_box.domain}}/elections/public/",
publicURL: "/elections/public/",
{% endif %}

// if we are in debug mode or not
Expand Down Expand Up @@ -428,7 +428,13 @@ var SequentConfigData = {
};

angular.module('SequentConfig', [])
.factory('ConfigService', function() {
.factory('ConfigService', function($location) {
var baseUrl = $location.protocol() + "://" + $location.host;
SequentConfigData.publicURL = baseUrl + SequentConfigData.publicURL;
SequentConfigData.electionsAPI = baseUrl + SequentConfigData.electionsAPI;
SequentConfigData.dnieUrl = baseUrl + SequentConfigData.dnieUrl;
SequentConfigData.authAPI = baseUrl + SequentConfigData.authAPI;
SequentConfigData.baseUrl = baseUrl + SequentConfigData.baseUrl;
return SequentConfigData;
});

Expand Down