Move access
property to React Router's handle
(#19320)
This commit is contained in:
parent
251f6151e8
commit
0fb9b9becd
77 changed files with 237 additions and 83 deletions
|
@ -62,14 +62,14 @@ type SecuredRouteProps = { route: RouteDef };
|
|||
const SecuredRoute = ({ route }: SecuredRouteProps) => {
|
||||
const { hasAccess } = useAccess();
|
||||
const accessAllowed =
|
||||
route.access instanceof Array
|
||||
? hasAccess(...route.access)
|
||||
: hasAccess(route.access);
|
||||
route.handle.access instanceof Array
|
||||
? hasAccess(...route.handle.access)
|
||||
: hasAccess(route.handle.access);
|
||||
|
||||
if (accessAllowed)
|
||||
return <Suspense fallback={<KeycloakSpinner />}>{route.element}</Suspense>;
|
||||
|
||||
return <ForbiddenSection permissionNeeded={route.access} />;
|
||||
return <ForbiddenSection permissionNeeded={route.handle.access} />;
|
||||
};
|
||||
|
||||
export const App = ({ keycloak, adminClient }: AdminClientProps) => {
|
||||
|
|
|
@ -30,9 +30,9 @@ const LeftNav = ({ title, path }: LeftNavProps) => {
|
|||
|
||||
const accessAllowed =
|
||||
route &&
|
||||
(route.access instanceof Array
|
||||
? hasAccess(...route.access)
|
||||
: hasAccess(route.access));
|
||||
(route.handle.access instanceof Array
|
||||
? hasAccess(...route.handle.access)
|
||||
: hasAccess(route.handle.access));
|
||||
|
||||
if (!accessAllowed) {
|
||||
return null;
|
||||
|
|
|
@ -13,7 +13,9 @@ export const AuthenticationRoute: RouteDef = {
|
|||
path: "/:realm/authentication",
|
||||
element: <AuthenticationSection />,
|
||||
breadcrumb: (t) => t("authentication"),
|
||||
access: ["view-realm", "view-identity-providers", "view-clients"],
|
||||
handle: {
|
||||
access: ["view-realm", "view-identity-providers", "view-clients"],
|
||||
},
|
||||
};
|
||||
|
||||
export const AuthenticationRouteWithTab: RouteDef = {
|
||||
|
|
|
@ -11,7 +11,9 @@ export const CreateFlowRoute: RouteDef = {
|
|||
path: "/:realm/authentication/flows/create",
|
||||
element: <CreateFlow />,
|
||||
breadcrumb: (t) => t("authentication:createFlow"),
|
||||
access: "manage-authorization",
|
||||
handle: {
|
||||
access: "manage-authorization",
|
||||
},
|
||||
};
|
||||
|
||||
export const toCreateFlow = (params: CreateFlowParams): Partial<Path> => ({
|
||||
|
|
|
@ -16,7 +16,9 @@ export const FlowRoute: RouteDef = {
|
|||
path: "/:realm/authentication/:id/:usedBy",
|
||||
element: <FlowDetails />,
|
||||
breadcrumb: (t) => t("authentication:flowDetails"),
|
||||
access: "view-authorization",
|
||||
handle: {
|
||||
access: "view-authorization",
|
||||
},
|
||||
};
|
||||
|
||||
export const FlowWithBuiltInRoute: RouteDef = {
|
||||
|
|
|
@ -17,7 +17,9 @@ export const ClientScopeRoute: RouteDef = {
|
|||
path: "/:realm/client-scopes/:id/:tab",
|
||||
element: <EditClientScope />,
|
||||
breadcrumb: (t) => t("client-scopes:clientScopeDetails"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toClientScope = (params: ClientScopeParams): Partial<Path> => {
|
||||
|
|
|
@ -11,7 +11,9 @@ export const ClientScopesRoute: RouteDef = {
|
|||
path: "/:realm/client-scopes",
|
||||
element: <ClientScopesSection />,
|
||||
breadcrumb: (t) => t("client-scopes:clientScopeList"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toClientScopes = (params: ClientScopesParams): Partial<Path> => ({
|
||||
|
|
|
@ -15,7 +15,9 @@ export const MapperRoute: RouteDef = {
|
|||
path: "/:realm/client-scopes/:id/mappers/:mapperId",
|
||||
element: <MappingDetails />,
|
||||
breadcrumb: (t) => t("common:mappingDetails"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toMapper = (params: MapperParams): Partial<Path> => ({
|
||||
|
|
|
@ -11,7 +11,9 @@ export const NewClientScopeRoute: RouteDef = {
|
|||
path: "/:realm/client-scopes/new",
|
||||
element: <CreateClientScope />,
|
||||
breadcrumb: (t) => t("client-scopes:createClientScope"),
|
||||
access: "manage-clients",
|
||||
handle: {
|
||||
access: "manage-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toNewClientScope = (
|
||||
|
|
|
@ -11,7 +11,9 @@ export const AddClientRoute: RouteDef = {
|
|||
path: "/:realm/clients/add-client",
|
||||
element: <NewClientForm />,
|
||||
breadcrumb: (t) => t("clients:createClient"),
|
||||
access: "manage-clients",
|
||||
handle: {
|
||||
access: "manage-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toAddClient = (params: AddClientParams): Partial<Path> => ({
|
||||
|
|
|
@ -17,7 +17,9 @@ export const AddRegistrationProviderRoute: RouteDef = {
|
|||
path: "/:realm/clients/client-registration/:subTab/:providerId",
|
||||
element: <DetailProvider />,
|
||||
breadcrumb: (t) => t("clients:clientSettings"),
|
||||
access: "manage-clients",
|
||||
handle: {
|
||||
access: "manage-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const EditRegistrationProviderRoute: RouteDef = {
|
||||
|
|
|
@ -24,7 +24,9 @@ export const AuthorizationRoute: RouteDef = {
|
|||
path: "/:realm/clients/:clientId/authorization/:tab",
|
||||
element: <ClientDetails />,
|
||||
breadcrumb: (t) => t("clients:clientSettings"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toAuthorizationTab = (
|
||||
|
|
|
@ -28,7 +28,9 @@ export const ClientRoute: RouteDef = {
|
|||
path: "/:realm/clients/:clientId/:tab",
|
||||
element: <ClientDetails />,
|
||||
breadcrumb: (t) => t("clients:clientSettings"),
|
||||
access: "query-clients",
|
||||
handle: {
|
||||
access: "query-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toClient = (params: ClientParams): Partial<Path> => ({
|
||||
|
|
|
@ -16,7 +16,9 @@ export const ClientRegistrationRoute: RouteDef = {
|
|||
path: "/:realm/clients/client-registration/:subTab",
|
||||
element: <ClientsSection />,
|
||||
breadcrumb: (t) => t("clients:clientRegistration"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toClientRegistration = (
|
||||
|
|
|
@ -22,7 +22,9 @@ export const ClientRoleRoute: RouteDef = {
|
|||
path: "/:realm/clients/:clientId/roles/:id/:tab" as const,
|
||||
element: <RealmRoleTabs />,
|
||||
breadcrumb: (t) => t("roles:roleDetails"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
} satisfies RouteDef;
|
||||
|
||||
export const toClientRole = (params: ClientRoleParams): Partial<Path> => ({
|
||||
|
|
|
@ -17,7 +17,9 @@ export const ClientScopesRoute: RouteDef = {
|
|||
path: "/:realm/clients/:clientId/clientScopes/:tab",
|
||||
element: <ClientDetails />,
|
||||
breadcrumb: (t) => t("clients:clientSettings"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toClientScopesTab = (
|
||||
|
|
|
@ -19,7 +19,9 @@ export const ClientsRoute: RouteDef = {
|
|||
path: "/:realm/clients",
|
||||
element: <ClientsSection />,
|
||||
breadcrumb: (t) => t("clients:clientList"),
|
||||
access: "query-clients",
|
||||
handle: {
|
||||
access: "query-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const ClientsRouteWithTab: RouteDef = {
|
||||
|
|
|
@ -13,7 +13,9 @@ export const CreateInitialAccessTokenRoute: RouteDef = {
|
|||
path: "/:realm/clients/initialAccessToken/create",
|
||||
element: <CreateInitialAccessToken />,
|
||||
breadcrumb: (t) => t("clients:createToken"),
|
||||
access: "manage-clients",
|
||||
handle: {
|
||||
access: "manage-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toCreateInitialAccessToken = (
|
||||
|
|
|
@ -17,7 +17,9 @@ export const DedicatedScopeDetailsRoute: RouteDef = {
|
|||
path: "/:realm/clients/:clientId/clientScopes/dedicated",
|
||||
element: <DedicatedScopes />,
|
||||
breadcrumb: (t) => t("clients:dedicatedScopes"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const DedicatedScopeDetailsWithTabRoute: RouteDef = {
|
||||
|
|
|
@ -11,7 +11,9 @@ export const ImportClientRoute: RouteDef = {
|
|||
path: "/:realm/clients/import-client",
|
||||
element: <ImportForm />,
|
||||
breadcrumb: (t) => t("clients:importClient"),
|
||||
access: "manage-clients",
|
||||
handle: {
|
||||
access: "manage-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toImportClient = (params: ImportClientParams): Partial<Path> => ({
|
||||
|
|
|
@ -17,7 +17,9 @@ export const MapperRoute: RouteDef = {
|
|||
path: "/:realm/clients/:id/clientScopes/dedicated/mappers/:mapperId",
|
||||
element: <MappingDetails />,
|
||||
breadcrumb: (t) => t("common:mappingDetails"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toMapper = (params: MapperParams): Partial<Path> => ({
|
||||
|
|
|
@ -20,7 +20,9 @@ export const NewPermissionRoute: RouteDef = {
|
|||
path: "/:realm/clients/:id/authorization/permission/new/:permissionType",
|
||||
element: <PermissionDetails />,
|
||||
breadcrumb: (t) => t("clients:createPermission"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const NewPermissionWithSelectedIdRoute: RouteDef = {
|
||||
|
|
|
@ -13,7 +13,9 @@ export const NewPolicyRoute: RouteDef = {
|
|||
path: "/:realm/clients/:id/authorization/policy/new/:policyType",
|
||||
element: <PolicyDetails />,
|
||||
breadcrumb: (t) => t("clients:createPolicy"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toCreatePolicy = (params: NewPolicyParams): Partial<Path> => ({
|
||||
|
|
|
@ -11,7 +11,9 @@ export const NewResourceRoute: RouteDef = {
|
|||
path: "/:realm/clients/:id/authorization/resource/new",
|
||||
element: <ResourceDetails />,
|
||||
breadcrumb: (t) => t("clients:createResource"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toCreateResource = (params: NewResourceParams): Partial<Path> => ({
|
||||
|
|
|
@ -11,7 +11,9 @@ export const NewRoleRoute: RouteDef = {
|
|||
path: "/:realm/clients/:clientId/roles/new",
|
||||
element: <CreateClientRole />,
|
||||
breadcrumb: (t) => t("roles:createRole"),
|
||||
access: "manage-clients",
|
||||
handle: {
|
||||
access: "manage-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toCreateRole = (params: NewRoleParams): Partial<Path> => ({
|
||||
|
|
|
@ -11,7 +11,9 @@ export const NewScopeRoute: RouteDef = {
|
|||
path: "/:realm/clients/:id/authorization/scope/new",
|
||||
element: <ScopeDetails />,
|
||||
breadcrumb: (t) => t("clients:createAuthorizationScope"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toNewScope = (params: NewScopeParams): Partial<Path> => ({
|
||||
|
|
|
@ -19,7 +19,9 @@ export const PermissionDetailsRoute: RouteDef = {
|
|||
path: "/:realm/clients/:id/authorization/permission/:permissionType/:permissionId",
|
||||
element: <PermissionDetails />,
|
||||
breadcrumb: (t) => t("clients:permissionDetails"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toPermissionDetails = (
|
||||
|
|
|
@ -18,7 +18,9 @@ export const PolicyDetailsRoute: RouteDef = {
|
|||
path: "/:realm/clients/:id/authorization/policy/:policyId/:policyType",
|
||||
element: <PolicyDetails />,
|
||||
breadcrumb: (t) => t("clients:createPolicy"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toPolicyDetails = (
|
||||
|
|
|
@ -15,7 +15,9 @@ export const ResourceDetailsRoute: RouteDef = {
|
|||
path: "/:realm/clients/:id/authorization/resource",
|
||||
element: <ResourceDetails />,
|
||||
breadcrumb: (t) => t("clients:createResource"),
|
||||
access: "view-clients",
|
||||
handle: {
|
||||
access: "view-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const ResourceDetailsWithResourceIdRoute: RouteDef = {
|
||||
|
|
|
@ -15,7 +15,9 @@ export const ScopeDetailsRoute: RouteDef = {
|
|||
path: "/:realm/clients/:id/authorization/scope",
|
||||
element: <ScopeDetails />,
|
||||
breadcrumb: (t) => t("clients:createAuthorizationScope"),
|
||||
access: "manage-clients",
|
||||
handle: {
|
||||
access: "manage-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const ScopeDetailsWithScopeIdRoute: RouteDef = {
|
||||
|
|
|
@ -13,7 +13,9 @@ export const DashboardRoute: RouteDef = {
|
|||
path: "/",
|
||||
element: <Dashboard />,
|
||||
breadcrumb: (t) => t("common:home"),
|
||||
access: "anyone",
|
||||
handle: {
|
||||
access: "anyone",
|
||||
},
|
||||
};
|
||||
|
||||
export const DashboardRouteWithRealm: RouteDef = {
|
||||
|
|
|
@ -16,7 +16,9 @@ export const EventsRoute: RouteDef = {
|
|||
path: "/:realm/events",
|
||||
element: <EventsSection />,
|
||||
breadcrumb: (t) => t("events:title"),
|
||||
access: "view-events",
|
||||
handle: {
|
||||
access: "view-events",
|
||||
},
|
||||
};
|
||||
|
||||
export const EventsRouteWithTab: RouteDef = {
|
||||
|
|
|
@ -10,7 +10,9 @@ const GroupsSection = lazy(() => import("../GroupsSection"));
|
|||
export const GroupsRoute: RouteDef = {
|
||||
path: "/:realm/groups/*",
|
||||
element: <GroupsSection />,
|
||||
access: "query-groups",
|
||||
handle: {
|
||||
access: "query-groups",
|
||||
},
|
||||
};
|
||||
|
||||
export const GroupsWithIdRoute: RouteDef = {
|
||||
|
|
|
@ -15,8 +15,10 @@ const AddMapper = lazy(() => import("../add/AddMapper"));
|
|||
export const IdentityProviderAddMapperRoute: RouteDef = {
|
||||
path: "/:realm/identity-providers/:providerId/:alias/:tab/create",
|
||||
element: <AddMapper />,
|
||||
access: "manage-identity-providers",
|
||||
breadcrumb: (t) => t("identity-providers:addIdPMapper"),
|
||||
handle: {
|
||||
access: "manage-identity-providers",
|
||||
},
|
||||
};
|
||||
|
||||
export const toIdentityProviderAddMapper = (
|
||||
|
|
|
@ -15,8 +15,10 @@ const AddMapper = lazy(() => import("../add/AddMapper"));
|
|||
export const IdentityProviderEditMapperRoute: RouteDef = {
|
||||
path: "/:realm/identity-providers/:providerId/:alias/mappers/:id",
|
||||
element: <AddMapper />,
|
||||
access: "manage-identity-providers",
|
||||
breadcrumb: (t) => t("identity-providers:editIdPMapper"),
|
||||
handle: {
|
||||
access: "manage-identity-providers",
|
||||
},
|
||||
};
|
||||
|
||||
export const toIdentityProviderEditMapper = (
|
||||
|
|
|
@ -18,7 +18,9 @@ export const IdentityProviderRoute: RouteDef = {
|
|||
path: "/:realm/identity-providers/:providerId/:alias/:tab",
|
||||
element: <DetailSettings />,
|
||||
breadcrumb: (t) => t("identity-providers:providerDetails"),
|
||||
access: "view-identity-providers",
|
||||
handle: {
|
||||
access: "view-identity-providers",
|
||||
},
|
||||
};
|
||||
|
||||
export const toIdentityProvider = (
|
||||
|
|
|
@ -14,7 +14,9 @@ export const IdentityProviderCreateRoute: RouteDef = {
|
|||
path: "/:realm/identity-providers/:providerId/add",
|
||||
element: <AddIdentityProvider />,
|
||||
breadcrumb: (t) => t("identity-providers:addProvider"),
|
||||
access: "manage-identity-providers",
|
||||
handle: {
|
||||
access: "manage-identity-providers",
|
||||
},
|
||||
};
|
||||
|
||||
export const toIdentityProviderCreate = (
|
||||
|
|
|
@ -11,7 +11,9 @@ export const IdentityProviderKeycloakOidcRoute: RouteDef = {
|
|||
path: "/:realm/identity-providers/keycloak-oidc/add",
|
||||
element: <AddOpenIdConnect />,
|
||||
breadcrumb: (t) => t("identity-providers:addKeycloakOpenIdProvider"),
|
||||
access: "manage-identity-providers",
|
||||
handle: {
|
||||
access: "manage-identity-providers",
|
||||
},
|
||||
};
|
||||
|
||||
export const toIdentityProviderKeycloakOidc = (
|
||||
|
|
|
@ -11,7 +11,9 @@ export const IdentityProviderOidcRoute: RouteDef = {
|
|||
path: "/:realm/identity-providers/oidc/add",
|
||||
element: <AddOpenIdConnect />,
|
||||
breadcrumb: (t) => t("identity-providers:addOpenIdProvider"),
|
||||
access: "manage-identity-providers",
|
||||
handle: {
|
||||
access: "manage-identity-providers",
|
||||
},
|
||||
};
|
||||
|
||||
export const toIdentityProviderOidc = (
|
||||
|
|
|
@ -11,7 +11,9 @@ export const IdentityProviderSamlRoute: RouteDef = {
|
|||
path: "/:realm/identity-providers/saml/add",
|
||||
element: <AddSamlConnect />,
|
||||
breadcrumb: (t) => t("identity-providers:addSamlProvider"),
|
||||
access: "manage-identity-providers",
|
||||
handle: {
|
||||
access: "manage-identity-providers",
|
||||
},
|
||||
};
|
||||
|
||||
export const toIdentityProviderSaml = (
|
||||
|
|
|
@ -13,7 +13,9 @@ export const IdentityProvidersRoute: RouteDef = {
|
|||
path: "/:realm/identity-providers",
|
||||
element: <IdentityProvidersSection />,
|
||||
breadcrumb: (t) => t("identityProviders"),
|
||||
access: "view-identity-providers",
|
||||
handle: {
|
||||
access: "view-identity-providers",
|
||||
},
|
||||
};
|
||||
|
||||
export const toIdentityProviders = (
|
||||
|
|
|
@ -11,7 +11,9 @@ export const AddRoleRoute: RouteDef = {
|
|||
path: "/:realm/roles/new",
|
||||
element: <CreateRealmRole />,
|
||||
breadcrumb: (t) => t("roles:createRole"),
|
||||
access: "manage-realm",
|
||||
handle: {
|
||||
access: "manage-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toAddRole = (params: AddRoleParams): Partial<Path> => ({
|
||||
|
|
|
@ -23,7 +23,9 @@ export const RealmRoleRoute: RouteDef = {
|
|||
path: "/:realm/roles/:id/:tab",
|
||||
element: <RealmRoleTabs />,
|
||||
breadcrumb: (t) => t("roles:roleDetails"),
|
||||
access: ["view-realm", "view-users"],
|
||||
handle: {
|
||||
access: ["view-realm", "view-users"],
|
||||
},
|
||||
};
|
||||
|
||||
export const toRealmRole = (params: RealmRoleParams): Partial<Path> => ({
|
||||
|
|
|
@ -11,7 +11,9 @@ export const RealmRolesRoute: RouteDef = {
|
|||
path: "/:realm/roles",
|
||||
element: <RealmRolesSection />,
|
||||
breadcrumb: (t) => t("roles:realmRolesList"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toRealmRoles = (params: RealmRolesParams): Partial<Path> => ({
|
||||
|
|
|
@ -13,7 +13,9 @@ export const AddAttributeRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/user-profile/attributes/add-attribute",
|
||||
element: <NewAttributeSettings />,
|
||||
breadcrumb: (t) => t("realm-settings:createAttribute"),
|
||||
access: "manage-realm",
|
||||
handle: {
|
||||
access: "manage-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toAddAttribute = (params: AddAttributeParams): Partial<Path> => ({
|
||||
|
|
|
@ -11,7 +11,9 @@ export const AddClientPolicyRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/client-policies/policies/add-client-policy",
|
||||
element: <NewClientPolicyForm />,
|
||||
breadcrumb: (t) => t("realm-settings:createPolicy"),
|
||||
access: "manage-clients",
|
||||
handle: {
|
||||
access: "manage-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toAddClientPolicy = (
|
||||
|
|
|
@ -14,7 +14,9 @@ export const AddClientProfileRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/client-policies/:tab/add-profile",
|
||||
element: <ClientProfileForm />,
|
||||
breadcrumb: (t) => t("realm-settings:newClientProfile"),
|
||||
access: "manage-realm",
|
||||
handle: {
|
||||
access: "manage-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toAddClientProfile = (
|
||||
|
|
|
@ -16,7 +16,9 @@ export const NewClientPolicyConditionRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/client-policies/:policyName/edit-policy/create-condition",
|
||||
element: <NewClientPolicyCondition />,
|
||||
breadcrumb: (t) => t("realm-settings:addCondition"),
|
||||
access: "manage-clients",
|
||||
handle: {
|
||||
access: "manage-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toNewClientPolicyCondition = (
|
||||
|
|
|
@ -14,7 +14,9 @@ export const AddExecutorRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/client-policies/:profileName/add-executor",
|
||||
element: <ExecutorForm />,
|
||||
breadcrumb: (t) => t("realm-settings:addExecutor"),
|
||||
access: "manage-realm",
|
||||
handle: {
|
||||
access: "manage-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toAddExecutor = (params: AddExecutorParams): Partial<Path> => ({
|
||||
|
|
|
@ -14,7 +14,9 @@ export const AttributeRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/user-profile/attributes/:attributeName/edit-attribute",
|
||||
element: <NewAttributeSettings />,
|
||||
breadcrumb: (t) => t("realm-settings:editAttribute"),
|
||||
access: "manage-realm",
|
||||
handle: {
|
||||
access: "manage-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toAttribute = (params: AttributeParams): Partial<Path> => ({
|
||||
|
|
|
@ -16,7 +16,9 @@ export const ClientPoliciesRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/client-policies/:tab",
|
||||
element: <RealmSettingsSection />,
|
||||
breadcrumb: (t) => t("realm-settings:clientPolicies"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toClientPolicies = (
|
||||
|
|
|
@ -14,7 +14,9 @@ export const ClientProfileRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/client-policies/:profileName/edit-profile",
|
||||
element: <ClientProfileForm />,
|
||||
breadcrumb: (t) => t("realm-settings:clientProfile"),
|
||||
access: ["view-realm", "view-users"],
|
||||
handle: {
|
||||
access: ["view-realm", "view-users"],
|
||||
},
|
||||
};
|
||||
|
||||
export const toClientProfile = (
|
||||
|
|
|
@ -16,7 +16,9 @@ export const EditAttributesGroupRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/user-profile/attributesGroup/edit/:name",
|
||||
element: <AttributesGroupDetails />,
|
||||
breadcrumb: (t) => t("realm-settings:editGroupText"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toEditAttributesGroup = (
|
||||
|
|
|
@ -13,8 +13,10 @@ const NewClientPolicyForm = lazy(() => import("../NewClientPolicyForm"));
|
|||
export const EditClientPolicyRoute: RouteDef = {
|
||||
path: "/:realm/realm-settings/client-policies/:policyName/edit-policy",
|
||||
element: <NewClientPolicyForm />,
|
||||
access: "manage-realm",
|
||||
breadcrumb: (t) => t("realm-settings:policyDetails"),
|
||||
handle: {
|
||||
access: "manage-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toEditClientPolicy = (
|
||||
|
|
|
@ -17,7 +17,9 @@ export const EditClientPolicyConditionRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/client-policies/:policyName/edit-policy/:conditionName/edit-condition",
|
||||
element: <NewClientPolicyCondition />,
|
||||
breadcrumb: (t) => t("realm-settings:editCondition"),
|
||||
access: "manage-clients",
|
||||
handle: {
|
||||
access: "manage-clients",
|
||||
},
|
||||
};
|
||||
|
||||
export const toEditClientPolicyCondition = (
|
||||
|
|
|
@ -15,7 +15,9 @@ export const ExecutorRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/client-policies/:profileName/edit-profile/:executorName",
|
||||
element: <ExecutorForm />,
|
||||
breadcrumb: (t) => t("realm-settings:executorDetails"),
|
||||
access: ["manage-realm"],
|
||||
handle: {
|
||||
access: ["manage-realm"],
|
||||
},
|
||||
};
|
||||
|
||||
export const toExecutor = (params: ExecutorParams): Partial<Path> => ({
|
||||
|
|
|
@ -27,7 +27,9 @@ export const KeyProviderFormRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/keys/providers/:id/:providerType/settings",
|
||||
element: <KeyProviderForm />,
|
||||
breadcrumb: (t) => t("realm-settings:editProvider"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toKeyProvider = (params: KeyProviderParams): Partial<Path> => ({
|
||||
|
|
|
@ -16,7 +16,9 @@ export const KeysRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/keys/:tab",
|
||||
element: <RealmSettingsSection />,
|
||||
breadcrumb: (t) => t("realm-settings:keys"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toKeysTab = (params: KeysParams): Partial<Path> => ({
|
||||
|
|
|
@ -15,7 +15,9 @@ export const NewAttributesGroupRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/user-profile/attributesGroup/new",
|
||||
element: <AttributesGroupDetails />,
|
||||
breadcrumb: (t) => t("realm-settings:createGroupText"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toNewAttributesGroup = (
|
||||
|
|
|
@ -29,7 +29,9 @@ export const RealmSettingsRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings",
|
||||
element: <RealmSettingsSection />,
|
||||
breadcrumb: (t) => t("realmSettings"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const RealmSettingsRouteWithTab: RouteDef = {
|
||||
|
|
|
@ -16,7 +16,9 @@ export const UserProfileRoute: RouteDef = {
|
|||
path: "/:realm/realm-settings/user-profile/:tab",
|
||||
element: <RealmSettingsSection />,
|
||||
breadcrumb: (t) => t("realm-settings:userProfile"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toUserProfile = (params: UserProfileParams): Partial<Path> => ({
|
||||
|
|
|
@ -11,7 +11,9 @@ export const AddRealmRoute: RouteDef = {
|
|||
path: "/:realm/add-realm",
|
||||
element: <NewRealmForm />,
|
||||
breadcrumb: (t) => t("realm:createRealm"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toAddRealm = (params: AddRealmParams): Partial<Path> => ({
|
||||
|
|
|
@ -18,16 +18,22 @@ import sessionRoutes from "./sessions/routes";
|
|||
import userFederationRoutes from "./user-federation/routes";
|
||||
import userRoutes from "./user/routes";
|
||||
|
||||
export type RouteObjectHandle = {
|
||||
access: AccessType | AccessType[];
|
||||
};
|
||||
|
||||
export type RouteDef = Required<Pick<RouteObject, "element">> & {
|
||||
path: string;
|
||||
breadcrumb?: (t: TFunction) => string | ComponentType<any>;
|
||||
access: AccessType | AccessType[];
|
||||
handle: RouteObjectHandle;
|
||||
};
|
||||
|
||||
const NotFoundRoute: RouteDef = {
|
||||
path: "*",
|
||||
element: <PageNotFoundSection />,
|
||||
access: "anyone",
|
||||
handle: {
|
||||
access: "anyone",
|
||||
},
|
||||
};
|
||||
|
||||
export const routes: RouteDef[] = [
|
||||
|
|
|
@ -11,7 +11,9 @@ export const SessionsRoute: RouteDef = {
|
|||
path: "/:realm/sessions",
|
||||
element: <SessionsSection />,
|
||||
breadcrumb: (t) => t("sessions:title"),
|
||||
access: ["view-realm", "view-clients", "view-users"],
|
||||
handle: {
|
||||
access: ["view-realm", "view-clients", "view-users"],
|
||||
},
|
||||
};
|
||||
|
||||
export const toSessions = (params: SessionsParams): Partial<Path> => ({
|
||||
|
|
|
@ -18,7 +18,9 @@ export const CustomUserFederationRoute: RouteDef = {
|
|||
path: "/:realm/user-federation/:providerId/:id",
|
||||
element: <CustomProviderSettings />,
|
||||
breadcrumb: (t) => t("user-federation:providerDetails"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toCustomUserFederation = (
|
||||
|
|
|
@ -17,7 +17,9 @@ export const NewCustomUserFederationRoute: RouteDef = {
|
|||
path: "/:realm/user-federation/:providerId/new",
|
||||
element: <CustomProviderSettings />,
|
||||
breadcrumb: (t) => t("user-federation:addCustomProvider"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toNewCustomUserFederation = (
|
||||
|
|
|
@ -13,7 +13,9 @@ export const NewKerberosUserFederationRoute: RouteDef = {
|
|||
path: "/:realm/user-federation/kerberos/new",
|
||||
element: <UserFederationKerberosSettings />,
|
||||
breadcrumb: (t) => t("common:settings"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toNewKerberosUserFederation = (
|
||||
|
|
|
@ -14,7 +14,9 @@ export const NewLdapUserFederationRoute: RouteDef = {
|
|||
element: <CreateUserFederationLdapSettings />,
|
||||
breadcrumb: (t) =>
|
||||
t("user-federation:addProvider", { provider: "LDAP", count: 1 }),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toNewLdapUserFederation = (
|
||||
|
|
|
@ -11,7 +11,9 @@ export const UserFederationRoute: RouteDef = {
|
|||
path: "/:realm/user-federation",
|
||||
element: <UserFederationSection />,
|
||||
breadcrumb: (t) => t("userFederation"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toUserFederation = (
|
||||
|
|
|
@ -16,7 +16,9 @@ export const UserFederationKerberosRoute: RouteDef = {
|
|||
path: "/:realm/user-federation/kerberos/:id",
|
||||
element: <UserFederationKerberosSettings />,
|
||||
breadcrumb: (t) => t("common:settings"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toUserFederationKerberos = (
|
||||
|
|
|
@ -19,7 +19,9 @@ export const UserFederationLdapRoute: RouteDef = {
|
|||
path: "/:realm/user-federation/ldap/:id",
|
||||
element: <UserFederationLdapSettings />,
|
||||
breadcrumb: (t) => t("common:settings"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const UserFederationLdapWithTabRoute: RouteDef = {
|
||||
|
|
|
@ -17,7 +17,9 @@ export const UserFederationLdapMapperRoute: RouteDef = {
|
|||
path: "/:realm/user-federation/ldap/:id/mappers/:mapperId",
|
||||
element: <LdapMapperDetails />,
|
||||
breadcrumb: (t) => t("common:mappingDetails"),
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toUserFederationLdapMapper = (
|
||||
|
|
|
@ -10,7 +10,9 @@ const UserFederationSection = lazy(() => import("../UserFederationSection"));
|
|||
export const UserFederationsKerberosRoute: RouteDef = {
|
||||
path: "/:realm/user-federation/kerberos",
|
||||
element: <UserFederationSection />,
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toUserFederationsKerberos = (
|
||||
|
|
|
@ -10,7 +10,9 @@ const UserFederationSection = lazy(() => import("../UserFederationSection"));
|
|||
export const UserFederationsLdapRoute: RouteDef = {
|
||||
path: "/:realm/user-federation/ldap",
|
||||
element: <UserFederationSection />,
|
||||
access: "view-realm",
|
||||
handle: {
|
||||
access: "view-realm",
|
||||
},
|
||||
};
|
||||
|
||||
export const toUserFederationsLdap = (
|
||||
|
|
|
@ -12,7 +12,9 @@ export const AddUserRoute: RouteDef = {
|
|||
path: "/:realm/users/add-user",
|
||||
element: <CreateUser />,
|
||||
breadcrumb: (t) => t("users:createUser"),
|
||||
access: ["query-users", "query-groups"],
|
||||
handle: {
|
||||
access: ["query-users", "query-groups"],
|
||||
},
|
||||
};
|
||||
|
||||
export const toAddUser = (params: AddUserParams): Partial<Path> => ({
|
||||
|
|
|
@ -25,7 +25,9 @@ export const UserRoute: RouteDef = {
|
|||
path: "/:realm/users/:id/:tab",
|
||||
element: <EditUser />,
|
||||
breadcrumb: (t) => t("users:userDetails"),
|
||||
access: "query-users",
|
||||
handle: {
|
||||
access: "query-users",
|
||||
},
|
||||
};
|
||||
|
||||
export const toUser = (params: UserParams): Partial<Path> => ({
|
||||
|
|
|
@ -13,7 +13,9 @@ export const UsersRoute: RouteDef = {
|
|||
path: "/:realm/users",
|
||||
element: <UsersSection />,
|
||||
breadcrumb: (t) => t("users:title"),
|
||||
access: "query-users",
|
||||
handle: {
|
||||
access: "query-users",
|
||||
},
|
||||
};
|
||||
|
||||
export const UsersRouteWithTab: RouteDef = {
|
||||
|
|
Loading…
Reference in a new issue