Skip to content

Commit

Permalink
Merge pull request #28 from sadnub/sso
Browse files Browse the repository at this point in the history
feat: single sign-on amidaware/tacticalrmm#508
  • Loading branch information
wh1te909 authored Nov 20, 2024
2 parents 1adeadd + 09ecc36 commit 4932997
Show file tree
Hide file tree
Showing 26 changed files with 1,549 additions and 186 deletions.
66 changes: 33 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
"format": "prettier --write \"**/*.{js,ts,vue,,html,md,json}\" --ignore-path .gitignore"
},
"dependencies": {
"@quasar/extras": "1.16.12",
"@vueuse/core": "11.1.0",
"@vueuse/integrations": "11.1.0",
"@vueuse/shared": "11.1.0",
"@quasar/extras": "1.16.13",
"@vueuse/core": "11.2.0",
"@vueuse/integrations": "11.2.0",
"@vueuse/shared": "11.2.0",
"apexcharts": "3.54.1",
"axios": "1.7.7",
"dotenv": "16.4.5",
"monaco-editor": "0.50.0",
"pinia": "2.2.4",
"pinia": "2.2.6",
"qrcode": "1.5.4",
"quasar": "2.17.1",
"quasar": "2.17.2",
"vue": "3.5.12",
"vue-router": "4.4.5",
"vue3-apexcharts": "1.7.0",
Expand Down
18 changes: 16 additions & 2 deletions quasar.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// Configuration for your app
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js

const { mergeConfig } = require("vite");
const { configure } = require("quasar/wrappers");
const path = require("path");
require("dotenv").config();
Expand Down Expand Up @@ -78,9 +79,22 @@ module.exports = configure(function (/* ctx */) {
// polyfillModulePreload: true,
distDir: "dist/",

// extendViteConf (viteConf) {},
/* eslint-disable quotes */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
extendViteConf(viteConf, { isServer, isClient }) {
viteConf.build = mergeConfig(viteConf.build, {
chunkSizeWarningLimit: 1600,
rollupOptions: {
output: {
entryFileNames: `[hash].js`,
chunkFileNames: `[hash].js`,
assetFileNames: `[hash].[ext]`,
},
},
});
},
/* eslint-enable quotes */
// viteVuePluginOptions: {},

// vitePlugins: []
},

Expand Down
28 changes: 28 additions & 0 deletions src/api/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,34 @@ export async function resetTwoFactor() {
}
}

// sessions api
export async function fetchUserSessions(id) {
try {
const { data } = await axios.get(`${baseUrl}/users/${id}/sessions/`);
return data;
} catch (e) {
console.error(e);
}
}

export async function deleteAllUserSessions(id) {
try {
const { data } = await axios.delete(`${baseUrl}/users/${id}/sessions/`);
return data;
} catch (e) {
console.error(e);
}
}

export async function deleteUserSession(id) {
try {
const { data } = await axios.delete(`${baseUrl}/sessions/${id}/`);
return data;
} catch (e) {
console.error(e);
}
}

// role api function
export async function fetchRoles(params = {}) {
try {
Expand Down
7 changes: 7 additions & 0 deletions src/api/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ import type {
TestRunURLActionResponse,
} from "@/types/core/urlactions";

import type { CoreSetting } from "@/types/core/settings";

const baseUrl = "/core";

export async function fetchCoreSettings(params = {}): Promise<CoreSetting> {
const { data } = await axios.get("/core/settings/", { params: params });
return data;
}

export async function fetchDashboardInfo(params = {}) {
const { data } = await axios.get(`${baseUrl}/dashinfo/`, { params: params });
return data;
Expand Down
15 changes: 12 additions & 3 deletions src/boot/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function setErrorMessage(data, message) {

export default function ({ app, router }) {
app.config.globalProperties.$axios = axios;
axios.defaults.withCredentials = true;

axios.interceptors.request.use(
function (config) {
Expand Down Expand Up @@ -65,12 +66,20 @@ export default function ({ app, router }) {
// perms
else if (error.response.status === 403) {
// don't notify user if method is GET
if (error.config.method === "get" || error.config.method === "patch")
if (
error.config.method === "get" ||
error.config.method === "patch" ||
error.config.url === "accounts/ssoproviders/token/"
)
return Promise.reject({ ...error });
text = error.response.data.detail;
}
// catch all for other 400 error messages
else if (error.response.status >= 400 && error.response.status < 500) {
else if (
error.response.status >= 400 &&
error.response.status < 500 &&
error.response.status !== 423
) {
if (error.config.responseType === "blob") {
text = (await error.response.data.text()).replace(/^"|"$/g, "");
} else if (error.response.data.non_field_errors) {
Expand All @@ -85,7 +94,7 @@ export default function ({ app, router }) {
}
}

if (text || error.response) {
if ((text || error.response) && error.response.status !== 423) {
Notify.create({
color: "negative",
message: text ? text : "",
Expand Down
Loading

0 comments on commit 4932997

Please sign in to comment.