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
3 changes: 3 additions & 0 deletions backend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,8 @@
},
"i18n_excel_import": {
"col_num_not_match": "Number of columns in Excel does not match"
},
"i18n_authentication": {
"record_not_exist": "{msg} record does not exist. Please save it first!"
}
}
3 changes: 3 additions & 0 deletions backend/locales/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,8 @@
},
"i18n_excel_import": {
"col_num_not_match": "Excel 열 개수가 일치하지 않습니다"
},
"i18n_authentication": {
"record_not_exist": "{msg} 기록이 존재하지 않습니다. 먼저 저장해 주세요!"
}
}
3 changes: 3 additions & 0 deletions backend/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,8 @@
},
"i18n_excel_import": {
"col_num_not_match": "EXCEL列数量不匹配"
},
"i18n_authentication": {
"record_not_exist": "{msg} 记录不存在,请先保存!"
}
}
1 change: 1 addition & 0 deletions frontend/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@
"valid": "Valid",
"cas_settings": "CAS Settings",
"callback_domain_name": "Callback Domain",
"callback_domain_name_error": "Callback URL must match the current access domain",
"field_mapping": "User Attribute Mapping",
"field_mapping_placeholder": "Example: {'{'}\"account\": \"saml2Account\", \"name\": \"saml2Name\", \"email\": \"email\"{'}'}",
"incorrect_please_re_enter": "Incorrect format, please re-enter",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@
"valid": "유효함",
"cas_settings": "CAS 설정",
"callback_domain_name": "콜백 도메인",
"callback_domain_name_error": "콜백 URL은 현재 접속 도메인과 일치해야 합니다",
"field_mapping": "사용자 속성 매핑",
"field_mapping_placeholder": "예: {'{'}\"account\": \"saml2Account\", \"name\": \"saml2Name\", \"email\": \"email\"{'}'}",
"incorrect_please_re_enter": "형식이 잘못되었습니다. 다시 입력해 주세요",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@
"valid": "有效",
"cas_settings": "CAS 设置",
"callback_domain_name": "回调地址",
"callback_domain_name_error": "回调地址必须是当前访问域名",
"field_mapping": "用户属性映射",
"field_mapping_placeholder": "例如:{'{'}\"account\": \"saml2Account\", \"name\": \"saml2Name\", \"email\": \"email\"{'}'}",
"incorrect_please_re_enter": "格式错误,请重新填写",
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,11 @@ export function isMobile() {
) && !isTablet()
)
}

export const getSQLBotAddr = (portEnd?: boolean) => {
const addr = location.origin + location.pathname
if (!portEnd || !addr.endsWith('/')) {
return addr
}
return addr.substring(0, addr.length - 1)
}
14 changes: 12 additions & 2 deletions frontend/src/views/system/authentication/CasEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ElMessage, ElLoading } from 'element-plus-secondary'
import { useI18n } from 'vue-i18n'
import type { FormInstance, FormRules } from 'element-plus-secondary'
import { request } from '@/utils/request'
import { getSQLBotAddr } from '@/utils/utils'
const { t } = useI18n()
const dialogVisible = ref(false)
const loadingInstance = ref<ReturnType<typeof ElLoading.service> | null>(null)
Expand All @@ -17,7 +18,7 @@ interface CasForm {
const state = reactive({
form: reactive<CasForm>({
idpUri: '',
casCallbackDomain: '',
casCallbackDomain: getSQLBotAddr(),
mapping: '',
}),
})
Expand All @@ -33,6 +34,15 @@ const validateUrl = (rule, value, callback) => {
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
const validateCbUrl = (rule, value, callback) => {
const addr = getSQLBotAddr()
if (value === addr || `${value}/` === addr) {
callback()
}
callback(new Error(t('authentication.callback_domain_name_error')))
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
const validateMapping = (rule, value, callback) => {
if (!value) {
callback()
Expand Down Expand Up @@ -76,7 +86,7 @@ const rule = reactive<FormRules>({
message: t('commons.input_limit', [10, 255]),
trigger: 'blur',
},
{ required: true, validator: validateUrl, trigger: 'blur' },
{ required: true, validator: validateCbUrl, trigger: 'blur' },
],
mapping: [{ required: false, validator: validateMapping, trigger: 'blur' }],
})
Expand Down
15 changes: 13 additions & 2 deletions frontend/src/views/system/authentication/Oauth2Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
ElSelect,
} from 'element-plus-secondary'
import { request } from '@/utils/request'
import { getSQLBotAddr } from '@/utils/utils'

const { t } = useI18n()
const dialogVisible = ref(false)
const loadingInstance = ref<ReturnType<typeof ElLoading.service> | null>(null)
Expand All @@ -26,7 +28,7 @@ const state = reactive({
scope: '',
client_id: '',
client_secret: '',
redirect_url: '',
redirect_url: getSQLBotAddr(),
token_auth_method: 'basic',
userinfo_auth_method: 'header',
logout_redirect_url: '',
Expand Down Expand Up @@ -81,6 +83,15 @@ const validateUrl = (rule, value, callback) => {
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
const validateCbUrl = (rule, value, callback) => {
const addr = getSQLBotAddr()
if (value === addr || `${value}/` === addr) {
callback()
}
callback(new Error(t('authentication.callback_domain_name_error')))
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
const validateMapping = (rule, value, callback) => {
if (value === null || value === '') {
callback()
Expand Down Expand Up @@ -183,7 +194,7 @@ const rule = reactive<FormRules>({
message: t('commons.input_limit', [10, 255]),
trigger: 'blur',
},
{ required: true, validator: validateUrl, trigger: 'blur' },
{ required: true, validator: validateCbUrl, trigger: 'blur' },
],
mapping: [{ required: false, validator: validateMapping, trigger: 'blur' }],
})
Expand Down
15 changes: 13 additions & 2 deletions frontend/src/views/system/authentication/OidcEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { ElMessage, ElLoading } from 'element-plus-secondary'
import { useI18n } from 'vue-i18n'
import type { FormInstance, FormRules } from 'element-plus-secondary'
import { request } from '@/utils/request'
import { getSQLBotAddr } from '@/utils/utils'

const { t } = useI18n()
const dialogVisible = ref(false)
const loadingInstance = ref<ReturnType<typeof ElLoading.service> | null>(null)
Expand All @@ -15,7 +17,7 @@ const state = reactive({
client_id: '',
client_secret: '',
metadata_url: '',
redirect_uri: '',
redirect_uri: getSQLBotAddr(),
realm: '',
scope: '',
mapping: '',
Expand Down Expand Up @@ -45,6 +47,15 @@ const validateMapping = (rule, value, callback) => {
}
callback()
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
const validateCbUrl = (rule, value, callback) => {
const addr = getSQLBotAddr()
if (value === addr || `${value}/` === addr) {
callback()
}
callback(new Error(t('authentication.callback_domain_name_error')))
}
const rule = reactive<FormRules>({
client_id: [
{
Expand Down Expand Up @@ -84,7 +95,7 @@ const rule = reactive<FormRules>({
message: t('commons.input_limit', [10, 255]),
trigger: 'blur',
},
{ required: true, validator: validateUrl, trigger: 'blur' },
{ required: true, validator: validateCbUrl, trigger: 'blur' },
],
metadata_url: [
{
Expand Down
16 changes: 7 additions & 9 deletions frontend/src/views/system/authentication/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ const init = (needLoading: boolean) => {
.get(url)
.then((res) => {
if (res) {
infos.value = [...(res as CardInfo[])].filter((item) => item.name !== 'saml2')
const templateArray = ['ldap', 'oidc', 'cas', 'oauth2']
const resultList = [...(res as CardInfo[])].filter((item) => item.name !== 'saml2')
let resultMap = {} as any
resultList.forEach((item: any) => {
resultMap[item.name] = item
})
infos.value = templateArray.map((item: string) => resultMap[item])
showInfos.value = [...infos.value]
}
loading.value = false
Expand Down Expand Up @@ -130,14 +136,6 @@ const editInfo = (item: CardInfo) => {
}
}
const validate = (id: any) => {
if (!id) {
ElMessage.error(
`${t('ds.test_connection') + t('report.last_status_fail')}: ${t(
'system.platform_information_first'
)}`
)
return
}
loading.value = true
request
.patch('/system/authentication/status', { type: id, name: '', config: '' })
Expand Down