Skip to content

Commit

Permalink
urls now sent by backend and add javascript origin url
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Nov 4, 2024
1 parent 2690e9d commit face099
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/components/modals/coresettings/EditCoreSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<q-tab name="webhooks" label="Web Hooks" />
<q-tab name="retention" label="Retention" />
<q-tab name="apikeys" label="API Keys" />
<q-tab name="sso" label="Single Sign-On" />
<q-tab name="sso" label="Single Sign-On (SSO)" />
<!-- <q-tab name="openai" label="Open AI" /> -->
</q-tabs>
</template>
Expand Down
51 changes: 39 additions & 12 deletions src/ee/sso/components/SSOProvidersTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ For details, see: https://license.tacticalrmm.com/ee
dense
:rows="providers"
:columns="columns"
:visible-columns="visibleColumns"
:pagination="{ rowsPerPage: 0, sortBy: 'name', descending: true }"
row-key="id"
binary-state-sort
Expand Down Expand Up @@ -79,17 +80,32 @@ For details, see: https://license.tacticalrmm.com/ee

<q-separator></q-separator>

<!-- callback url -->
<q-item
clickable
v-close-popup
@click="getCallbackURL(props.row)"
@click="getCallbackURL(props.row.callback_url)"
>
<q-item-section side>
<q-icon name="description" />
</q-item-section>
<q-item-section>Copy Callback URL</q-item-section>
</q-item>

<!-- javascript origin url (used by google oath) -->
<q-item
clickable
v-close-popup
@click="getCallbackURL(props.row.javascript_origin_url)"
>
<q-item-section side>
<q-icon name="description" />
</q-item-section>
<q-item-section
>Copy Allowed JavaScript Origin to Clipboard</q-item-section
>
</q-item>

<q-separator></q-separator>

<q-item clickable v-close-popup>
Expand All @@ -99,24 +115,24 @@ For details, see: https://license.tacticalrmm.com/ee
</q-menu>
<!-- name -->
<q-td>
{{ truncateText(props.row.name, 35) }}
{{ truncateText(props.row.name, 25) }}
<q-tooltip>{{ props.row.name }}</q-tooltip>
</q-td>
<!-- server_url -->
<q-td>
{{ truncateText(props.row.server_url, 35) }}
{{ truncateText(props.row.server_url, 20) }}
<q-tooltip>{{ props.row.server_url }}</q-tooltip>
</q-td>
<!-- pattern -->
<q-td>
{{ truncateText(props.row.client_id, 35) }}
{{ truncateText(props.row.client_id, 20) }}
<q-tooltip>{{ props.row.client_id }}</q-tooltip>
</q-td>
<q-td>
<q-icon
size="sm"
name="content_copy"
@click="getCallbackURL(props.row)"
@click="getCallbackURL(props.row.callback_url)"
>
<q-tooltip>Copy Callback URL to Clipboard</q-tooltip>
</q-icon>
Expand All @@ -129,7 +145,7 @@ For details, see: https://license.tacticalrmm.com/ee

<script setup lang="ts">
// composition imports
import { ref, onMounted } from "vue";
import { computed, ref, onMounted } from "vue";
import { useStore } from "vuex";
import { QTableColumn, useQuasar, copyToClipboard } from "quasar";
import {
Expand All @@ -139,7 +155,6 @@ import {
} from "@/ee/sso/api/sso";
import { notifySuccess } from "@/utils/notify";
import { truncateText } from "@/utils/format";
import { getBaseUrl } from "@/boot/axios";

// ui imports
import SSOProvidersForm from "@/ee/sso/components/SSOProvidersForm.vue";
Expand Down Expand Up @@ -183,11 +198,25 @@ const columns: QTableColumn[] = [
{
name: "callback_url",
label: "Callback URL",
field: "callback_url",
align: "left",
sortable: false,
},
{
name: "javascript_origin_url",
label: "Javascript Origin URL",
field: "javascript_origin_url",
align: "left",
sortable: false,
},
];

const visibleColumns = computed(() => {
return columns
.map((column) => column.name)
.filter((name) => name !== "javascript_origin_url");
});

async function getSSOSettings() {
try {
ssoSettings.value = await fetchSSOSettings();
Expand Down Expand Up @@ -239,11 +268,9 @@ function deleteSSOProvider(provider: SSOProvider) {
});
}

function getCallbackURL(provider: SSOProvider) {
copyToClipboard(
`${getBaseUrl()}/accounts/oidc/${provider.provider_id}/login/callback/`,
).then(() => {
notifySuccess("Callback URL copied!");
function getCallbackURL(url: string) {
copyToClipboard(url).then(() => {
notifySuccess("URL copied!");
});
}

Expand Down

0 comments on commit face099

Please sign in to comment.