cartography 0.110.0rc2__py3-none-any.whl → 0.111.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cartography might be problematic. Click here for more details.

Files changed (54) hide show
  1. cartography/_version.py +16 -3
  2. cartography/cli.py +46 -0
  3. cartography/config.py +16 -0
  4. cartography/data/indexes.cypher +0 -2
  5. cartography/data/jobs/analysis/keycloak_inheritance.json +30 -0
  6. cartography/graph/querybuilder.py +70 -0
  7. cartography/intel/aws/apigateway.py +113 -4
  8. cartography/intel/aws/ec2/vpc.py +140 -124
  9. cartography/intel/aws/eventbridge.py +73 -0
  10. cartography/intel/github/repos.py +28 -12
  11. cartography/intel/github/util.py +12 -0
  12. cartography/intel/keycloak/__init__.py +153 -0
  13. cartography/intel/keycloak/authenticationexecutions.py +322 -0
  14. cartography/intel/keycloak/authenticationflows.py +77 -0
  15. cartography/intel/keycloak/clients.py +187 -0
  16. cartography/intel/keycloak/groups.py +126 -0
  17. cartography/intel/keycloak/identityproviders.py +94 -0
  18. cartography/intel/keycloak/organizations.py +163 -0
  19. cartography/intel/keycloak/realms.py +61 -0
  20. cartography/intel/keycloak/roles.py +202 -0
  21. cartography/intel/keycloak/scopes.py +73 -0
  22. cartography/intel/keycloak/users.py +70 -0
  23. cartography/intel/keycloak/util.py +47 -0
  24. cartography/models/aws/apigateway/apigatewaydeployment.py +74 -0
  25. cartography/models/aws/ec2/vpc.py +46 -0
  26. cartography/models/aws/ec2/vpc_cidr.py +102 -0
  27. cartography/models/aws/eventbridge/target.py +71 -0
  28. cartography/models/keycloak/__init__.py +0 -0
  29. cartography/models/keycloak/authenticationexecution.py +160 -0
  30. cartography/models/keycloak/authenticationflow.py +54 -0
  31. cartography/models/keycloak/client.py +177 -0
  32. cartography/models/keycloak/group.py +101 -0
  33. cartography/models/keycloak/identityprovider.py +89 -0
  34. cartography/models/keycloak/organization.py +116 -0
  35. cartography/models/keycloak/organizationdomain.py +73 -0
  36. cartography/models/keycloak/realm.py +173 -0
  37. cartography/models/keycloak/role.py +126 -0
  38. cartography/models/keycloak/scope.py +73 -0
  39. cartography/models/keycloak/user.py +51 -0
  40. cartography/models/tailscale/device.py +1 -0
  41. cartography/sync.py +2 -0
  42. cartography/util.py +8 -0
  43. {cartography-0.110.0rc2.dist-info → cartography-0.111.0.dist-info}/METADATA +2 -1
  44. {cartography-0.110.0rc2.dist-info → cartography-0.111.0.dist-info}/RECORD +53 -25
  45. cartography/data/jobs/cleanup/aws_import_vpc_cleanup.json +0 -23
  46. /cartography/models/aws/{__init__.py → apigateway/__init__.py} +0 -0
  47. /cartography/models/aws/{apigateway.py → apigateway/apigateway.py} +0 -0
  48. /cartography/models/aws/{apigatewaycertificate.py → apigateway/apigatewaycertificate.py} +0 -0
  49. /cartography/models/aws/{apigatewayresource.py → apigateway/apigatewayresource.py} +0 -0
  50. /cartography/models/aws/{apigatewaystage.py → apigateway/apigatewaystage.py} +0 -0
  51. {cartography-0.110.0rc2.dist-info → cartography-0.111.0.dist-info}/WHEEL +0 -0
  52. {cartography-0.110.0rc2.dist-info → cartography-0.111.0.dist-info}/entry_points.txt +0 -0
  53. {cartography-0.110.0rc2.dist-info → cartography-0.111.0.dist-info}/licenses/LICENSE +0 -0
  54. {cartography-0.110.0rc2.dist-info → cartography-0.111.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,177 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.nodes import CartographyNodeProperties
5
+ from cartography.models.core.nodes import CartographyNodeSchema
6
+ from cartography.models.core.relationships import CartographyRelProperties
7
+ from cartography.models.core.relationships import CartographyRelSchema
8
+ from cartography.models.core.relationships import LinkDirection
9
+ from cartography.models.core.relationships import make_source_node_matcher
10
+ from cartography.models.core.relationships import make_target_node_matcher
11
+ from cartography.models.core.relationships import OtherRelationships
12
+ from cartography.models.core.relationships import SourceNodeMatcher
13
+ from cartography.models.core.relationships import TargetNodeMatcher
14
+
15
+
16
+ @dataclass(frozen=True)
17
+ class KeycloakClientNodeProperties(CartographyNodeProperties):
18
+ id: PropertyRef = PropertyRef("id")
19
+ client_id: PropertyRef = PropertyRef("clientId")
20
+ name: PropertyRef = PropertyRef("name")
21
+ description: PropertyRef = PropertyRef("description")
22
+ type: PropertyRef = PropertyRef("type")
23
+ root_url: PropertyRef = PropertyRef("rootUrl")
24
+ admin_url: PropertyRef = PropertyRef("adminUrl")
25
+ base_url: PropertyRef = PropertyRef("baseUrl")
26
+ surrogate_auth_required: PropertyRef = PropertyRef("surrogateAuthRequired")
27
+ enabled: PropertyRef = PropertyRef("enabled")
28
+ always_display_in_console: PropertyRef = PropertyRef("alwaysDisplayInConsole")
29
+ client_authenticator_type: PropertyRef = PropertyRef("clientAuthenticatorType")
30
+ registration_access_token: PropertyRef = PropertyRef("registrationAccessToken")
31
+ not_before: PropertyRef = PropertyRef("notBefore")
32
+ bearer_only: PropertyRef = PropertyRef("bearerOnly")
33
+ consent_required: PropertyRef = PropertyRef("consentRequired")
34
+ standard_flow_enabled: PropertyRef = PropertyRef("standardFlowEnabled")
35
+ implicit_flow_enabled: PropertyRef = PropertyRef("implicitFlowEnabled")
36
+ direct_access_grants_enabled: PropertyRef = PropertyRef("directAccessGrantsEnabled")
37
+ service_accounts_enabled: PropertyRef = PropertyRef("serviceAccountsEnabled")
38
+ authorization_services_enabled: PropertyRef = PropertyRef(
39
+ "authorizationServicesEnabled"
40
+ )
41
+ direct_grants_only: PropertyRef = PropertyRef("directGrantsOnly")
42
+ public_client: PropertyRef = PropertyRef("publicClient")
43
+ frontchannel_logout: PropertyRef = PropertyRef("frontchannelLogout")
44
+ protocol: PropertyRef = PropertyRef("protocol")
45
+ full_scope_allowed: PropertyRef = PropertyRef("fullScopeAllowed")
46
+ node_re_registration_timeout: PropertyRef = PropertyRef("nodeReRegistrationTimeout")
47
+ client_template: PropertyRef = PropertyRef("clientTemplate")
48
+ use_template_config: PropertyRef = PropertyRef("useTemplateConfig")
49
+ use_template_scope: PropertyRef = PropertyRef("useTemplateScope")
50
+ use_template_mappers: PropertyRef = PropertyRef("useTemplateMappers")
51
+ origin: PropertyRef = PropertyRef("origin")
52
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
53
+
54
+
55
+ @dataclass(frozen=True)
56
+ class KeycloakClientToRealmRelProperties(CartographyRelProperties):
57
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
58
+
59
+
60
+ @dataclass(frozen=True)
61
+ # (:KeycloakClient)<-[:RESOURCE]-(:KeycloakRealm)
62
+ class KeycloakClientToRealmRel(CartographyRelSchema):
63
+ target_node_label: str = "KeycloakRealm"
64
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
65
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
66
+ )
67
+ direction: LinkDirection = LinkDirection.INWARD
68
+ rel_label: str = "RESOURCE"
69
+ properties: KeycloakClientToRealmRelProperties = (
70
+ KeycloakClientToRealmRelProperties()
71
+ )
72
+
73
+
74
+ @dataclass(frozen=True)
75
+ class KeycloakClientToDefaultScopeRelProperties(CartographyRelProperties):
76
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
77
+
78
+
79
+ @dataclass(frozen=True)
80
+ # (:KeycloakClient)-[:HAS_DEFAULT_SCOPE]->(:KeycloakScope)
81
+ class KeycloakClientToDefaultScopeRel(CartographyRelSchema):
82
+ target_node_label: str = "KeycloakScope"
83
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
84
+ {
85
+ "name": PropertyRef("defaultClientScopes", one_to_many=True),
86
+ "realm": PropertyRef("REALM", set_in_kwargs=True),
87
+ },
88
+ )
89
+ direction: LinkDirection = LinkDirection.OUTWARD
90
+ rel_label: str = "HAS_DEFAULT_SCOPE"
91
+ properties: KeycloakClientToDefaultScopeRelProperties = (
92
+ KeycloakClientToDefaultScopeRelProperties()
93
+ )
94
+
95
+
96
+ @dataclass(frozen=True)
97
+ class KeycloakClientToOptionalScopeRelProperties(CartographyRelProperties):
98
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
99
+
100
+
101
+ @dataclass(frozen=True)
102
+ # (:KeycloakClient)-[:HAS_OPTIONAL_SCOPE]->(:KeycloakScope)
103
+ class KeycloakClientToOptionalScopeRel(CartographyRelSchema):
104
+ target_node_label: str = "KeycloakScope"
105
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
106
+ {
107
+ "name": PropertyRef("optionalClientScopes", one_to_many=True),
108
+ "realm": PropertyRef("REALM", set_in_kwargs=True),
109
+ },
110
+ )
111
+ direction: LinkDirection = LinkDirection.OUTWARD
112
+ rel_label: str = "HAS_OPTIONAL_SCOPE"
113
+ properties: KeycloakClientToOptionalScopeRelProperties = (
114
+ KeycloakClientToOptionalScopeRelProperties()
115
+ )
116
+
117
+
118
+ @dataclass(frozen=True)
119
+ class KeycloakClientToServiceAccountRelProperties(CartographyRelProperties):
120
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
121
+
122
+
123
+ @dataclass(frozen=True)
124
+ # (:KeycloakClient)-[:HAS_SERVICE_ACCOUNT]->(:KeycloakUser)
125
+ class KeycloakClientToServiceAccountRel(CartographyRelSchema):
126
+ target_node_label: str = "KeycloakUser"
127
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
128
+ {"id": PropertyRef("_service_account_user_id")},
129
+ )
130
+ direction: LinkDirection = LinkDirection.OUTWARD
131
+ rel_label: str = "HAS_SERVICE_ACCOUNT"
132
+ properties: KeycloakClientToServiceAccountRelProperties = (
133
+ KeycloakClientToServiceAccountRelProperties()
134
+ )
135
+
136
+
137
+ @dataclass(frozen=True)
138
+ class KeycloakClientSchema(CartographyNodeSchema):
139
+ label: str = "KeycloakClient"
140
+ properties: KeycloakClientNodeProperties = KeycloakClientNodeProperties()
141
+ sub_resource_relationship: KeycloakClientToRealmRel = KeycloakClientToRealmRel()
142
+ other_relationships: OtherRelationships = OtherRelationships(
143
+ [
144
+ KeycloakClientToDefaultScopeRel(),
145
+ KeycloakClientToOptionalScopeRel(),
146
+ KeycloakClientToServiceAccountRel(),
147
+ ]
148
+ )
149
+
150
+
151
+ # The following relationships are MatchLinks to enable batch loading with rel properties
152
+ @dataclass(frozen=True)
153
+ class KeycloakClientToFlowRelProperties(CartographyRelProperties):
154
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
155
+ flow_name: PropertyRef = PropertyRef("flow_name")
156
+ default_flow: PropertyRef = PropertyRef("default_flow")
157
+ # Mandatory fields for MatchLinks
158
+ _sub_resource_label: PropertyRef = PropertyRef(
159
+ "_sub_resource_label", set_in_kwargs=True
160
+ )
161
+ _sub_resource_id: PropertyRef = PropertyRef("_sub_resource_id", set_in_kwargs=True)
162
+
163
+
164
+ @dataclass(frozen=True)
165
+ # (:KeycloakClient)-[:USES]->(:KeycloakAuthenticationFlow)
166
+ class KeycloakClientToFlowMatchLink(CartographyRelSchema):
167
+ source_node_label: str = "KeycloakClient"
168
+ source_node_matcher: SourceNodeMatcher = make_source_node_matcher(
169
+ {"id": PropertyRef("client_id")},
170
+ )
171
+ target_node_label: str = "KeycloakAuthenticationFlow"
172
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
173
+ {"id": PropertyRef("flow_id")},
174
+ )
175
+ direction: LinkDirection = LinkDirection.OUTWARD
176
+ rel_label: str = "USES"
177
+ properties: KeycloakClientToFlowRelProperties = KeycloakClientToFlowRelProperties()
@@ -0,0 +1,101 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.nodes import CartographyNodeProperties
5
+ from cartography.models.core.nodes import CartographyNodeSchema
6
+ from cartography.models.core.relationships import CartographyRelProperties
7
+ from cartography.models.core.relationships import CartographyRelSchema
8
+ from cartography.models.core.relationships import LinkDirection
9
+ from cartography.models.core.relationships import make_target_node_matcher
10
+ from cartography.models.core.relationships import OtherRelationships
11
+ from cartography.models.core.relationships import TargetNodeMatcher
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class KeycloakGroupNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("id")
17
+ name: PropertyRef = PropertyRef("name")
18
+ description: PropertyRef = PropertyRef("description")
19
+ path: PropertyRef = PropertyRef("path")
20
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
21
+
22
+
23
+ @dataclass(frozen=True)
24
+ class KeycloakGroupToRealmRelProperties(CartographyRelProperties):
25
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
26
+
27
+
28
+ @dataclass(frozen=True)
29
+ # (:KeycloakGroup)<-[:RESOURCE]-(:KeycloakRealm)
30
+ class KeycloakGroupToRealmRel(CartographyRelSchema):
31
+ target_node_label: str = "KeycloakRealm"
32
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
33
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
34
+ )
35
+ direction: LinkDirection = LinkDirection.INWARD
36
+ rel_label: str = "RESOURCE"
37
+ properties: KeycloakGroupToRealmRelProperties = KeycloakGroupToRealmRelProperties()
38
+
39
+
40
+ @dataclass(frozen=True)
41
+ class KeycloakGroupToGroupRelProperties(CartographyRelProperties):
42
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
43
+
44
+
45
+ @dataclass(frozen=True)
46
+ # (:KeycloakGroup)-[:SUBGROUP_OF]->(:KeycloakGroup)
47
+ class KeycloakGroupToGroupRel(CartographyRelSchema):
48
+ target_node_label: str = "KeycloakGroup"
49
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
50
+ {"id": PropertyRef("parentId")},
51
+ )
52
+ direction: LinkDirection = LinkDirection.OUTWARD
53
+ rel_label: str = "SUBGROUP_OF"
54
+ properties: KeycloakGroupToGroupRelProperties = KeycloakGroupToGroupRelProperties()
55
+
56
+
57
+ @dataclass(frozen=True)
58
+ class KeycloakGroupToUserRelProperties(CartographyRelProperties):
59
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
60
+
61
+
62
+ @dataclass(frozen=True)
63
+ # (:KeycloakGroup)<-[:MEMBER_OF]-(:KeycloakUser)
64
+ class KeycloakGroupToUserRel(CartographyRelSchema):
65
+ target_node_label: str = "KeycloakUser"
66
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
67
+ {"id": PropertyRef("_member_ids", one_to_many=True)},
68
+ )
69
+ direction: LinkDirection = LinkDirection.INWARD
70
+ rel_label: str = "MEMBER_OF"
71
+ properties: KeycloakGroupToUserRelProperties = KeycloakGroupToUserRelProperties()
72
+
73
+
74
+ @dataclass(frozen=True)
75
+ class KeycloakGroupToRoleRelProperties(CartographyRelProperties):
76
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
77
+
78
+
79
+ @dataclass(frozen=True)
80
+ # (:KeycloakGroup)-[:GRANTS]->(:KeycloakRole)
81
+ class KeycloakGroupToRoleRel(CartographyRelSchema):
82
+ target_node_label: str = "KeycloakRole"
83
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
84
+ {
85
+ "name": PropertyRef("_roles", one_to_many=True),
86
+ "realm": PropertyRef("REALM", set_in_kwargs=True),
87
+ },
88
+ )
89
+ direction: LinkDirection = LinkDirection.OUTWARD
90
+ rel_label: str = "GRANTS"
91
+ properties: KeycloakGroupToRoleRelProperties = KeycloakGroupToRoleRelProperties()
92
+
93
+
94
+ @dataclass(frozen=True)
95
+ class KeycloakGroupSchema(CartographyNodeSchema):
96
+ label: str = "KeycloakGroup"
97
+ properties: KeycloakGroupNodeProperties = KeycloakGroupNodeProperties()
98
+ sub_resource_relationship: KeycloakGroupToRealmRel = KeycloakGroupToRealmRel()
99
+ other_relationships: OtherRelationships = OtherRelationships(
100
+ [KeycloakGroupToGroupRel(), KeycloakGroupToUserRel(), KeycloakGroupToRoleRel()]
101
+ )
@@ -0,0 +1,89 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.nodes import CartographyNodeProperties
5
+ from cartography.models.core.nodes import CartographyNodeSchema
6
+ from cartography.models.core.relationships import CartographyRelProperties
7
+ from cartography.models.core.relationships import CartographyRelSchema
8
+ from cartography.models.core.relationships import LinkDirection
9
+ from cartography.models.core.relationships import make_target_node_matcher
10
+ from cartography.models.core.relationships import OtherRelationships
11
+ from cartography.models.core.relationships import TargetNodeMatcher
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class KeycloakIdentityProviderNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("internalId")
17
+ alias: PropertyRef = PropertyRef("alias", extra_index=True)
18
+ display_name: PropertyRef = PropertyRef("displayName")
19
+ provider_id: PropertyRef = PropertyRef("providerId")
20
+ enabled: PropertyRef = PropertyRef("enabled")
21
+ update_profile_first_login_mode: PropertyRef = PropertyRef(
22
+ "updateProfileFirstLoginMode"
23
+ )
24
+ trust_email: PropertyRef = PropertyRef("trustEmail")
25
+ store_token: PropertyRef = PropertyRef("storeToken")
26
+ add_read_token_role_on_create: PropertyRef = PropertyRef("addReadTokenRoleOnCreate")
27
+ authenticate_by_default: PropertyRef = PropertyRef("authenticateByDefault")
28
+ link_only: PropertyRef = PropertyRef("linkOnly")
29
+ hide_on_login: PropertyRef = PropertyRef("hideOnLogin")
30
+ first_broker_login_flow_alias: PropertyRef = PropertyRef(
31
+ "firstBrokerLoginFlowAlias"
32
+ )
33
+ post_broker_login_flow_alias: PropertyRef = PropertyRef("postBrokerLoginFlowAlias")
34
+ organization_id: PropertyRef = PropertyRef("organizationId")
35
+ update_profile_first_login: PropertyRef = PropertyRef("updateProfileFirstLogin")
36
+ config_sync_mode: PropertyRef = PropertyRef("config.syncMode")
37
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
38
+
39
+
40
+ @dataclass(frozen=True)
41
+ class KeycloakIdentityProviderToRealmRelProperties(CartographyRelProperties):
42
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
43
+
44
+
45
+ @dataclass(frozen=True)
46
+ # (:KeycloakIdentityProvider)<-[:RESOURCE]-(:KeycloakRealm)
47
+ class KeycloakIdentityProviderToRealmRel(CartographyRelSchema):
48
+ target_node_label: str = "KeycloakRealm"
49
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
50
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
51
+ )
52
+ direction: LinkDirection = LinkDirection.INWARD
53
+ rel_label: str = "RESOURCE"
54
+ properties: KeycloakIdentityProviderToRealmRelProperties = (
55
+ KeycloakIdentityProviderToRealmRelProperties()
56
+ )
57
+
58
+
59
+ @dataclass(frozen=True)
60
+ class KeycloakIdentityProviderToUserRelProperties(CartographyRelProperties):
61
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
62
+
63
+
64
+ @dataclass(frozen=True)
65
+ # (:KeycloakIdentityProvider)<-[:HAS_IDENTITY]-(:KeycloakUser)
66
+ class KeycloakIdentityProviderToUserRel(CartographyRelSchema):
67
+ target_node_label: str = "KeycloakUser"
68
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
69
+ {"id": PropertyRef("_member_ids", one_to_many=True)},
70
+ )
71
+ direction: LinkDirection = LinkDirection.INWARD
72
+ rel_label: str = "HAS_IDENTITY"
73
+ properties: KeycloakIdentityProviderToUserRelProperties = (
74
+ KeycloakIdentityProviderToUserRelProperties()
75
+ )
76
+
77
+
78
+ @dataclass(frozen=True)
79
+ class KeycloakIdentityProviderSchema(CartographyNodeSchema):
80
+ label: str = "KeycloakIdentityProvider"
81
+ properties: KeycloakIdentityProviderNodeProperties = (
82
+ KeycloakIdentityProviderNodeProperties()
83
+ )
84
+ sub_resource_relationship: KeycloakIdentityProviderToRealmRel = (
85
+ KeycloakIdentityProviderToRealmRel()
86
+ )
87
+ other_relationships: OtherRelationships = OtherRelationships(
88
+ [KeycloakIdentityProviderToUserRel()],
89
+ )
@@ -0,0 +1,116 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.nodes import CartographyNodeProperties
5
+ from cartography.models.core.nodes import CartographyNodeSchema
6
+ from cartography.models.core.relationships import CartographyRelProperties
7
+ from cartography.models.core.relationships import CartographyRelSchema
8
+ from cartography.models.core.relationships import LinkDirection
9
+ from cartography.models.core.relationships import make_target_node_matcher
10
+ from cartography.models.core.relationships import OtherRelationships
11
+ from cartography.models.core.relationships import TargetNodeMatcher
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class KeycloakOrganizationNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("id")
17
+ name: PropertyRef = PropertyRef("name")
18
+ alias: PropertyRef = PropertyRef("alias")
19
+ enabled: PropertyRef = PropertyRef("enabled")
20
+ description: PropertyRef = PropertyRef("description")
21
+ redirect_url: PropertyRef = PropertyRef("redirectUrl")
22
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
23
+
24
+
25
+ @dataclass(frozen=True)
26
+ class KeycloakOrganizationToRealmRelProperties(CartographyRelProperties):
27
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
28
+
29
+
30
+ @dataclass(frozen=True)
31
+ # (:KeycloakOrganization)<-[:RESOURCE]-(:KeycloakRealm)
32
+ class KeycloakOrganizationToRealmRel(CartographyRelSchema):
33
+ target_node_label: str = "KeycloakRealm"
34
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
35
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
36
+ )
37
+ direction: LinkDirection = LinkDirection.INWARD
38
+ rel_label: str = "RESOURCE"
39
+ properties: KeycloakOrganizationToRealmRelProperties = (
40
+ KeycloakOrganizationToRealmRelProperties()
41
+ )
42
+
43
+
44
+ @dataclass(frozen=True)
45
+ class KeycloakOrganizationToManagedUserRelProperties(CartographyRelProperties):
46
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
47
+
48
+
49
+ @dataclass(frozen=True)
50
+ # (:KeycloakOrganization)<-[:MANAGED_MEMBER_OF]-(:KeycloakUser)
51
+ class KeycloakOrganizationToManagedUserRel(CartographyRelSchema):
52
+ target_node_label: str = "KeycloakUser"
53
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
54
+ {"id": PropertyRef("_managed_members", one_to_many=True)},
55
+ )
56
+ direction: LinkDirection = LinkDirection.INWARD
57
+ rel_label: str = "MANAGED_MEMBER_OF"
58
+ properties: KeycloakOrganizationToManagedUserRelProperties = (
59
+ KeycloakOrganizationToManagedUserRelProperties()
60
+ )
61
+
62
+
63
+ @dataclass(frozen=True)
64
+ class KeycloakOrganizationToUnmanagedUserRelProperties(CartographyRelProperties):
65
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
66
+
67
+
68
+ @dataclass(frozen=True)
69
+ # (:KeycloakOrganization)<-[:UNMANAGED_MEMBER_OF]-(:KeycloakUser)
70
+ class KeycloakOrganizationToUnmanagedUserRel(CartographyRelSchema):
71
+ target_node_label: str = "KeycloakUser"
72
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
73
+ {"id": PropertyRef("_unmanaged_members", one_to_many=True)},
74
+ )
75
+ direction: LinkDirection = LinkDirection.INWARD
76
+ rel_label: str = "UNMANAGED_MEMBER_OF"
77
+ properties: KeycloakOrganizationToUnmanagedUserRelProperties = (
78
+ KeycloakOrganizationToUnmanagedUserRelProperties()
79
+ )
80
+
81
+
82
+ @dataclass(frozen=True)
83
+ class KeycloakOrganizationToIdentityProviderRelProperties(CartographyRelProperties):
84
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
85
+
86
+
87
+ @dataclass(frozen=True)
88
+ # (:KeycloakOrganization)-[:ENFORCES]->(:KeycloakIdentityProvider)
89
+ class KeycloakOrganizationToIdentityProviderRel(CartographyRelSchema):
90
+ target_node_label: str = "KeycloakIdentityProvider"
91
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
92
+ {"id": PropertyRef("_idp_ids", one_to_many=True)},
93
+ )
94
+ direction: LinkDirection = LinkDirection.OUTWARD
95
+ rel_label: str = "ENFORCES"
96
+ properties: KeycloakOrganizationToIdentityProviderRelProperties = (
97
+ KeycloakOrganizationToIdentityProviderRelProperties()
98
+ )
99
+
100
+
101
+ @dataclass(frozen=True)
102
+ class KeycloakOrganizationSchema(CartographyNodeSchema):
103
+ label: str = "KeycloakOrganization"
104
+ properties: KeycloakOrganizationNodeProperties = (
105
+ KeycloakOrganizationNodeProperties()
106
+ )
107
+ sub_resource_relationship: KeycloakOrganizationToRealmRel = (
108
+ KeycloakOrganizationToRealmRel()
109
+ )
110
+ other_relationships: OtherRelationships = OtherRelationships(
111
+ [
112
+ KeycloakOrganizationToManagedUserRel(),
113
+ KeycloakOrganizationToUnmanagedUserRel(),
114
+ KeycloakOrganizationToIdentityProviderRel(),
115
+ ]
116
+ )
@@ -0,0 +1,73 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.nodes import CartographyNodeProperties
5
+ from cartography.models.core.nodes import CartographyNodeSchema
6
+ from cartography.models.core.relationships import CartographyRelProperties
7
+ from cartography.models.core.relationships import CartographyRelSchema
8
+ from cartography.models.core.relationships import LinkDirection
9
+ from cartography.models.core.relationships import make_target_node_matcher
10
+ from cartography.models.core.relationships import OtherRelationships
11
+ from cartography.models.core.relationships import TargetNodeMatcher
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class KeycloakOrganizationDomainNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("id")
17
+ name: PropertyRef = PropertyRef("name", extra_index=True)
18
+ verified: PropertyRef = PropertyRef("verified")
19
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
20
+
21
+
22
+ @dataclass(frozen=True)
23
+ class KeycloakOrganizationDomainToRealmRelProperties(CartographyRelProperties):
24
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
25
+
26
+
27
+ @dataclass(frozen=True)
28
+ # (:KeycloakOrganizationDomain)<-[:RESOURCE]-(:KeycloakRealm)
29
+ class KeycloakOrganizationDomainToRealmRel(CartographyRelSchema):
30
+ target_node_label: str = "KeycloakRealm"
31
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
32
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
33
+ )
34
+ direction: LinkDirection = LinkDirection.INWARD
35
+ rel_label: str = "RESOURCE"
36
+ properties: KeycloakOrganizationDomainToRealmRelProperties = (
37
+ KeycloakOrganizationDomainToRealmRelProperties()
38
+ )
39
+
40
+
41
+ @dataclass(frozen=True)
42
+ class KeycloakOrganizationDomainToOrganizationRelProperties(CartographyRelProperties):
43
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
44
+
45
+
46
+ @dataclass(frozen=True)
47
+ # (:KeycloakOrganizationDomain)-[:BELONGS_TO]->(:KeycloakOrganization)
48
+ class KeycloakOrganizationDomainToOrganizationRel(CartographyRelSchema):
49
+ target_node_label: str = "KeycloakOrganization"
50
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
51
+ {"id": PropertyRef("organization_id")},
52
+ )
53
+ direction: LinkDirection = LinkDirection.OUTWARD
54
+ rel_label: str = "BELONGS_TO"
55
+ properties: KeycloakOrganizationDomainToOrganizationRelProperties = (
56
+ KeycloakOrganizationDomainToOrganizationRelProperties()
57
+ )
58
+
59
+
60
+ @dataclass(frozen=True)
61
+ class KeycloakOrganizationDomainSchema(CartographyNodeSchema):
62
+ label: str = "KeycloakOrganizationDomain"
63
+ properties: KeycloakOrganizationDomainNodeProperties = (
64
+ KeycloakOrganizationDomainNodeProperties()
65
+ )
66
+ sub_resource_relationship: KeycloakOrganizationDomainToRealmRel = (
67
+ KeycloakOrganizationDomainToRealmRel()
68
+ )
69
+ other_relationships: OtherRelationships = OtherRelationships(
70
+ [
71
+ KeycloakOrganizationDomainToOrganizationRel(),
72
+ ]
73
+ )