diff --git a/AgileConfig.Server.Apisite/Controllers/AdminController.cs b/AgileConfig.Server.Apisite/Controllers/AdminController.cs index c4f65dda..7d3b1f32 100644 --- a/AgileConfig.Server.Apisite/Controllers/AdminController.cs +++ b/AgileConfig.Server.Apisite/Controllers/AdminController.cs @@ -127,7 +127,8 @@ public async Task OidcLoginByCode(string code) Password = "/", CreateTime = DateTime.Now, Status = UserStatus.Normal, - Salt = "" + Salt = "", + Source = UserSource.SSO }; await _userService.AddAsync(newUser); } diff --git a/AgileConfig.Server.Apisite/Controllers/HomeController.cs b/AgileConfig.Server.Apisite/Controllers/HomeController.cs index 693986d3..64883ed6 100644 --- a/AgileConfig.Server.Apisite/Controllers/HomeController.cs +++ b/AgileConfig.Server.Apisite/Controllers/HomeController.cs @@ -83,6 +83,9 @@ public async Task Sys() return Json(new { appVer, + passwordInited = await _settingService.HasSuperAdmin(), + ssoEnabled = Appsettings.SsoEnabled, + ssoButtonText = Appsettings.SsoButtonText }); } diff --git a/AgileConfig.Server.Apisite/appsettings.Development.json b/AgileConfig.Server.Apisite/appsettings.Development.json index b1c8fac7..a62e05af 100644 --- a/AgileConfig.Server.Apisite/appsettings.Development.json +++ b/AgileConfig.Server.Apisite/appsettings.Development.json @@ -41,7 +41,7 @@ "ExpireSeconds": 86400 // 过期时间 }, "SSO": { - "enabled": true, + "enabled": false, "loginButtonText": "SSO", "OIDC": { "clientId": "2bb823b7-f1ad-48c7-a9a1-713e9a885a5d", diff --git a/AgileConfig.Server.Apisite/appsettings.json b/AgileConfig.Server.Apisite/appsettings.json index 7efaf739..43878fa2 100644 --- a/AgileConfig.Server.Apisite/appsettings.json +++ b/AgileConfig.Server.Apisite/appsettings.json @@ -42,8 +42,8 @@ "ExpireSeconds": 86400 // 过期时间 }, "SSO": { - "enabled": true, - "loginButtonText": "SSO", + "enabled": false, + "loginButtonText": "", "OIDC": { "clientId": "", "clientSecret": "", diff --git a/AgileConfig.Server.Data.Entity/User.cs b/AgileConfig.Server.Data.Entity/User.cs index b2be07f8..fa4e94aa 100644 --- a/AgileConfig.Server.Data.Entity/User.cs +++ b/AgileConfig.Server.Data.Entity/User.cs @@ -1,5 +1,6 @@ using FreeSql.DataAnnotations; using System; +using System.Diagnostics; namespace AgileConfig.Server.Data.Entity { @@ -7,7 +8,7 @@ namespace AgileConfig.Server.Data.Entity [OraclePrimaryKeyName("agc_user_pk")] public class User { - [Column(Name = "id", StringLength = 36)] + [Column(Name = "id", StringLength = 50)] public string Id { get; set; } [Column(Name= "user_name" , StringLength = 50)] @@ -30,6 +31,9 @@ public class User [Column(Name = "status")] public UserStatus Status { get; set; } + + [Column(Name = "source")] + public UserSource Source { get; set; } } public enum UserStatus @@ -37,4 +41,10 @@ public enum UserStatus Normal = 0, Deleted = -1 } + + public enum UserSource + { + Normal = 0, + SSO = 1 + } } diff --git a/AgileConfig.Server.UI/react-ui-antd/package.json b/AgileConfig.Server.UI/react-ui-antd/package.json index 05c5986c..70b1c3e0 100644 --- a/AgileConfig.Server.UI/react-ui-antd/package.json +++ b/AgileConfig.Server.UI/react-ui-antd/package.json @@ -6,6 +6,7 @@ "scripts": { "analyze": "cross-env ANALYZE=1 umi build", "build": "umi build", + "build:ssl-legacy": "set NODE_OPTIONS=--openssl-legacy-provider && umi build", "deploy": "npm run site && npm run gh-pages", "dev": "npm run start:dev", "fetch:blocks": "pro fetch-blocks && npm run prettier", @@ -20,7 +21,8 @@ "lint:style": "stylelint --fix \"src/**/*.less\" --syntax less", "precommit": "lint-staged", "prettier": "prettier -c --write \"src/**/*\"", - "start": "set NODE_OPTIONS=--openssl-legacy-provider && cross-env UMI_ENV=dev umi dev", + "start": "cross-env UMI_ENV=dev umi dev", + "start:ssl-legacy": "set NODE_OPTIONS=--openssl-legacy-provider && npm run start", "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev umi dev", "start:no-mock": "cross-env MOCK=none UMI_ENV=dev umi dev", "start:no-ui": "cross-env UMI_UI=none UMI_ENV=dev umi dev", diff --git a/AgileConfig.Server.UI/react-ui-antd/src/models/user.ts b/AgileConfig.Server.UI/react-ui-antd/src/models/user.ts index 27ec78ec..83a2d223 100644 --- a/AgileConfig.Server.UI/react-ui-antd/src/models/user.ts +++ b/AgileConfig.Server.UI/react-ui-antd/src/models/user.ts @@ -31,7 +31,7 @@ export type UserModelType = { fetchCurrent: Effect; }; reducers: { - saveCurrentUser: Reducer; + saveCurrentSystemInfo: Reducer; changeNotifyCount: Reducer; }; }; @@ -66,14 +66,14 @@ const UserModel: UserModelType = { currentFunctions: currentInfo.currentUser?.currentFunctions }; yield put({ - type: 'saveCurrentUser', + type: 'saveCurrentSystemInfo', payload: response, }); }, }, reducers: { - saveCurrentUser(state, action) { + saveCurrentSystemInfo(state, action) { setAuthority(action.payload.currentAuthority); setFunctions(action.payload.currentFunctions); setUserInfo({name:action.payload.name, userid: action.payload.userid}); diff --git a/AgileConfig.Server.UI/react-ui-antd/src/pages/OIDC/index.tsx b/AgileConfig.Server.UI/react-ui-antd/src/pages/OIDC/index.tsx index 3ed6b53c..317a1a25 100644 --- a/AgileConfig.Server.UI/react-ui-antd/src/pages/OIDC/index.tsx +++ b/AgileConfig.Server.UI/react-ui-antd/src/pages/OIDC/index.tsx @@ -1,4 +1,5 @@ import { PageContainer } from '@ant-design/pro-layout'; +import React, { useEffect, useState } from 'react'; import { Spin } from 'antd'; import styles from './index.less'; import { oidcLogin } from '@/services/login'; @@ -20,7 +21,10 @@ const logs:React.FC = (props: any) => { id: 'pages.login.loginsuccess' }); message.success(msg); - loginModel.reducers.changeLoginStatus({}, {payload: response}); + loginModel.reducers.changeLoginStatus({}, { + payload: response, + type: 'changeLoginStatus' + }); history.replace('/'); } else { diff --git a/AgileConfig.Server.UI/react-ui-antd/src/pages/OIDC/service.ts b/AgileConfig.Server.UI/react-ui-antd/src/pages/OIDC/service.ts index ad91bc7d..e69de29b 100644 --- a/AgileConfig.Server.UI/react-ui-antd/src/pages/OIDC/service.ts +++ b/AgileConfig.Server.UI/react-ui-antd/src/pages/OIDC/service.ts @@ -1,10 +0,0 @@ -import request from '@/utils/request'; -import { LogListParams } from './data'; - -export async function queryLogs(params?: LogListParams) { - console.log(params); - return request('syslog/search', { - params, - }); -} - diff --git a/AgileConfig.Server.UI/react-ui-antd/src/pages/User/login/index.tsx b/AgileConfig.Server.UI/react-ui-antd/src/pages/User/login/index.tsx index eeef1007..2ded96e4 100644 --- a/AgileConfig.Server.UI/react-ui-antd/src/pages/User/login/index.tsx +++ b/AgileConfig.Server.UI/react-ui-antd/src/pages/User/login/index.tsx @@ -10,7 +10,6 @@ import { history } from 'umi'; import type { StateType } from '@/models/login'; import type { LoginParamsType } from '@/services/login'; import type { ConnectState } from '@/models/connect'; -import { PasswordInited } from './service' import styles from './index.less'; import { Button } from 'antd'; @@ -19,17 +18,25 @@ export type LoginProps = { userLogin: StateType; submitting?: boolean; }; +import { sys } from '@/services/system'; const Login: React.FC = (props) => { - const { userLogin = {}, submitting } = props; - const [type, setType] = useState('account'); + const { submitting } = props; + const [type] = useState('account'); + const [ssoEnabled, setSsoEnabled] = useState(false); + const [ssoLoginButtonText, setSsoLoginButtonText] = useState('SSO Login'); const intl = useIntl(); useEffect(()=>{ - PasswordInited().then(resp=> { - if (!resp.data) { + sys().then(resp=> { + console.log(resp); + if (!resp.passwordInited) { history.replace('/user/initpassword'); } + setSsoEnabled(resp.ssoEnabled); + if(resp.ssoButtonText) { + setSsoLoginButtonText(resp.ssoButtonText); + } }) },[]) @@ -127,7 +134,7 @@ const Login: React.FC = (props) => { > - + ); }; diff --git a/AgileConfig.Server.UI/react-ui-antd/src/services/login.ts b/AgileConfig.Server.UI/react-ui-antd/src/services/login.ts index 96a2fddc..39427aa8 100644 --- a/AgileConfig.Server.UI/react-ui-antd/src/services/login.ts +++ b/AgileConfig.Server.UI/react-ui-antd/src/services/login.ts @@ -15,7 +15,7 @@ export async function accountLogin(params: LoginParamsType) { } export async function oidcLogin(code: string) { - return request('admin/oidc', { + return request('admin/oidc/login', { method: 'GET', params: { code: code