Browse Source

✨ 添加id4 ui

pull/10/head
王军 5 years ago
parent
commit
b1ebad5176
  1. 8
      aspnet-core/services/src/CompanyName.ProjectName.Domain/IdentityServer/IdenityServerApiResourceManager.cs
  2. 32
      aspnet-core/services/src/CompanyName.ProjectName.Domain/IdentityServer/IdenityServerClientManager.cs
  3. 7528
      aspnet-core/services/src/CompanyName.ProjectName.HttpApi.Host/Logs/logs.txt
  4. 4
      vben271/src/main.ts
  5. 6
      vben271/src/views/admin/users/EditAbpUser.vue
  6. 65
      vben271/src/views/identityServers/apiResources/EditApiResources.vue
  7. 155
      vben271/src/views/identityServers/clients/ClientUri.vue
  8. 50
      vben271/src/views/identityServers/clients/Clients.ts
  9. 34
      vben271/src/views/identityServers/clients/Clients.vue
  10. 16
      vben271/src/views/identityServers/clients/EditClientBasic.vue

8
aspnet-core/services/src/CompanyName.ProjectName.Domain/IdentityServer/IdenityServerApiResourceManager.cs

@ -127,8 +127,12 @@ namespace CompanyName.ProjectName.IdentityServer
} }
apiResource.Scopes.Clear(); apiResource.Scopes.Clear();
scopes?.Distinct().ToList().ForEach(item => { apiResource.AddScope(item); }); foreach (var item in scopes)
{
apiResource.AddScope(item);
}
return await _apiResourceRepository.UpdateAsync(apiResource, cancellationToken: cancellationToken); return await _apiResourceRepository.UpdateAsync(apiResource, cancellationToken: cancellationToken);

32
aspnet-core/services/src/CompanyName.ProjectName.Domain/IdentityServer/IdenityServerClientManager.cs

@ -163,7 +163,7 @@ namespace CompanyName.ProjectName.IdentityServer
public async Task<Client> UpdateScopesAsync(string clientId, List<string> scopes) public async Task<Client> UpdateScopesAsync(string clientId, List<string> scopes)
{ {
var client = await _clientRepository.FindByClientIdAsync(clientId); var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: "Client不存在"); if (client == null) throw new UserFriendlyException(message: $"{clientId}不存在");
client.RemoveAllScopes(); client.RemoveAllScopes();
scopes.ForEach(item => { client.AddScope(item.Trim()); }); scopes.ForEach(item => { client.AddScope(item.Trim()); });
@ -178,13 +178,15 @@ namespace CompanyName.ProjectName.IdentityServer
uri = uri.Trim(); uri = uri.Trim();
var client = await _clientRepository.FindByClientIdAsync(clientId); var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: $"{clientId}不存在"); if (client == null) throw new UserFriendlyException(message: $"{clientId}不存在");
if (client.RedirectUris.Any(e => e.RedirectUri != uri.Trim())) if (client.RedirectUris.Any(e => e.RedirectUri == uri.Trim()))
{
return client;
}
else
{ {
client.AddRedirectUri(uri); client.AddRedirectUri(uri);
return await _clientRepository.UpdateAsync(client); return await _clientRepository.UpdateAsync(client);
} }
return client;
} }
/// <summary> /// <summary>
@ -200,8 +202,10 @@ namespace CompanyName.ProjectName.IdentityServer
client.RemoveRedirectUri(uri); client.RemoveRedirectUri(uri);
return await _clientRepository.UpdateAsync(client); return await _clientRepository.UpdateAsync(client);
} }
else
return client; {
return client;
}
} }
/// <summary> /// <summary>
@ -212,13 +216,13 @@ namespace CompanyName.ProjectName.IdentityServer
uri = uri.Trim(); uri = uri.Trim();
var client = await _clientRepository.FindByClientIdAsync(clientId); var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: $"{clientId}不存在"); if (client == null) throw new UserFriendlyException(message: $"{clientId}不存在");
if (client.PostLogoutRedirectUris.Any(e => e.PostLogoutRedirectUri != uri)) if (client.PostLogoutRedirectUris.Any(e => e.PostLogoutRedirectUri == uri))
{ {
client.AddPostLogoutRedirectUri(uri); return client;
await _clientRepository.UpdateAsync(client);
} }
return client; client.AddPostLogoutRedirectUri(uri);
return await _clientRepository.UpdateAsync(client);
} }
/// <summary> /// <summary>
@ -246,13 +250,15 @@ namespace CompanyName.ProjectName.IdentityServer
origin = origin.Trim(); origin = origin.Trim();
var client = await _clientRepository.FindByClientIdAsync(clientId); var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: $"{clientId}不存在"); if (client == null) throw new UserFriendlyException(message: $"{clientId}不存在");
if (client.AllowedCorsOrigins.Any(e => e.Origin != origin)) if (client.AllowedCorsOrigins.Any(e => e.Origin == origin))
{
return client;
}
else
{ {
client.AddCorsOrigin(origin); client.AddCorsOrigin(origin);
return await _clientRepository.UpdateAsync(client); return await _clientRepository.UpdateAsync(client);
} }
return client;
} }
/// <summary> /// <summary>

7528
aspnet-core/services/src/CompanyName.ProjectName.HttpApi.Host/Logs/logs.txt

File diff suppressed because it is too large

4
vben271/src/main.ts

@ -14,7 +14,7 @@ import { setupStore } from '/@/store';
import { setupGlobDirectives } from '/@/directives'; import { setupGlobDirectives } from '/@/directives';
import { setupI18n } from '/@/locales/setupI18n'; import { setupI18n } from '/@/locales/setupI18n';
import { registerGlobComp } from '/@/components/registerGlobComp'; import { registerGlobComp } from '/@/components/registerGlobComp';
import Antd from 'ant-design-vue';
// Do not introduce on-demand in local development? // Do not introduce on-demand in local development?
// In the local development for introduce on-demand, the number of browser requests will increase by about 20%. // In the local development for introduce on-demand, the number of browser requests will increase by about 20%.
// Which may slow down the browser refresh. // Which may slow down the browser refresh.
@ -25,7 +25,7 @@ if (import.meta.env.DEV) {
async function bootstrap() { async function bootstrap() {
const app = createApp(App); const app = createApp(App);
app.use(Antd);
// Configure store // Configure store
setupStore(app); setupStore(app);

6
vben271/src/views/admin/users/EditAbpUser.vue

@ -17,12 +17,6 @@
<BasicForm @register="registerUserForm" /> <BasicForm @register="registerUserForm" />
</TabPane> </TabPane>
<TabPane tab="角色" key="2"> <TabPane tab="角色" key="2">
<!-- <a-checkbox-group @change="onRoleSelectedChange" v-model:value="defaultRolesRef">
<a-checkbox v-for="(item, index) in rolesRef" :key="index" :value="item.name">
{{ item.name }}
</a-checkbox>
</a-checkbox-group> -->
<a-checkbox-group v-model:value="defaultRolesRef"> <a-checkbox-group v-model:value="defaultRolesRef">
<a-row justify="center"> <a-row justify="center">
<a-col :span="24"> <a-col :span="24">

65
vben271/src/views/identityServers/apiResources/EditApiResources.vue

@ -13,8 +13,20 @@
<TabPane tab="基本信息" key="1"> <TabPane tab="基本信息" key="1">
<BasicForm @register="registerBasicInfoForm" /> <BasicForm @register="registerBasicInfoForm" />
</TabPane> </TabPane>
<TabPane tab="ApiScopes" key="2" forceRender> <TabPane tab="ApiScopes" key="2">
<BasicForm @register="registerApiScopeForm" /> <a-checkbox-group v-model:value="defaultApiScope">
<a-row justify="center">
<a-col :span="24">
<a-checkbox
style="width: 150px"
v-for="(item, index) in apiScopes"
:key="index"
:value="item.value"
>{{ item.label }}</a-checkbox
>
</a-col>
</a-row>
</a-checkbox-group>
</TabPane> </TabPane>
</Tabs> </Tabs>
</div> </div>
@ -22,17 +34,12 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { defineComponent, reactive, toRefs } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal'; import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index'; import { BasicForm, useForm } from '/@/components/Form/index';
import { Tabs } from 'ant-design-vue'; import { Tabs } from 'ant-design-vue';
import { import { editFormSchema, getAllApiScopeAsync, updateApiResourceAsync } from './ApiResources';
editFormSchema, import { StringStringFromSelector } from '/@/services/ServiceProxies';
editApiScopeSchema,
getAllApiScopeAsync,
updateApiResourceAsync,
} from './ApiResources';
export default defineComponent({ export default defineComponent({
name: 'EditApiResources', name: 'EditApiResources',
components: { components: {
@ -55,19 +62,16 @@
schemas: editFormSchema, schemas: editFormSchema,
showActionButtonGroup: false, showActionButtonGroup: false,
}); });
const [
registerApiScopeForm, let currentApiResuource: any;
{ let apiScopes: StringStringFromSelector[] = [];
getFieldsValue: getFieldsApiScopeValue, const state = reactive({
validate: apiScopeValidate, defaultApiScope: [],
updateSchema: updateApiScopeSchema, apiScopes,
},
] = useForm({
labelWidth: 120,
schemas: editApiScopeSchema,
showActionButtonGroup: false,
}); });
const [registerModal, { changeOkLoading, closeModal }] = useModalInner(async (data) => { const [registerModal, { changeOkLoading, closeModal }] = useModalInner(async (data) => {
currentApiResuource = data;
setBasicInfoFieldsValue({ setBasicInfoFieldsValue({
name: data.record.name, name: data.record.name,
displayName: data.record.displayName, displayName: data.record.displayName,
@ -77,32 +81,23 @@
showInDiscoveryDocument: data.record.showInDiscoveryDocument, showInDiscoveryDocument: data.record.showInDiscoveryDocument,
}); });
let apiScopes = await getAllApiScopeAsync(); state.apiScopes = await getAllApiScopeAsync();
const defaultApiScopes = data.record.scopes.map((e) => e.scope); state.defaultApiScope = data.record.scopes.map((e) => e.scope);
console.log(defaultApiScopes);
updateApiScopeSchema([
{
field: 'apiScopes',
defaultValue: defaultApiScopes,
componentProps: { options: apiScopes },
},
]);
}); });
const submit = async () => { const submit = async () => {
await basicInfoValidate(); await basicInfoValidate();
await apiScopeValidate();
var basicInfo = getFieldsBasicInfoValue(); var basicInfo = getFieldsBasicInfoValue();
var apiScope = getFieldsApiScopeValue(); let requestScope = { apiScopes: state.defaultApiScope };
var request = Object.assign(basicInfo, apiScope); var request = Object.assign(basicInfo, requestScope);
await updateApiResourceAsync({ request, changeOkLoading, closeModal }); await updateApiResourceAsync({ request, changeOkLoading, closeModal });
emit('reload'); emit('reload');
}; };
return { return {
registerModal, registerModal,
registerBasicInfoForm, registerBasicInfoForm,
registerApiScopeForm,
submit, submit,
...toRefs(state),
}; };
}, },
}); });

155
vben271/src/views/identityServers/clients/ClientUri.vue

@ -0,0 +1,155 @@
<template>
<BasicDrawer v-bind="$attrs" @register="register" title="Uri" width="30%">
<Tabs>
<TabPane tab="RedirectUri" key="1">
<a-input
placeholder="Please Enter Uri"
style="width: 470px"
v-model:value="redirectUriValue"
/>
<a-button type="primary" @click="handleAddRedirectUri" style="margin-bottom: 10px"
>新增</a-button
>
<div v-for="item in currentClient.redirectUris">
<a-input placeholder="" style="width: 470px" :defaultValue="item.redirectUri" disabled />
<a-button type="primary" @click="handleRemoveRedirectUri(item.redirectUri)" danger
>删除</a-button
>
</div>
</TabPane>
<TabPane tab="LogoutRedirectUri" key="2" forceRender>
<a-input
placeholder="Please Enter Uri"
style="width: 470px"
v-model:value="postLogoutRedirectUriValue"
/>
<a-button type="primary" @click="handleAddLogoutRedirectUri" style="margin-bottom: 10px"
>新增</a-button
>
<div v-for="item in currentClient.postLogoutRedirectUris">
<a-input
placeholder=""
style="width: 470px"
:defaultValue="item.postLogoutRedirectUri"
disabled
/>
<a-button
type="primary"
@click="handleRemoveLogoutRedirectUri(item.postLogoutRedirectUris)"
danger
>删除</a-button
>
</div>
</TabPane>
<TabPane tab="CORS" key="3" forceRender>
<a-input placeholder="Please Enter Uri" style="width: 470px" v-model:value="originValue" />
<a-button type="primary" @click="handleAddCors" style="margin-bottom: 10px">新增</a-button>
<div v-for="item in currentClient.allowedCorsOrigins">
<a-input placeholder="" style="width: 470px" :defaultValue="item.origin" disabled />
<a-button type="primary" @click="handleRemoveCors(item.origin)" danger>删除</a-button>
</div>
</TabPane>
</Tabs>
</BasicDrawer>
</template>
<script lang="ts">
import { defineComponent, reactive, toRefs } from 'vue';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { Tabs } from 'ant-design-vue';
import {
addRedirectUriAsync,
removeRedirectUriAsync,
addLogoutRedirectUriAsync,
removeLogoutRedirectUriAsync,
addCorsAsync,
removeCorsAsync,
} from './Clients';
import { PagingClientListOutput } from '/@/services/ServiceProxies';
export default defineComponent({
name: 'ClientUri',
components: { BasicDrawer, Tabs, TabPane: Tabs.TabPane },
emits: ['reload'],
setup(_, { emit }) {
let currentClient: PagingClientListOutput = new PagingClientListOutput();
const state = reactive({
redirectUriValue: '',
postLogoutRedirectUriValue: '',
originValue: '',
currentClient,
});
const [register, { closeDrawer }] = useDrawerInner((data) => {
state.currentClient = data.record;
console.log(state);
});
const handleAddRedirectUri = async () => {
if (state.redirectUriValue) {
await addRedirectUriAsync({
clientId: state.currentClient.clientId,
uri: state.redirectUriValue,
});
closeDrawer();
emit('reload');
}
};
const handleRemoveRedirectUri = async (redirectUri: string) => {
await removeRedirectUriAsync({
clientId: state.currentClient.clientId,
uri: redirectUri,
});
closeDrawer();
emit('reload');
};
const handleAddLogoutRedirectUri = async () => {
await addLogoutRedirectUriAsync({
clientId: state.currentClient.clientId,
uri: state.postLogoutRedirectUriValue,
});
closeDrawer();
emit('reload');
};
const handleRemoveLogoutRedirectUri = async (redirectUri: string) => {
await removeLogoutRedirectUriAsync({
clientId: state.currentClient.clientId,
uri: redirectUri,
});
closeDrawer();
emit('reload');
};
const handleAddCors = async () => {
await addCorsAsync({
clientId: state.currentClient.clientId,
origin: state.originValue,
});
closeDrawer();
emit('reload');
};
const handleRemoveCors = async (origin: string) => {
await removeCorsAsync({
clientId: state.currentClient.clientId,
origin: origin,
});
closeDrawer();
emit('reload');
};
return {
register,
handleAddRedirectUri,
handleRemoveRedirectUri,
handleAddLogoutRedirectUri,
handleRemoveLogoutRedirectUri,
handleAddCors,
handleRemoveCors,
...toRefs(state),
};
},
});
</script>

50
vben271/src/views/identityServers/clients/Clients.ts

@ -8,6 +8,10 @@ import {
EnabledInput, EnabledInput,
IdInput, IdInput,
PagingClientListInput, PagingClientListInput,
AddRedirectUriInput,
RemoveRedirectUriInput,
AddCorsInput,
RemoveCorsInput,
} from '/@/services/ServiceProxies'; } from '/@/services/ServiceProxies';
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
@ -345,3 +349,49 @@ export async function enabledClientAsync({ clientId, enabled, reload }) {
await _clientServiceProxy.enabled(request); await _clientServiceProxy.enabled(request);
reload(); reload();
} }
export async function addRedirectUriAsync({ clientId, uri }) {
const _clientServiceProxy = new ClientServiceProxy();
let request = new AddRedirectUriInput();
request.clientId = clientId;
request.uri = uri;
return await _clientServiceProxy.addRedirectUri(request);
}
export async function removeRedirectUriAsync({ clientId, uri }) {
const _clientServiceProxy = new ClientServiceProxy();
let request = new RemoveRedirectUriInput();
request.clientId = clientId;
request.uri = uri;
return await _clientServiceProxy.removeRedirectUri(request);
}
export async function addLogoutRedirectUriAsync({ clientId, uri }) {
const _clientServiceProxy = new ClientServiceProxy();
let request = new RemoveRedirectUriInput();
request.clientId = clientId;
request.uri = uri;
return await _clientServiceProxy.addLogoutRedirectUri(request);
}
export async function removeLogoutRedirectUriAsync({ clientId, uri }) {
const _clientServiceProxy = new ClientServiceProxy();
let request = new RemoveRedirectUriInput();
request.clientId = clientId;
request.uri = uri;
return await _clientServiceProxy.removeLogoutRedirectUri(request);
}
export async function addCorsAsync({ clientId, origin }) {
const _clientServiceProxy = new ClientServiceProxy();
let request = new AddCorsInput();
request.clientId = clientId;
request.origin = origin;
return await _clientServiceProxy.addCors(request);
}
export async function removeCorsAsync({ clientId, origin }) {
const _clientServiceProxy = new ClientServiceProxy();
let request = new RemoveCorsInput();
request.clientId = clientId;
request.origin = origin;
return await _clientServiceProxy.removeCors(request);
}

34
vben271/src/views/identityServers/clients/Clients.vue

@ -20,26 +20,45 @@
<a-button type="link" size="small" @click="handleEnabled(record)"> <a-button type="link" size="small" @click="handleEnabled(record)">
{{ record.enabled ? '禁用' : '启用' }} {{ record.enabled ? '禁用' : '启用' }}
</a-button> </a-button>
<a-button type="link" size="small" @click="handleUri(record)"> Uri </a-button>
<a-button type="link" size="small" @click="handleDelete(record)"> <a-button type="link" size="small" @click="handleDelete(record)">
{{ t('common.delText') }} {{ t('common.delText') }}
</a-button> </a-button>
</template> </template>
</BasicTable> </BasicTable>
<CreateClient @register="registerCreateClientModal" @reload="reload" :bodyStyle="{ 'padding-top': '0' }" /> <CreateClient
<EditClientBasic @register="registerEditClientModal" @reload="reload" :bodyStyle="{ 'padding-top': '0' }" /> @register="registerCreateClientModal"
@reload="reload"
:bodyStyle="{ 'padding-top': '0' }"
/>
<EditClientBasic
@register="registerEditClientModal"
@reload="reload"
:bodyStyle="{ 'padding-top': '0' }"
/>
<ClientUri @register="registerUriDrawer" @reload="reload" :bodyStyle="{ 'padding-top': '0' }" />
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table'; import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { tableColumns, searchFormSchema, getTableListAsync, deleteClientAsync, enabledClientAsync } from './Clients'; import {
tableColumns,
searchFormSchema,
getTableListAsync,
deleteClientAsync,
enabledClientAsync,
} from './Clients';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { Tag } from 'ant-design-vue'; import { Tag } from 'ant-design-vue';
import CreateClient from './CreateClient.vue'; import CreateClient from './CreateClient.vue';
import EditClientBasic from './EditClientBasic.vue'; import EditClientBasic from './EditClientBasic.vue';
import ClientUri from './ClientUri.vue';
import { useModal } from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import { useDrawer } from '/@/components/Drawer';
export default defineComponent({ export default defineComponent({
name: 'Clients', name: 'Clients',
components: { components: {
@ -48,6 +67,7 @@
Tag, Tag,
CreateClient, CreateClient,
EditClientBasic, EditClientBasic,
ClientUri,
}, },
setup() { setup() {
const { t } = useI18n(); const { t } = useI18n();
@ -66,7 +86,7 @@
canResize: true, canResize: true,
showIndexColumn: true, showIndexColumn: true,
actionColumn: { actionColumn: {
width: 150, width: 300,
title: t('common.action'), title: t('common.action'),
dataIndex: 'action', dataIndex: 'action',
slots: { slots: {
@ -97,6 +117,10 @@
const handleEnabled = async (record: Recordable) => { const handleEnabled = async (record: Recordable) => {
await enabledClientAsync({ clientId: record.clientId, enabled: !record.enabled, reload }); await enabledClientAsync({ clientId: record.clientId, enabled: !record.enabled, reload });
}; };
const [registerUriDrawer, { openDrawer: openUriDrawer }] = useDrawer();
const handleUri = async (record: Recordable) => {
openUriDrawer(true, { record: record });
};
return { return {
registerTable, registerTable,
registerCreateClientModal, registerCreateClientModal,
@ -108,6 +132,8 @@
handleEdit, handleEdit,
handleDelete, handleDelete,
handleEnabled, handleEnabled,
handleUri,
registerUriDrawer,
}; };
}, },
}); });

16
vben271/src/views/identityServers/clients/EditClientBasic.vue

@ -50,9 +50,6 @@
}, },
emits: ['reload'], emits: ['reload'],
setup(_, { emit }) { setup(_, { emit }) {
// 加载父组件方法
// defineEmit(['reload']);
const [ const [
registerDetailForm, registerDetailForm,
{ {
@ -146,19 +143,6 @@
} }
}); });
// const visibleChange = async (visible: boolean) => {
// if (visible) {
// detailValidate();
// optionValidate();
// tokenValidate();
// secretValidate();
// getFieldsTokenValue();
// getFieldsSecretValue();
// getFieldsOptionValue();
// getFieldsDetailValue();
// }
// };
const submit = async () => { const submit = async () => {
await detailValidate(); await detailValidate();
await optionValidate(); await optionValidate();

Loading…
Cancel
Save