Move access property to React Router's handle (#19320)

This commit is contained in:
Jon Koops 2023-03-27 02:31:23 +02:00 committed by GitHub
parent 251f6151e8
commit 0fb9b9becd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 237 additions and 83 deletions

View file

@ -62,14 +62,14 @@ type SecuredRouteProps = { route: RouteDef };
const SecuredRoute = ({ route }: SecuredRouteProps) => { const SecuredRoute = ({ route }: SecuredRouteProps) => {
const { hasAccess } = useAccess(); const { hasAccess } = useAccess();
const accessAllowed = const accessAllowed =
route.access instanceof Array route.handle.access instanceof Array
? hasAccess(...route.access) ? hasAccess(...route.handle.access)
: hasAccess(route.access); : hasAccess(route.handle.access);
if (accessAllowed) if (accessAllowed)
return <Suspense fallback={<KeycloakSpinner />}>{route.element}</Suspense>; return <Suspense fallback={<KeycloakSpinner />}>{route.element}</Suspense>;
return <ForbiddenSection permissionNeeded={route.access} />; return <ForbiddenSection permissionNeeded={route.handle.access} />;
}; };
export const App = ({ keycloak, adminClient }: AdminClientProps) => { export const App = ({ keycloak, adminClient }: AdminClientProps) => {

View file

@ -30,9 +30,9 @@ const LeftNav = ({ title, path }: LeftNavProps) => {
const accessAllowed = const accessAllowed =
route && route &&
(route.access instanceof Array (route.handle.access instanceof Array
? hasAccess(...route.access) ? hasAccess(...route.handle.access)
: hasAccess(route.access)); : hasAccess(route.handle.access));
if (!accessAllowed) { if (!accessAllowed) {
return null; return null;

View file

@ -13,7 +13,9 @@ export const AuthenticationRoute: RouteDef = {
path: "/:realm/authentication", path: "/:realm/authentication",
element: <AuthenticationSection />, element: <AuthenticationSection />,
breadcrumb: (t) => t("authentication"), 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 = { export const AuthenticationRouteWithTab: RouteDef = {

View file

@ -11,7 +11,9 @@ export const CreateFlowRoute: RouteDef = {
path: "/:realm/authentication/flows/create", path: "/:realm/authentication/flows/create",
element: <CreateFlow />, element: <CreateFlow />,
breadcrumb: (t) => t("authentication:createFlow"), breadcrumb: (t) => t("authentication:createFlow"),
access: "manage-authorization", handle: {
access: "manage-authorization",
},
}; };
export const toCreateFlow = (params: CreateFlowParams): Partial<Path> => ({ export const toCreateFlow = (params: CreateFlowParams): Partial<Path> => ({

View file

@ -16,7 +16,9 @@ export const FlowRoute: RouteDef = {
path: "/:realm/authentication/:id/:usedBy", path: "/:realm/authentication/:id/:usedBy",
element: <FlowDetails />, element: <FlowDetails />,
breadcrumb: (t) => t("authentication:flowDetails"), breadcrumb: (t) => t("authentication:flowDetails"),
access: "view-authorization", handle: {
access: "view-authorization",
},
}; };
export const FlowWithBuiltInRoute: RouteDef = { export const FlowWithBuiltInRoute: RouteDef = {

View file

@ -17,7 +17,9 @@ export const ClientScopeRoute: RouteDef = {
path: "/:realm/client-scopes/:id/:tab", path: "/:realm/client-scopes/:id/:tab",
element: <EditClientScope />, element: <EditClientScope />,
breadcrumb: (t) => t("client-scopes:clientScopeDetails"), breadcrumb: (t) => t("client-scopes:clientScopeDetails"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const toClientScope = (params: ClientScopeParams): Partial<Path> => { export const toClientScope = (params: ClientScopeParams): Partial<Path> => {

View file

@ -11,7 +11,9 @@ export const ClientScopesRoute: RouteDef = {
path: "/:realm/client-scopes", path: "/:realm/client-scopes",
element: <ClientScopesSection />, element: <ClientScopesSection />,
breadcrumb: (t) => t("client-scopes:clientScopeList"), breadcrumb: (t) => t("client-scopes:clientScopeList"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const toClientScopes = (params: ClientScopesParams): Partial<Path> => ({ export const toClientScopes = (params: ClientScopesParams): Partial<Path> => ({

View file

@ -15,7 +15,9 @@ export const MapperRoute: RouteDef = {
path: "/:realm/client-scopes/:id/mappers/:mapperId", path: "/:realm/client-scopes/:id/mappers/:mapperId",
element: <MappingDetails />, element: <MappingDetails />,
breadcrumb: (t) => t("common:mappingDetails"), breadcrumb: (t) => t("common:mappingDetails"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const toMapper = (params: MapperParams): Partial<Path> => ({ export const toMapper = (params: MapperParams): Partial<Path> => ({

View file

@ -11,7 +11,9 @@ export const NewClientScopeRoute: RouteDef = {
path: "/:realm/client-scopes/new", path: "/:realm/client-scopes/new",
element: <CreateClientScope />, element: <CreateClientScope />,
breadcrumb: (t) => t("client-scopes:createClientScope"), breadcrumb: (t) => t("client-scopes:createClientScope"),
access: "manage-clients", handle: {
access: "manage-clients",
},
}; };
export const toNewClientScope = ( export const toNewClientScope = (

View file

@ -11,7 +11,9 @@ export const AddClientRoute: RouteDef = {
path: "/:realm/clients/add-client", path: "/:realm/clients/add-client",
element: <NewClientForm />, element: <NewClientForm />,
breadcrumb: (t) => t("clients:createClient"), breadcrumb: (t) => t("clients:createClient"),
access: "manage-clients", handle: {
access: "manage-clients",
},
}; };
export const toAddClient = (params: AddClientParams): Partial<Path> => ({ export const toAddClient = (params: AddClientParams): Partial<Path> => ({

View file

@ -17,7 +17,9 @@ export const AddRegistrationProviderRoute: RouteDef = {
path: "/:realm/clients/client-registration/:subTab/:providerId", path: "/:realm/clients/client-registration/:subTab/:providerId",
element: <DetailProvider />, element: <DetailProvider />,
breadcrumb: (t) => t("clients:clientSettings"), breadcrumb: (t) => t("clients:clientSettings"),
access: "manage-clients", handle: {
access: "manage-clients",
},
}; };
export const EditRegistrationProviderRoute: RouteDef = { export const EditRegistrationProviderRoute: RouteDef = {

View file

@ -24,7 +24,9 @@ export const AuthorizationRoute: RouteDef = {
path: "/:realm/clients/:clientId/authorization/:tab", path: "/:realm/clients/:clientId/authorization/:tab",
element: <ClientDetails />, element: <ClientDetails />,
breadcrumb: (t) => t("clients:clientSettings"), breadcrumb: (t) => t("clients:clientSettings"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const toAuthorizationTab = ( export const toAuthorizationTab = (

View file

@ -28,7 +28,9 @@ export const ClientRoute: RouteDef = {
path: "/:realm/clients/:clientId/:tab", path: "/:realm/clients/:clientId/:tab",
element: <ClientDetails />, element: <ClientDetails />,
breadcrumb: (t) => t("clients:clientSettings"), breadcrumb: (t) => t("clients:clientSettings"),
access: "query-clients", handle: {
access: "query-clients",
},
}; };
export const toClient = (params: ClientParams): Partial<Path> => ({ export const toClient = (params: ClientParams): Partial<Path> => ({

View file

@ -16,7 +16,9 @@ export const ClientRegistrationRoute: RouteDef = {
path: "/:realm/clients/client-registration/:subTab", path: "/:realm/clients/client-registration/:subTab",
element: <ClientsSection />, element: <ClientsSection />,
breadcrumb: (t) => t("clients:clientRegistration"), breadcrumb: (t) => t("clients:clientRegistration"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const toClientRegistration = ( export const toClientRegistration = (

View file

@ -22,7 +22,9 @@ export const ClientRoleRoute: RouteDef = {
path: "/:realm/clients/:clientId/roles/:id/:tab" as const, path: "/:realm/clients/:clientId/roles/:id/:tab" as const,
element: <RealmRoleTabs />, element: <RealmRoleTabs />,
breadcrumb: (t) => t("roles:roleDetails"), breadcrumb: (t) => t("roles:roleDetails"),
access: "view-realm", handle: {
access: "view-realm",
},
} satisfies RouteDef; } satisfies RouteDef;
export const toClientRole = (params: ClientRoleParams): Partial<Path> => ({ export const toClientRole = (params: ClientRoleParams): Partial<Path> => ({

View file

@ -17,7 +17,9 @@ export const ClientScopesRoute: RouteDef = {
path: "/:realm/clients/:clientId/clientScopes/:tab", path: "/:realm/clients/:clientId/clientScopes/:tab",
element: <ClientDetails />, element: <ClientDetails />,
breadcrumb: (t) => t("clients:clientSettings"), breadcrumb: (t) => t("clients:clientSettings"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const toClientScopesTab = ( export const toClientScopesTab = (

View file

@ -19,7 +19,9 @@ export const ClientsRoute: RouteDef = {
path: "/:realm/clients", path: "/:realm/clients",
element: <ClientsSection />, element: <ClientsSection />,
breadcrumb: (t) => t("clients:clientList"), breadcrumb: (t) => t("clients:clientList"),
access: "query-clients", handle: {
access: "query-clients",
},
}; };
export const ClientsRouteWithTab: RouteDef = { export const ClientsRouteWithTab: RouteDef = {

View file

@ -13,7 +13,9 @@ export const CreateInitialAccessTokenRoute: RouteDef = {
path: "/:realm/clients/initialAccessToken/create", path: "/:realm/clients/initialAccessToken/create",
element: <CreateInitialAccessToken />, element: <CreateInitialAccessToken />,
breadcrumb: (t) => t("clients:createToken"), breadcrumb: (t) => t("clients:createToken"),
access: "manage-clients", handle: {
access: "manage-clients",
},
}; };
export const toCreateInitialAccessToken = ( export const toCreateInitialAccessToken = (

View file

@ -17,7 +17,9 @@ export const DedicatedScopeDetailsRoute: RouteDef = {
path: "/:realm/clients/:clientId/clientScopes/dedicated", path: "/:realm/clients/:clientId/clientScopes/dedicated",
element: <DedicatedScopes />, element: <DedicatedScopes />,
breadcrumb: (t) => t("clients:dedicatedScopes"), breadcrumb: (t) => t("clients:dedicatedScopes"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const DedicatedScopeDetailsWithTabRoute: RouteDef = { export const DedicatedScopeDetailsWithTabRoute: RouteDef = {

View file

@ -11,7 +11,9 @@ export const ImportClientRoute: RouteDef = {
path: "/:realm/clients/import-client", path: "/:realm/clients/import-client",
element: <ImportForm />, element: <ImportForm />,
breadcrumb: (t) => t("clients:importClient"), breadcrumb: (t) => t("clients:importClient"),
access: "manage-clients", handle: {
access: "manage-clients",
},
}; };
export const toImportClient = (params: ImportClientParams): Partial<Path> => ({ export const toImportClient = (params: ImportClientParams): Partial<Path> => ({

View file

@ -17,7 +17,9 @@ export const MapperRoute: RouteDef = {
path: "/:realm/clients/:id/clientScopes/dedicated/mappers/:mapperId", path: "/:realm/clients/:id/clientScopes/dedicated/mappers/:mapperId",
element: <MappingDetails />, element: <MappingDetails />,
breadcrumb: (t) => t("common:mappingDetails"), breadcrumb: (t) => t("common:mappingDetails"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const toMapper = (params: MapperParams): Partial<Path> => ({ export const toMapper = (params: MapperParams): Partial<Path> => ({

View file

@ -20,7 +20,9 @@ export const NewPermissionRoute: RouteDef = {
path: "/:realm/clients/:id/authorization/permission/new/:permissionType", path: "/:realm/clients/:id/authorization/permission/new/:permissionType",
element: <PermissionDetails />, element: <PermissionDetails />,
breadcrumb: (t) => t("clients:createPermission"), breadcrumb: (t) => t("clients:createPermission"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const NewPermissionWithSelectedIdRoute: RouteDef = { export const NewPermissionWithSelectedIdRoute: RouteDef = {

View file

@ -13,7 +13,9 @@ export const NewPolicyRoute: RouteDef = {
path: "/:realm/clients/:id/authorization/policy/new/:policyType", path: "/:realm/clients/:id/authorization/policy/new/:policyType",
element: <PolicyDetails />, element: <PolicyDetails />,
breadcrumb: (t) => t("clients:createPolicy"), breadcrumb: (t) => t("clients:createPolicy"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const toCreatePolicy = (params: NewPolicyParams): Partial<Path> => ({ export const toCreatePolicy = (params: NewPolicyParams): Partial<Path> => ({

View file

@ -11,7 +11,9 @@ export const NewResourceRoute: RouteDef = {
path: "/:realm/clients/:id/authorization/resource/new", path: "/:realm/clients/:id/authorization/resource/new",
element: <ResourceDetails />, element: <ResourceDetails />,
breadcrumb: (t) => t("clients:createResource"), breadcrumb: (t) => t("clients:createResource"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const toCreateResource = (params: NewResourceParams): Partial<Path> => ({ export const toCreateResource = (params: NewResourceParams): Partial<Path> => ({

View file

@ -11,7 +11,9 @@ export const NewRoleRoute: RouteDef = {
path: "/:realm/clients/:clientId/roles/new", path: "/:realm/clients/:clientId/roles/new",
element: <CreateClientRole />, element: <CreateClientRole />,
breadcrumb: (t) => t("roles:createRole"), breadcrumb: (t) => t("roles:createRole"),
access: "manage-clients", handle: {
access: "manage-clients",
},
}; };
export const toCreateRole = (params: NewRoleParams): Partial<Path> => ({ export const toCreateRole = (params: NewRoleParams): Partial<Path> => ({

View file

@ -11,7 +11,9 @@ export const NewScopeRoute: RouteDef = {
path: "/:realm/clients/:id/authorization/scope/new", path: "/:realm/clients/:id/authorization/scope/new",
element: <ScopeDetails />, element: <ScopeDetails />,
breadcrumb: (t) => t("clients:createAuthorizationScope"), breadcrumb: (t) => t("clients:createAuthorizationScope"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const toNewScope = (params: NewScopeParams): Partial<Path> => ({ export const toNewScope = (params: NewScopeParams): Partial<Path> => ({

View file

@ -19,7 +19,9 @@ export const PermissionDetailsRoute: RouteDef = {
path: "/:realm/clients/:id/authorization/permission/:permissionType/:permissionId", path: "/:realm/clients/:id/authorization/permission/:permissionType/:permissionId",
element: <PermissionDetails />, element: <PermissionDetails />,
breadcrumb: (t) => t("clients:permissionDetails"), breadcrumb: (t) => t("clients:permissionDetails"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const toPermissionDetails = ( export const toPermissionDetails = (

View file

@ -18,7 +18,9 @@ export const PolicyDetailsRoute: RouteDef = {
path: "/:realm/clients/:id/authorization/policy/:policyId/:policyType", path: "/:realm/clients/:id/authorization/policy/:policyId/:policyType",
element: <PolicyDetails />, element: <PolicyDetails />,
breadcrumb: (t) => t("clients:createPolicy"), breadcrumb: (t) => t("clients:createPolicy"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const toPolicyDetails = ( export const toPolicyDetails = (

View file

@ -15,7 +15,9 @@ export const ResourceDetailsRoute: RouteDef = {
path: "/:realm/clients/:id/authorization/resource", path: "/:realm/clients/:id/authorization/resource",
element: <ResourceDetails />, element: <ResourceDetails />,
breadcrumb: (t) => t("clients:createResource"), breadcrumb: (t) => t("clients:createResource"),
access: "view-clients", handle: {
access: "view-clients",
},
}; };
export const ResourceDetailsWithResourceIdRoute: RouteDef = { export const ResourceDetailsWithResourceIdRoute: RouteDef = {

View file

@ -15,7 +15,9 @@ export const ScopeDetailsRoute: RouteDef = {
path: "/:realm/clients/:id/authorization/scope", path: "/:realm/clients/:id/authorization/scope",
element: <ScopeDetails />, element: <ScopeDetails />,
breadcrumb: (t) => t("clients:createAuthorizationScope"), breadcrumb: (t) => t("clients:createAuthorizationScope"),
access: "manage-clients", handle: {
access: "manage-clients",
},
}; };
export const ScopeDetailsWithScopeIdRoute: RouteDef = { export const ScopeDetailsWithScopeIdRoute: RouteDef = {

View file

@ -13,7 +13,9 @@ export const DashboardRoute: RouteDef = {
path: "/", path: "/",
element: <Dashboard />, element: <Dashboard />,
breadcrumb: (t) => t("common:home"), breadcrumb: (t) => t("common:home"),
access: "anyone", handle: {
access: "anyone",
},
}; };
export const DashboardRouteWithRealm: RouteDef = { export const DashboardRouteWithRealm: RouteDef = {

View file

@ -16,7 +16,9 @@ export const EventsRoute: RouteDef = {
path: "/:realm/events", path: "/:realm/events",
element: <EventsSection />, element: <EventsSection />,
breadcrumb: (t) => t("events:title"), breadcrumb: (t) => t("events:title"),
access: "view-events", handle: {
access: "view-events",
},
}; };
export const EventsRouteWithTab: RouteDef = { export const EventsRouteWithTab: RouteDef = {

View file

@ -10,7 +10,9 @@ const GroupsSection = lazy(() => import("../GroupsSection"));
export const GroupsRoute: RouteDef = { export const GroupsRoute: RouteDef = {
path: "/:realm/groups/*", path: "/:realm/groups/*",
element: <GroupsSection />, element: <GroupsSection />,
access: "query-groups", handle: {
access: "query-groups",
},
}; };
export const GroupsWithIdRoute: RouteDef = { export const GroupsWithIdRoute: RouteDef = {

View file

@ -15,8 +15,10 @@ const AddMapper = lazy(() => import("../add/AddMapper"));
export const IdentityProviderAddMapperRoute: RouteDef = { export const IdentityProviderAddMapperRoute: RouteDef = {
path: "/:realm/identity-providers/:providerId/:alias/:tab/create", path: "/:realm/identity-providers/:providerId/:alias/:tab/create",
element: <AddMapper />, element: <AddMapper />,
access: "manage-identity-providers",
breadcrumb: (t) => t("identity-providers:addIdPMapper"), breadcrumb: (t) => t("identity-providers:addIdPMapper"),
handle: {
access: "manage-identity-providers",
},
}; };
export const toIdentityProviderAddMapper = ( export const toIdentityProviderAddMapper = (

View file

@ -15,8 +15,10 @@ const AddMapper = lazy(() => import("../add/AddMapper"));
export const IdentityProviderEditMapperRoute: RouteDef = { export const IdentityProviderEditMapperRoute: RouteDef = {
path: "/:realm/identity-providers/:providerId/:alias/mappers/:id", path: "/:realm/identity-providers/:providerId/:alias/mappers/:id",
element: <AddMapper />, element: <AddMapper />,
access: "manage-identity-providers",
breadcrumb: (t) => t("identity-providers:editIdPMapper"), breadcrumb: (t) => t("identity-providers:editIdPMapper"),
handle: {
access: "manage-identity-providers",
},
}; };
export const toIdentityProviderEditMapper = ( export const toIdentityProviderEditMapper = (

View file

@ -18,7 +18,9 @@ export const IdentityProviderRoute: RouteDef = {
path: "/:realm/identity-providers/:providerId/:alias/:tab", path: "/:realm/identity-providers/:providerId/:alias/:tab",
element: <DetailSettings />, element: <DetailSettings />,
breadcrumb: (t) => t("identity-providers:providerDetails"), breadcrumb: (t) => t("identity-providers:providerDetails"),
access: "view-identity-providers", handle: {
access: "view-identity-providers",
},
}; };
export const toIdentityProvider = ( export const toIdentityProvider = (

View file

@ -14,7 +14,9 @@ export const IdentityProviderCreateRoute: RouteDef = {
path: "/:realm/identity-providers/:providerId/add", path: "/:realm/identity-providers/:providerId/add",
element: <AddIdentityProvider />, element: <AddIdentityProvider />,
breadcrumb: (t) => t("identity-providers:addProvider"), breadcrumb: (t) => t("identity-providers:addProvider"),
access: "manage-identity-providers", handle: {
access: "manage-identity-providers",
},
}; };
export const toIdentityProviderCreate = ( export const toIdentityProviderCreate = (

View file

@ -11,7 +11,9 @@ export const IdentityProviderKeycloakOidcRoute: RouteDef = {
path: "/:realm/identity-providers/keycloak-oidc/add", path: "/:realm/identity-providers/keycloak-oidc/add",
element: <AddOpenIdConnect />, element: <AddOpenIdConnect />,
breadcrumb: (t) => t("identity-providers:addKeycloakOpenIdProvider"), breadcrumb: (t) => t("identity-providers:addKeycloakOpenIdProvider"),
access: "manage-identity-providers", handle: {
access: "manage-identity-providers",
},
}; };
export const toIdentityProviderKeycloakOidc = ( export const toIdentityProviderKeycloakOidc = (

View file

@ -11,7 +11,9 @@ export const IdentityProviderOidcRoute: RouteDef = {
path: "/:realm/identity-providers/oidc/add", path: "/:realm/identity-providers/oidc/add",
element: <AddOpenIdConnect />, element: <AddOpenIdConnect />,
breadcrumb: (t) => t("identity-providers:addOpenIdProvider"), breadcrumb: (t) => t("identity-providers:addOpenIdProvider"),
access: "manage-identity-providers", handle: {
access: "manage-identity-providers",
},
}; };
export const toIdentityProviderOidc = ( export const toIdentityProviderOidc = (

View file

@ -11,7 +11,9 @@ export const IdentityProviderSamlRoute: RouteDef = {
path: "/:realm/identity-providers/saml/add", path: "/:realm/identity-providers/saml/add",
element: <AddSamlConnect />, element: <AddSamlConnect />,
breadcrumb: (t) => t("identity-providers:addSamlProvider"), breadcrumb: (t) => t("identity-providers:addSamlProvider"),
access: "manage-identity-providers", handle: {
access: "manage-identity-providers",
},
}; };
export const toIdentityProviderSaml = ( export const toIdentityProviderSaml = (

View file

@ -13,7 +13,9 @@ export const IdentityProvidersRoute: RouteDef = {
path: "/:realm/identity-providers", path: "/:realm/identity-providers",
element: <IdentityProvidersSection />, element: <IdentityProvidersSection />,
breadcrumb: (t) => t("identityProviders"), breadcrumb: (t) => t("identityProviders"),
access: "view-identity-providers", handle: {
access: "view-identity-providers",
},
}; };
export const toIdentityProviders = ( export const toIdentityProviders = (

View file

@ -11,7 +11,9 @@ export const AddRoleRoute: RouteDef = {
path: "/:realm/roles/new", path: "/:realm/roles/new",
element: <CreateRealmRole />, element: <CreateRealmRole />,
breadcrumb: (t) => t("roles:createRole"), breadcrumb: (t) => t("roles:createRole"),
access: "manage-realm", handle: {
access: "manage-realm",
},
}; };
export const toAddRole = (params: AddRoleParams): Partial<Path> => ({ export const toAddRole = (params: AddRoleParams): Partial<Path> => ({

View file

@ -23,7 +23,9 @@ export const RealmRoleRoute: RouteDef = {
path: "/:realm/roles/:id/:tab", path: "/:realm/roles/:id/:tab",
element: <RealmRoleTabs />, element: <RealmRoleTabs />,
breadcrumb: (t) => t("roles:roleDetails"), breadcrumb: (t) => t("roles:roleDetails"),
access: ["view-realm", "view-users"], handle: {
access: ["view-realm", "view-users"],
},
}; };
export const toRealmRole = (params: RealmRoleParams): Partial<Path> => ({ export const toRealmRole = (params: RealmRoleParams): Partial<Path> => ({

View file

@ -11,7 +11,9 @@ export const RealmRolesRoute: RouteDef = {
path: "/:realm/roles", path: "/:realm/roles",
element: <RealmRolesSection />, element: <RealmRolesSection />,
breadcrumb: (t) => t("roles:realmRolesList"), breadcrumb: (t) => t("roles:realmRolesList"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toRealmRoles = (params: RealmRolesParams): Partial<Path> => ({ export const toRealmRoles = (params: RealmRolesParams): Partial<Path> => ({

View file

@ -13,7 +13,9 @@ export const AddAttributeRoute: RouteDef = {
path: "/:realm/realm-settings/user-profile/attributes/add-attribute", path: "/:realm/realm-settings/user-profile/attributes/add-attribute",
element: <NewAttributeSettings />, element: <NewAttributeSettings />,
breadcrumb: (t) => t("realm-settings:createAttribute"), breadcrumb: (t) => t("realm-settings:createAttribute"),
access: "manage-realm", handle: {
access: "manage-realm",
},
}; };
export const toAddAttribute = (params: AddAttributeParams): Partial<Path> => ({ export const toAddAttribute = (params: AddAttributeParams): Partial<Path> => ({

View file

@ -11,7 +11,9 @@ export const AddClientPolicyRoute: RouteDef = {
path: "/:realm/realm-settings/client-policies/policies/add-client-policy", path: "/:realm/realm-settings/client-policies/policies/add-client-policy",
element: <NewClientPolicyForm />, element: <NewClientPolicyForm />,
breadcrumb: (t) => t("realm-settings:createPolicy"), breadcrumb: (t) => t("realm-settings:createPolicy"),
access: "manage-clients", handle: {
access: "manage-clients",
},
}; };
export const toAddClientPolicy = ( export const toAddClientPolicy = (

View file

@ -14,7 +14,9 @@ export const AddClientProfileRoute: RouteDef = {
path: "/:realm/realm-settings/client-policies/:tab/add-profile", path: "/:realm/realm-settings/client-policies/:tab/add-profile",
element: <ClientProfileForm />, element: <ClientProfileForm />,
breadcrumb: (t) => t("realm-settings:newClientProfile"), breadcrumb: (t) => t("realm-settings:newClientProfile"),
access: "manage-realm", handle: {
access: "manage-realm",
},
}; };
export const toAddClientProfile = ( export const toAddClientProfile = (

View file

@ -16,7 +16,9 @@ export const NewClientPolicyConditionRoute: RouteDef = {
path: "/:realm/realm-settings/client-policies/:policyName/edit-policy/create-condition", path: "/:realm/realm-settings/client-policies/:policyName/edit-policy/create-condition",
element: <NewClientPolicyCondition />, element: <NewClientPolicyCondition />,
breadcrumb: (t) => t("realm-settings:addCondition"), breadcrumb: (t) => t("realm-settings:addCondition"),
access: "manage-clients", handle: {
access: "manage-clients",
},
}; };
export const toNewClientPolicyCondition = ( export const toNewClientPolicyCondition = (

View file

@ -14,7 +14,9 @@ export const AddExecutorRoute: RouteDef = {
path: "/:realm/realm-settings/client-policies/:profileName/add-executor", path: "/:realm/realm-settings/client-policies/:profileName/add-executor",
element: <ExecutorForm />, element: <ExecutorForm />,
breadcrumb: (t) => t("realm-settings:addExecutor"), breadcrumb: (t) => t("realm-settings:addExecutor"),
access: "manage-realm", handle: {
access: "manage-realm",
},
}; };
export const toAddExecutor = (params: AddExecutorParams): Partial<Path> => ({ export const toAddExecutor = (params: AddExecutorParams): Partial<Path> => ({

View file

@ -14,7 +14,9 @@ export const AttributeRoute: RouteDef = {
path: "/:realm/realm-settings/user-profile/attributes/:attributeName/edit-attribute", path: "/:realm/realm-settings/user-profile/attributes/:attributeName/edit-attribute",
element: <NewAttributeSettings />, element: <NewAttributeSettings />,
breadcrumb: (t) => t("realm-settings:editAttribute"), breadcrumb: (t) => t("realm-settings:editAttribute"),
access: "manage-realm", handle: {
access: "manage-realm",
},
}; };
export const toAttribute = (params: AttributeParams): Partial<Path> => ({ export const toAttribute = (params: AttributeParams): Partial<Path> => ({

View file

@ -16,7 +16,9 @@ export const ClientPoliciesRoute: RouteDef = {
path: "/:realm/realm-settings/client-policies/:tab", path: "/:realm/realm-settings/client-policies/:tab",
element: <RealmSettingsSection />, element: <RealmSettingsSection />,
breadcrumb: (t) => t("realm-settings:clientPolicies"), breadcrumb: (t) => t("realm-settings:clientPolicies"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toClientPolicies = ( export const toClientPolicies = (

View file

@ -14,7 +14,9 @@ export const ClientProfileRoute: RouteDef = {
path: "/:realm/realm-settings/client-policies/:profileName/edit-profile", path: "/:realm/realm-settings/client-policies/:profileName/edit-profile",
element: <ClientProfileForm />, element: <ClientProfileForm />,
breadcrumb: (t) => t("realm-settings:clientProfile"), breadcrumb: (t) => t("realm-settings:clientProfile"),
access: ["view-realm", "view-users"], handle: {
access: ["view-realm", "view-users"],
},
}; };
export const toClientProfile = ( export const toClientProfile = (

View file

@ -16,7 +16,9 @@ export const EditAttributesGroupRoute: RouteDef = {
path: "/:realm/realm-settings/user-profile/attributesGroup/edit/:name", path: "/:realm/realm-settings/user-profile/attributesGroup/edit/:name",
element: <AttributesGroupDetails />, element: <AttributesGroupDetails />,
breadcrumb: (t) => t("realm-settings:editGroupText"), breadcrumb: (t) => t("realm-settings:editGroupText"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toEditAttributesGroup = ( export const toEditAttributesGroup = (

View file

@ -13,8 +13,10 @@ const NewClientPolicyForm = lazy(() => import("../NewClientPolicyForm"));
export const EditClientPolicyRoute: RouteDef = { export const EditClientPolicyRoute: RouteDef = {
path: "/:realm/realm-settings/client-policies/:policyName/edit-policy", path: "/:realm/realm-settings/client-policies/:policyName/edit-policy",
element: <NewClientPolicyForm />, element: <NewClientPolicyForm />,
access: "manage-realm",
breadcrumb: (t) => t("realm-settings:policyDetails"), breadcrumb: (t) => t("realm-settings:policyDetails"),
handle: {
access: "manage-realm",
},
}; };
export const toEditClientPolicy = ( export const toEditClientPolicy = (

View file

@ -17,7 +17,9 @@ export const EditClientPolicyConditionRoute: RouteDef = {
path: "/:realm/realm-settings/client-policies/:policyName/edit-policy/:conditionName/edit-condition", path: "/:realm/realm-settings/client-policies/:policyName/edit-policy/:conditionName/edit-condition",
element: <NewClientPolicyCondition />, element: <NewClientPolicyCondition />,
breadcrumb: (t) => t("realm-settings:editCondition"), breadcrumb: (t) => t("realm-settings:editCondition"),
access: "manage-clients", handle: {
access: "manage-clients",
},
}; };
export const toEditClientPolicyCondition = ( export const toEditClientPolicyCondition = (

View file

@ -15,7 +15,9 @@ export const ExecutorRoute: RouteDef = {
path: "/:realm/realm-settings/client-policies/:profileName/edit-profile/:executorName", path: "/:realm/realm-settings/client-policies/:profileName/edit-profile/:executorName",
element: <ExecutorForm />, element: <ExecutorForm />,
breadcrumb: (t) => t("realm-settings:executorDetails"), breadcrumb: (t) => t("realm-settings:executorDetails"),
access: ["manage-realm"], handle: {
access: ["manage-realm"],
},
}; };
export const toExecutor = (params: ExecutorParams): Partial<Path> => ({ export const toExecutor = (params: ExecutorParams): Partial<Path> => ({

View file

@ -27,7 +27,9 @@ export const KeyProviderFormRoute: RouteDef = {
path: "/:realm/realm-settings/keys/providers/:id/:providerType/settings", path: "/:realm/realm-settings/keys/providers/:id/:providerType/settings",
element: <KeyProviderForm />, element: <KeyProviderForm />,
breadcrumb: (t) => t("realm-settings:editProvider"), breadcrumb: (t) => t("realm-settings:editProvider"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toKeyProvider = (params: KeyProviderParams): Partial<Path> => ({ export const toKeyProvider = (params: KeyProviderParams): Partial<Path> => ({

View file

@ -16,7 +16,9 @@ export const KeysRoute: RouteDef = {
path: "/:realm/realm-settings/keys/:tab", path: "/:realm/realm-settings/keys/:tab",
element: <RealmSettingsSection />, element: <RealmSettingsSection />,
breadcrumb: (t) => t("realm-settings:keys"), breadcrumb: (t) => t("realm-settings:keys"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toKeysTab = (params: KeysParams): Partial<Path> => ({ export const toKeysTab = (params: KeysParams): Partial<Path> => ({

View file

@ -15,7 +15,9 @@ export const NewAttributesGroupRoute: RouteDef = {
path: "/:realm/realm-settings/user-profile/attributesGroup/new", path: "/:realm/realm-settings/user-profile/attributesGroup/new",
element: <AttributesGroupDetails />, element: <AttributesGroupDetails />,
breadcrumb: (t) => t("realm-settings:createGroupText"), breadcrumb: (t) => t("realm-settings:createGroupText"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toNewAttributesGroup = ( export const toNewAttributesGroup = (

View file

@ -29,7 +29,9 @@ export const RealmSettingsRoute: RouteDef = {
path: "/:realm/realm-settings", path: "/:realm/realm-settings",
element: <RealmSettingsSection />, element: <RealmSettingsSection />,
breadcrumb: (t) => t("realmSettings"), breadcrumb: (t) => t("realmSettings"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const RealmSettingsRouteWithTab: RouteDef = { export const RealmSettingsRouteWithTab: RouteDef = {

View file

@ -16,7 +16,9 @@ export const UserProfileRoute: RouteDef = {
path: "/:realm/realm-settings/user-profile/:tab", path: "/:realm/realm-settings/user-profile/:tab",
element: <RealmSettingsSection />, element: <RealmSettingsSection />,
breadcrumb: (t) => t("realm-settings:userProfile"), breadcrumb: (t) => t("realm-settings:userProfile"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toUserProfile = (params: UserProfileParams): Partial<Path> => ({ export const toUserProfile = (params: UserProfileParams): Partial<Path> => ({

View file

@ -11,7 +11,9 @@ export const AddRealmRoute: RouteDef = {
path: "/:realm/add-realm", path: "/:realm/add-realm",
element: <NewRealmForm />, element: <NewRealmForm />,
breadcrumb: (t) => t("realm:createRealm"), breadcrumb: (t) => t("realm:createRealm"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toAddRealm = (params: AddRealmParams): Partial<Path> => ({ export const toAddRealm = (params: AddRealmParams): Partial<Path> => ({

View file

@ -18,16 +18,22 @@ import sessionRoutes from "./sessions/routes";
import userFederationRoutes from "./user-federation/routes"; import userFederationRoutes from "./user-federation/routes";
import userRoutes from "./user/routes"; import userRoutes from "./user/routes";
export type RouteObjectHandle = {
access: AccessType | AccessType[];
};
export type RouteDef = Required<Pick<RouteObject, "element">> & { export type RouteDef = Required<Pick<RouteObject, "element">> & {
path: string; path: string;
breadcrumb?: (t: TFunction) => string | ComponentType<any>; breadcrumb?: (t: TFunction) => string | ComponentType<any>;
access: AccessType | AccessType[]; handle: RouteObjectHandle;
}; };
const NotFoundRoute: RouteDef = { const NotFoundRoute: RouteDef = {
path: "*", path: "*",
element: <PageNotFoundSection />, element: <PageNotFoundSection />,
access: "anyone", handle: {
access: "anyone",
},
}; };
export const routes: RouteDef[] = [ export const routes: RouteDef[] = [

View file

@ -11,7 +11,9 @@ export const SessionsRoute: RouteDef = {
path: "/:realm/sessions", path: "/:realm/sessions",
element: <SessionsSection />, element: <SessionsSection />,
breadcrumb: (t) => t("sessions:title"), 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> => ({ export const toSessions = (params: SessionsParams): Partial<Path> => ({

View file

@ -18,7 +18,9 @@ export const CustomUserFederationRoute: RouteDef = {
path: "/:realm/user-federation/:providerId/:id", path: "/:realm/user-federation/:providerId/:id",
element: <CustomProviderSettings />, element: <CustomProviderSettings />,
breadcrumb: (t) => t("user-federation:providerDetails"), breadcrumb: (t) => t("user-federation:providerDetails"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toCustomUserFederation = ( export const toCustomUserFederation = (

View file

@ -17,7 +17,9 @@ export const NewCustomUserFederationRoute: RouteDef = {
path: "/:realm/user-federation/:providerId/new", path: "/:realm/user-federation/:providerId/new",
element: <CustomProviderSettings />, element: <CustomProviderSettings />,
breadcrumb: (t) => t("user-federation:addCustomProvider"), breadcrumb: (t) => t("user-federation:addCustomProvider"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toNewCustomUserFederation = ( export const toNewCustomUserFederation = (

View file

@ -13,7 +13,9 @@ export const NewKerberosUserFederationRoute: RouteDef = {
path: "/:realm/user-federation/kerberos/new", path: "/:realm/user-federation/kerberos/new",
element: <UserFederationKerberosSettings />, element: <UserFederationKerberosSettings />,
breadcrumb: (t) => t("common:settings"), breadcrumb: (t) => t("common:settings"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toNewKerberosUserFederation = ( export const toNewKerberosUserFederation = (

View file

@ -14,7 +14,9 @@ export const NewLdapUserFederationRoute: RouteDef = {
element: <CreateUserFederationLdapSettings />, element: <CreateUserFederationLdapSettings />,
breadcrumb: (t) => breadcrumb: (t) =>
t("user-federation:addProvider", { provider: "LDAP", count: 1 }), t("user-federation:addProvider", { provider: "LDAP", count: 1 }),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toNewLdapUserFederation = ( export const toNewLdapUserFederation = (

View file

@ -11,7 +11,9 @@ export const UserFederationRoute: RouteDef = {
path: "/:realm/user-federation", path: "/:realm/user-federation",
element: <UserFederationSection />, element: <UserFederationSection />,
breadcrumb: (t) => t("userFederation"), breadcrumb: (t) => t("userFederation"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toUserFederation = ( export const toUserFederation = (

View file

@ -16,7 +16,9 @@ export const UserFederationKerberosRoute: RouteDef = {
path: "/:realm/user-federation/kerberos/:id", path: "/:realm/user-federation/kerberos/:id",
element: <UserFederationKerberosSettings />, element: <UserFederationKerberosSettings />,
breadcrumb: (t) => t("common:settings"), breadcrumb: (t) => t("common:settings"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toUserFederationKerberos = ( export const toUserFederationKerberos = (

View file

@ -19,7 +19,9 @@ export const UserFederationLdapRoute: RouteDef = {
path: "/:realm/user-federation/ldap/:id", path: "/:realm/user-federation/ldap/:id",
element: <UserFederationLdapSettings />, element: <UserFederationLdapSettings />,
breadcrumb: (t) => t("common:settings"), breadcrumb: (t) => t("common:settings"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const UserFederationLdapWithTabRoute: RouteDef = { export const UserFederationLdapWithTabRoute: RouteDef = {

View file

@ -17,7 +17,9 @@ export const UserFederationLdapMapperRoute: RouteDef = {
path: "/:realm/user-federation/ldap/:id/mappers/:mapperId", path: "/:realm/user-federation/ldap/:id/mappers/:mapperId",
element: <LdapMapperDetails />, element: <LdapMapperDetails />,
breadcrumb: (t) => t("common:mappingDetails"), breadcrumb: (t) => t("common:mappingDetails"),
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toUserFederationLdapMapper = ( export const toUserFederationLdapMapper = (

View file

@ -10,7 +10,9 @@ const UserFederationSection = lazy(() => import("../UserFederationSection"));
export const UserFederationsKerberosRoute: RouteDef = { export const UserFederationsKerberosRoute: RouteDef = {
path: "/:realm/user-federation/kerberos", path: "/:realm/user-federation/kerberos",
element: <UserFederationSection />, element: <UserFederationSection />,
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toUserFederationsKerberos = ( export const toUserFederationsKerberos = (

View file

@ -10,7 +10,9 @@ const UserFederationSection = lazy(() => import("../UserFederationSection"));
export const UserFederationsLdapRoute: RouteDef = { export const UserFederationsLdapRoute: RouteDef = {
path: "/:realm/user-federation/ldap", path: "/:realm/user-federation/ldap",
element: <UserFederationSection />, element: <UserFederationSection />,
access: "view-realm", handle: {
access: "view-realm",
},
}; };
export const toUserFederationsLdap = ( export const toUserFederationsLdap = (

View file

@ -12,7 +12,9 @@ export const AddUserRoute: RouteDef = {
path: "/:realm/users/add-user", path: "/:realm/users/add-user",
element: <CreateUser />, element: <CreateUser />,
breadcrumb: (t) => t("users:createUser"), breadcrumb: (t) => t("users:createUser"),
access: ["query-users", "query-groups"], handle: {
access: ["query-users", "query-groups"],
},
}; };
export const toAddUser = (params: AddUserParams): Partial<Path> => ({ export const toAddUser = (params: AddUserParams): Partial<Path> => ({

View file

@ -25,7 +25,9 @@ export const UserRoute: RouteDef = {
path: "/:realm/users/:id/:tab", path: "/:realm/users/:id/:tab",
element: <EditUser />, element: <EditUser />,
breadcrumb: (t) => t("users:userDetails"), breadcrumb: (t) => t("users:userDetails"),
access: "query-users", handle: {
access: "query-users",
},
}; };
export const toUser = (params: UserParams): Partial<Path> => ({ export const toUser = (params: UserParams): Partial<Path> => ({

View file

@ -13,7 +13,9 @@ export const UsersRoute: RouteDef = {
path: "/:realm/users", path: "/:realm/users",
element: <UsersSection />, element: <UsersSection />,
breadcrumb: (t) => t("users:title"), breadcrumb: (t) => t("users:title"),
access: "query-users", handle: {
access: "query-users",
},
}; };
export const UsersRouteWithTab: RouteDef = { export const UsersRouteWithTab: RouteDef = {