first push 0.7
This commit is contained in:
@@ -5,7 +5,9 @@ export default {
|
||||
'common.button.editmode': 'Edit mode',
|
||||
'common.button.shortcut': 'Keyboard Shortcut',
|
||||
'common.button.add': 'Add',
|
||||
'common.button.login': 'Log In',
|
||||
'common.button.login': 'Use a local user',
|
||||
'common.button.oidclogin': 'Login In With OIDC',
|
||||
'common.button.samllogin': 'Login In With SAML',
|
||||
'common.button.select': 'Select',
|
||||
'common.button.selected': 'Selected',
|
||||
'common.button.continue': 'Continue',
|
||||
|
||||
@@ -6,6 +6,7 @@ export default {
|
||||
'users.table.username': 'User Name',
|
||||
'users.table.role': 'Role',
|
||||
'users.form.fullname': 'Full Name',
|
||||
'users.form.source': 'Source',
|
||||
'users.table.user': 'users',
|
||||
'users.form.admin': 'Admin',
|
||||
'users.form.user': 'User',
|
||||
|
||||
@@ -6,6 +6,8 @@ export default {
|
||||
'common.button.shortcut': 'キーボードショートカット',
|
||||
'common.button.add': '追加',
|
||||
'common.button.login': 'ログイン',
|
||||
'common.button.oidclogin': 'OIDCでログイン',
|
||||
'common.button.samllogin': 'SAMLでログイン',
|
||||
'common.button.select': '選択',
|
||||
'common.button.selected': '選択済み',
|
||||
'common.button.continue': '続行',
|
||||
|
||||
@@ -6,6 +6,7 @@ export default {
|
||||
'users.table.username': 'ユーザー名',
|
||||
'users.table.role': '役割',
|
||||
'users.form.fullname': 'フルネーム',
|
||||
'users.form.source': 'ソース',
|
||||
'users.table.user': 'ユーザー',
|
||||
'users.form.admin': '管理者',
|
||||
'users.form.user': '一般ユーザー',
|
||||
|
||||
@@ -6,6 +6,8 @@ export default {
|
||||
'common.button.shortcut': 'Сочетания клавиш',
|
||||
'common.button.add': 'Добавить',
|
||||
'common.button.login': 'Войти',
|
||||
'common.button.oidclogin': 'Войти с OIDC',
|
||||
'common.button.samllogin': 'Войти с SAML',
|
||||
'common.button.select': 'Выбрать',
|
||||
'common.button.selected': 'Выбрано',
|
||||
'common.button.continue': 'Продолжить',
|
||||
|
||||
@@ -6,6 +6,7 @@ export default {
|
||||
'users.table.username': 'Имя пользователя',
|
||||
'users.table.role': 'Роль',
|
||||
'users.form.fullname': 'Полное имя',
|
||||
'users.form.source': 'Источник',
|
||||
'users.table.user': 'пользователи',
|
||||
'users.form.admin': 'Администратор',
|
||||
'users.form.user': 'Пользователь',
|
||||
|
||||
@@ -5,7 +5,9 @@ export default {
|
||||
'common.button.editmode': '编辑模式',
|
||||
'common.button.shortcut': '快捷键',
|
||||
'common.button.add': '添加',
|
||||
'common.button.login': '登录',
|
||||
'common.button.login': 'Use a local user',
|
||||
'common.button.oidclogin': 'Login In With OIDC',
|
||||
'common.button.samllogin': 'Login In With SAML',
|
||||
'common.button.select': '选择',
|
||||
'common.button.selected': '已选择',
|
||||
'common.button.continue': '继续',
|
||||
|
||||
@@ -6,6 +6,7 @@ export default {
|
||||
'users.table.username': '用户名',
|
||||
'users.table.role': '角色',
|
||||
'users.form.fullname': '全名',
|
||||
'users.form.source': '来源',
|
||||
'users.table.user': '用户',
|
||||
'users.form.admin': '管理员',
|
||||
'users.form.user': '普通用户',
|
||||
|
||||
@@ -22,6 +22,7 @@ import { flushSync } from 'react-dom';
|
||||
import { login } from '../apis';
|
||||
import { checkDefaultPage } from '../utils';
|
||||
|
||||
const authConfig = await fetchAuthConfig('/get_config'); // get authentication configuration
|
||||
const useStyles = createStyles(({ token, css }) => ({
|
||||
header: css`
|
||||
display: flex;
|
||||
@@ -40,6 +41,17 @@ const useStyles = createStyles(({ token, css }) => ({
|
||||
}
|
||||
`
|
||||
}));
|
||||
// function authentication configuration method
|
||||
async function fetchAuthConfig(url) {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
return response.json();
|
||||
} catch (error) {
|
||||
console.error('OIDC config error:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const LoginForm = () => {
|
||||
const { styles } = useStyles();
|
||||
@@ -122,7 +134,37 @@ const LoginForm = () => {
|
||||
form.setFieldsValue({ username, password, autoLogin: true });
|
||||
}
|
||||
};
|
||||
|
||||
// OIDC certification
|
||||
const handleOidcLogin = async () => {
|
||||
const authUrl = `${authConfig.base_entrypoint}auth?response_type=code&client_id=${authConfig.CLIENT_ID}&redirect_uri=${authConfig.redirect_uri}&scope=openid profile email&state=random_state_string`;
|
||||
window.location.href = authUrl;};
|
||||
// SAML certification
|
||||
const handleSamlLogin = async () => {
|
||||
window.location.href = "/auth/saml/login";}
|
||||
// Handling certification callbacks
|
||||
useEffect(() => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const code = params.get('code'); // OIDC callback information
|
||||
console.log(code)
|
||||
const samlResponse = params.get('SAMLResponse'); // SAML callback information
|
||||
const allParams = Object.fromEntries(params.entries());
|
||||
history.replaceState({}, '', window.location.pathname);
|
||||
if (code) { login({
|
||||
code: code
|
||||
}).then(async () => {
|
||||
const userInfo = await fetchUserInfo();
|
||||
await setUserInfo(userInfo);
|
||||
gotoDefaultPage(userInfo);
|
||||
});
|
||||
};
|
||||
if (samlResponse) { login({
|
||||
SAMLResponse: decodeURIComponent(samlResponse)
|
||||
}).then(async () => {
|
||||
const userInfo = await fetchUserInfo();
|
||||
await setUserInfo(userInfo);
|
||||
gotoDefaultPage(userInfo);
|
||||
})};
|
||||
}, []);
|
||||
const handleLogin = async (values: any) => {
|
||||
try {
|
||||
await login({
|
||||
@@ -222,14 +264,28 @@ const LoginForm = () => {
|
||||
{intl.formatMessage({ id: 'common.button.forgotpassword' })}
|
||||
</Button>
|
||||
</div>
|
||||
<Button onClick={handleOidcLogin}
|
||||
type="primary"
|
||||
block
|
||||
style={{ height: '48px', fontSize: '14px', display: authConfig?.is_oidc ? 'block': 'none'}}
|
||||
>
|
||||
{intl.formatMessage({ id: 'common.button.oidclogin' })}
|
||||
</Button>
|
||||
<Button onClick={handleSamlLogin}
|
||||
type="primary"
|
||||
block
|
||||
style={{ height: '48px', fontSize: '14px', display: authConfig?.is_saml ? 'block': 'none'}}
|
||||
>
|
||||
{intl.formatMessage({ id: 'common.button.samllogin' })}
|
||||
</Button>
|
||||
<Button
|
||||
htmlType="submit"
|
||||
type="primary"
|
||||
block
|
||||
style={{ height: '48px', fontSize: '14px' }}
|
||||
>
|
||||
{intl.formatMessage({ id: 'common.button.login' })}
|
||||
</Button>
|
||||
htmlType="submit"
|
||||
type="link"
|
||||
block
|
||||
style={{ height: '48px', fontSize: '14px' }}
|
||||
>
|
||||
{intl.formatMessage({ id: 'common.button.login' })}
|
||||
</Button>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user