Skip to content
Merged
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
6 changes: 5 additions & 1 deletion backend/apps/system/api/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
from sqlbot_xpack.config.model import SysArgModel


from apps.system.crud.parameter_manage import get_parameter_args, save_parameter_args
from apps.system.crud.parameter_manage import get_groups, get_parameter_args, save_parameter_args
from common.core.deps import SessionDep

router = APIRouter(tags=["system/parameter"], prefix="/system/parameter")

@router.get("/login")
async def get_login_args(session: SessionDep) -> list[SysArgModel]:
return await get_groups(session, "login")

@router.get("")
async def get_args(session: SessionDep) -> list[SysArgModel]:
return await get_parameter_args(session)
Expand Down
4 changes: 4 additions & 0 deletions backend/apps/system/crud/parameter_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ async def get_parameter_args(session: SessionDep) -> list[SysArgModel]:
group_args = await get_group_args(session=session)
return [x for x in group_args if not x.pkey.startswith('appearance.')]

async def get_groups(session: SessionDep, flag: str) -> list[SysArgModel]:
group_args = await get_group_args(session=session, flag=flag)
return group_args

async def save_parameter_args(session: SessionDep, request: Request):
allow_file_mapping = {
""" "test_logo": { "types": [".jpg", ".jpeg", ".png", ".svg"], "size": 5 * 1024 * 1024 } """
Expand Down
1 change: 1 addition & 0 deletions backend/common/utils/whitelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"/system/authentication/platform/status",
"/system/authentication/login/*",
"/system/authentication/sso/*",
"/system/parameter/login"
]

class WhitelistChecker:
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ export const routes = [
name: 'assistantTest',
component: assistantTest,
},
{
path: '/admin-login',
name: 'admin-login',
component: login,
},
{
path: '/401',
name: '401',
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/router/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { Router } from 'vue-router'
const appearanceStore = useAppearanceStoreWithOut()
const userStore = useUserStore()
const { wsCache } = useCache()
const whiteList = ['/login']
const whiteList = ['/login', '/admin-login']
const assistantWhiteList = ['/assistant', '/embeddedPage', '/401']
export const watchRouter = (router: Router) => {
router.beforeEach(async (to: any, from: any, next: any) => {
Expand Down Expand Up @@ -40,7 +40,7 @@ export const watchRouter = (router: Router) => {
next('/chat')
return
}
if (to.path === '/login') {
if (to.path === '/login' || to.path === '/admin-login') {
console.info(from)
next('/chat')
} else {
Expand Down
84 changes: 41 additions & 43 deletions frontend/src/views/login/xpack/Handler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</template>

<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import { ref, onMounted, nextTick, computed } from 'vue'
import QrcodeLdap from './QrcodeLdap.vue'
import LdapLoginForm from './LdapLoginForm.vue'
/* import Oidc from './Oidc.vue'
Expand All @@ -77,14 +77,18 @@ defineProps<{
loading: boolean
}>()
const emits = defineEmits(['switchTab', 'autoCallback', 'update:loading'])
const updateLoading = (show: boolean) => {
emits('update:loading', show)
const updateLoading = (show: boolean, time: number = 1000) => {
setTimeout(() => {
emits('update:loading', show)
}, time)
}
const { t } = useI18n()
interface Categoryparam {
category: string
proxy?: string
}

const adminLogin = computed(() => router.currentRoute?.value?.name === 'admin-login')
const loginDialogVisible = ref(false)
const dialogTitle = ref('')
const dialogInterval = ref<any>(null)
Expand All @@ -102,7 +106,7 @@ const userStore = useUserStore()
const qrStatus = ref(false)
const loginCategory = ref({} as LoginCategory)
const anyEnable = ref(false)
// const qrcodeLdapHandler = ref()
const qrcodeLdapHandler = ref()
const oauth2Handler = ref()
const saml2Handler = ref()
/* const state = reactive({
Expand Down Expand Up @@ -232,21 +236,21 @@ const toMfa = (mfa) => {
document.getElementsByClassName('preheat-container')[0].setAttribute('style', 'display: none;')
}
} */
/* const ssoLogin = (category) => {
const ssoLogin = (category: any) => {
const array = [
{ category: 'ldap', proxy: '' },
{ category: 'oidc', proxy: '/oidcbi/#' },
{ category: 'cas', proxy: '/casbi/#' },
{ category: 'oidc', proxy: '/oidcbi/#' },
{ category: 'ldap', proxy: '' },
{ category: 'oauth2', proxy: '/#' },
{ category: 'saml2', proxy: '/#' },
]
if (category) {
if (category === 1) {
if (category === 3) {
qrcodeLdapHandler.value?.setActive('ldap')
}
switcherCategory(array[category - 1])
}
} */
}

const switcherCategory = async (param: Categoryparam) => {
const { category, proxy } = param
Expand Down Expand Up @@ -540,47 +544,41 @@ const callBackType = () => {
return getQueryString('state')
}

/* const auto2Platform = async () => {
const resultParam = {
preheat: true,
loadingText: '加载中...',
activeName: 'simple',
const auto2Platform = async () => {
if (adminLogin.value) {
updateLoading(false, 100)
return
}
if (!checkPlatform()) {
const res = await loginCategoryApi()
const adminLogin = router.currentRoute?.value?.name === 'admin-login'
if (adminLogin && (!res.data || res.data === 1)) {
emits('autoCallback', resultParam)
router.push('/401')
return
}
if (res.data && !adminLogin) {
if (res.data === 1) {
resultParam.activeName = 'ldap'
resultParam.preheat = false
} else {
resultParam.loadingText = '加载中...'
document.getElementsByClassName('ed-loading-text')?.length &&
(document.getElementsByClassName('ed-loading-text')[0]['innerText'] =
resultParam.loadingText)
}
nextTick(() => {
ssoLogin(res.data)
})
} else {
resultParam.preheat = false
const resData = await request.get('/system/parameter/login')
let res = 0
const resObj = {} as any
resData.forEach((item: any) => {
resObj[item.pkey] = item.pval
})
res = parseInt(resObj['login.default_login'] || 0)

if (res && !adminLogin.value) {
if (res === 3) {
qrStatusChange('ldap')
updateLoading(false)
}
} else if (getQueryString('state')?.includes('fit2clouddeoauth2')) {
resultParam.preheat = true
nextTick(() => {
ssoLogin(res)
})
} else {
updateLoading(false)
}
emits('autoCallback', resultParam)
} */
}

onMounted(() => {
if (adminLogin.value) {
updateLoading(false, 100)
return
}
// eslint-disable-next-line no-undef
const obj = LicenseGenerator.getLicense()
if (obj?.status !== 'valid') {
updateLoading(false)
updateLoading(false, 100)
return
}
wsCache.delete('de-platform-client')
Expand All @@ -594,7 +592,7 @@ onMounted(() => {
} else if (state?.includes('oidc')) {
oidcLogin()
} else {
updateLoading(false)
auto2Platform()
}
/* else if (window.location.pathname.includes('/oidcbi/')) {
platformLogin(2)
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/views/login/xpack/QrcodeLdap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ const setActive = (active?: string) => {
}
validComponentList.value[index] = componentMap.value[activeComponent.value]
activeComponent.value = item.key
if (active === 'ldap') {
hiddenDefaultTabs()
}
}
defineExpose({
setActive,
Expand Down