Skip to content

Commit bbcc215

Browse files
authored
Accounts identified as connectors now bypass the review process and automatically publish assets. (#619)
* allow connectors to bypass the review workflow * Add `platform_example` to `sdk-service` for developing connectors
1 parent d98475b commit bbcc215

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

authentication/import/aiod-realm.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@
4646
"failureFactor" : 30,
4747
"roles" : {
4848
"realm" : [ {
49+
"id" : "e08fe59a-cf81-451d-9f47-59141894dfc3",
50+
"name" : "platform_example",
51+
"description" : "Role for a connector which uploads assets from the \"example\" platform",
52+
"composite" : false,
53+
"clientRole" : false,
54+
"containerId" : "3df7e07d-ebbd-41c4-bc0c-1ba0e1a40ac5",
55+
"attributes" : { }
56+
}, {
4957
"id" : "25a45d6d-fe0d-4855-945f-f5a27ec86ad0",
5058
"name" : "uma_authorization",
5159
"description" : "${role_uma_authorization}",
@@ -1416,7 +1424,7 @@
14161424
"subType" : "authenticated",
14171425
"subComponents" : { },
14181426
"config" : {
1419-
"allowed-protocol-mapper-types" : [ "oidc-usermodel-property-mapper", "saml-role-list-mapper", "oidc-address-mapper", "oidc-full-name-mapper", "oidc-sha256-pairwise-sub-mapper", "saml-user-property-mapper", "oidc-usermodel-attribute-mapper", "saml-user-attribute-mapper" ]
1427+
"allowed-protocol-mapper-types" : [ "saml-user-attribute-mapper", "oidc-full-name-mapper", "oidc-usermodel-property-mapper", "saml-role-list-mapper", "oidc-address-mapper", "oidc-sha256-pairwise-sub-mapper", "saml-user-property-mapper", "oidc-usermodel-attribute-mapper" ]
14201428
}
14211429
}, {
14221430
"id" : "10f8b9b2-1038-4c98-b7a5-a9ac88fed69e",
@@ -1458,7 +1466,7 @@
14581466
"subType" : "anonymous",
14591467
"subComponents" : { },
14601468
"config" : {
1461-
"allowed-protocol-mapper-types" : [ "saml-role-list-mapper", "saml-user-property-mapper", "oidc-sha256-pairwise-sub-mapper", "saml-user-attribute-mapper", "oidc-usermodel-property-mapper", "oidc-full-name-mapper", "oidc-usermodel-attribute-mapper", "oidc-address-mapper" ]
1469+
"allowed-protocol-mapper-types" : [ "saml-user-attribute-mapper", "oidc-usermodel-attribute-mapper", "oidc-address-mapper", "oidc-sha256-pairwise-sub-mapper", "oidc-full-name-mapper", "saml-user-property-mapper", "saml-role-list-mapper", "oidc-usermodel-property-mapper" ]
14621470
}
14631471
}, {
14641472
"id" : "1d21f027-e0ae-4b80-b95e-f21d9426f115",

authentication/import/aiod-users-0.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
},
3838
"notBefore" : 0,
3939
"groups" : [ ]
40+
}, {
41+
"id" : "bbe1da8d-236c-40bb-9ca3-30d494b471cc",
42+
"username" : "service-account-sdk-service",
43+
"emailVerified" : false,
44+
"createdTimestamp" : 1758277112410,
45+
"enabled" : true,
46+
"totp" : false,
47+
"serviceAccountClientId" : "sdk-service",
48+
"credentials" : [ ],
49+
"disableableCredentialTypes" : [ ],
50+
"requiredActions" : [ ],
51+
"realmRoles" : [ "platform_example", "default-roles-aiod" ],
52+
"notBefore" : 0,
53+
"groups" : [ ]
4054
}, {
4155
"id" : "4a80f256-3928-4cfa-ba66-5e22bb36fc01",
4256
"username" : "user",
@@ -56,7 +70,7 @@
5670
} ],
5771
"disableableCredentialTypes" : [ ],
5872
"requiredActions" : [ ],
59-
"realmRoles" : [ "default-roles-aiod"],
73+
"realmRoles" : [ "default-roles-aiod" ],
6074
"notBefore" : 0,
6175
"groups" : [ ]
6276
} ]

src/routers/resource_router.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,8 @@ def register_resource(
513513
set_permission(
514514
user, resource.aiod_entry, session, type_=PermissionType.ADMIN
515515
)
516+
if user.is_connector:
517+
resource.aiod_entry.status = EntryStatus.PUBLISHED
516518
session.commit()
517519
return {"identifier": resource.identifier}
518520
except Exception as e:

src/tests/routers/generic/test_router_post.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import pytest
33
from starlette.testclient import TestClient
44

5+
from database.model.concept.aiod_entry import EntryStatus
6+
from database.model.knowledge_asset.publication import Publication
7+
from database.session import DbSession
58
from tests.testutils.users import logged_in_user, kc_connector_with_roles
69
from tests.routers.resource_routers.test_router_organisation import with_organisation_taxonomies
710
from database.model.platform.platform_names import PlatformName
@@ -189,6 +192,24 @@ def test_connector_cannot_post_to_other_platform(
189192
assert response.json()["detail"] == "No permission to upload assets for aiod platform."
190193

191194

195+
def test_connector_uploads_bypass_review(client: TestClient, publication: Publication):
196+
publication.platform = "example"
197+
publication.platform_resource_identifier = "example_id"
198+
with logged_in_user(kc_connector_with_roles()):
199+
response = client.post(
200+
"/publications",
201+
content=publication.json(),
202+
headers={"Authorization": "Fake token"}
203+
)
204+
assert response.status_code == HTTPStatus.OK, response.json()
205+
206+
identifier = response.json()["identifier"]
207+
with DbSession() as session:
208+
asset = session.get(Publication, identifier)
209+
assert asset.aiod_entry.status == EntryStatus.PUBLISHED
210+
211+
212+
192213
def test_taxonomy_is_enforced_for_user(
193214
client: TestClient,
194215
body_asset: dict

0 commit comments

Comments
 (0)