Skip to content

Commit

Permalink
digid machtigen
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed May 22, 2024
1 parent 270fad9 commit 2f8409c
Show file tree
Hide file tree
Showing 12 changed files with 2,978 additions and 6 deletions.
3 changes: 2 additions & 1 deletion docker/keycloak/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ VCR.py). The primary reason this setup exists, is for automated testing reasons.
**Users**

- `testuser` / `testuser`, has the `bsn` and `kvk` attributes
- `digid-machtigen` / `digid-machtigen`, has the `aanvrager.bsn` and `gemachtigde.bsn` attributes

## Exporting the Realm

Expand All @@ -60,7 +61,7 @@ chmod o+rwx ./keycloak/import/
Then open another terminal and run:

```bash
docker-compose exec keycloak \
docker-compose -f docker-compose.keycloak.yml exec keycloak \
/opt/keycloak/bin/kc.sh \
export \
--file /opt/keycloak/data/import/test-realm.json \
Expand Down
65 changes: 62 additions & 3 deletions docker/keycloak/import/test-realm.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,30 @@
"webAuthnPolicyPasswordlessAcceptableAaguids" : [ ],
"webAuthnPolicyPasswordlessExtraOrigins" : [ ],
"users" : [ {
"id" : "ec5a1f70-3d10-48a8-a18b-2d13c925cd92",
"createdTimestamp" : 1716388011747,
"username" : "digid-machtigen",
"enabled" : true,
"totp" : false,
"emailVerified" : false,
"attributes" : {
"gemachtigde.bsn" : [ "999999999" ],
"aanvrager.bsn" : [ "000000000" ]
},
"credentials" : [ {
"id" : "5dde1609-96d7-44e0-be78-ac32b9d55736",
"type" : "password",
"userLabel" : "My password",
"createdDate" : 1716388020934,
"secretData" : "{\"value\":\"fCYy0OCCW1dVleqekfMpt7hkrQg+e2AeY3pJ14eLKdU=\",\"salt\":\"+TVXeVVZ4RudZj0nUVZsYA==\",\"additionalParameters\":{}}",
"credentialData" : "{\"hashIterations\":27500,\"algorithm\":\"pbkdf2-sha256\",\"additionalParameters\":{}}"
} ],
"disableableCredentialTypes" : [ ],
"requiredActions" : [ ],
"realmRoles" : [ "default-roles-test" ],
"notBefore" : 0,
"groups" : [ ]
}, {
"id" : "a28aac19-6ac5-4ce5-bbe3-b6c24051914a",
"createdTimestamp" : 1707141299906,
"username" : "service-account-testid",
Expand Down Expand Up @@ -653,6 +677,7 @@
"attributes" : {
"client.secret.creation.time" : "1707218309",
"user.info.response.signature.alg" : "RS256",
"post.logout.redirect.uris" : "+",
"oauth2.device.authorization.grant.enabled" : "false",
"backchannel.logout.revoke.offline.tokens" : "false",
"use.refresh.tokens" : "true",
Expand Down Expand Up @@ -1294,6 +1319,23 @@
"consent.screen.text" : ""
},
"protocolMappers" : [ {
"id" : "65bb02a6-160e-4cd0-9cc8-41123b1f8207",
"name" : "aanvrager.bsn",
"protocol" : "openid-connect",
"protocolMapper" : "oidc-usermodel-attribute-mapper",
"consentRequired" : false,
"config" : {
"aggregate.attrs" : "false",
"introspection.token.claim" : "true",
"userinfo.token.claim" : "true",
"multivalued" : "false",
"user.attribute" : "aanvrager.bsn",
"id.token.claim" : "true",
"access.token.claim" : "true",
"claim.name" : "aanvrager\\.bsn",
"jsonType.label" : "String"
}
}, {
"id" : "e9a645fb-f731-43a0-bcca-c0a40070727a",
"name" : "bsn",
"protocol" : "openid-connect",
Expand All @@ -1308,6 +1350,23 @@
"claim.name" : "bsn",
"jsonType.label" : "String"
}
}, {
"id" : "2bc83ef0-a719-48e4-8142-6bfdcbe77ab2",
"name" : "gemachtigde.bsn",
"protocol" : "openid-connect",
"protocolMapper" : "oidc-usermodel-attribute-mapper",
"consentRequired" : false,
"config" : {
"aggregate.attrs" : "false",
"introspection.token.claim" : "true",
"userinfo.token.claim" : "true",
"multivalued" : "false",
"user.attribute" : "gemachtigde.bsn",
"id.token.claim" : "true",
"access.token.claim" : "true",
"claim.name" : "gemachtigde\\.bsn",
"jsonType.label" : "String"
}
} ]
} ],
"defaultDefaultClientScopes" : [ "role_list", "profile", "email", "roles", "web-origins", "acr" ],
Expand Down Expand Up @@ -1364,7 +1423,7 @@
"subType" : "anonymous",
"subComponents" : { },
"config" : {
"allowed-protocol-mapper-types" : [ "oidc-full-name-mapper", "oidc-usermodel-property-mapper", "oidc-usermodel-attribute-mapper", "saml-user-attribute-mapper", "saml-role-list-mapper", "oidc-address-mapper", "saml-user-property-mapper", "oidc-sha256-pairwise-sub-mapper" ]
"allowed-protocol-mapper-types" : [ "saml-user-property-mapper", "oidc-address-mapper", "saml-role-list-mapper", "oidc-usermodel-attribute-mapper", "oidc-usermodel-property-mapper", "saml-user-attribute-mapper", "oidc-full-name-mapper", "oidc-sha256-pairwise-sub-mapper" ]
}
}, {
"id" : "c6b13ddf-1676-4e33-85d7-c778891156b3",
Expand All @@ -1389,7 +1448,7 @@
"subType" : "authenticated",
"subComponents" : { },
"config" : {
"allowed-protocol-mapper-types" : [ "oidc-sha256-pairwise-sub-mapper", "oidc-address-mapper", "saml-role-list-mapper", "saml-user-property-mapper", "saml-user-attribute-mapper", "oidc-usermodel-attribute-mapper", "oidc-usermodel-property-mapper", "oidc-full-name-mapper" ]
"allowed-protocol-mapper-types" : [ "saml-user-attribute-mapper", "oidc-usermodel-attribute-mapper", "saml-user-property-mapper", "oidc-sha256-pairwise-sub-mapper", "oidc-usermodel-property-mapper", "oidc-full-name-mapper", "saml-role-list-mapper", "oidc-address-mapper" ]
}
}, {
"id" : "9557d357-cc12-443e-bba6-a89e89b22c2e",
Expand Down Expand Up @@ -1990,7 +2049,7 @@
"cibaInterval" : "5",
"realmReusableOtpCode" : "false"
},
"keycloakVersion" : "23.0.6",
"keycloakVersion" : "23.0.7",
"userManagedAccessAllowed" : false,
"clientProfiles" : {
"profiles" : [ ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def mock_config(model: str, **overrides):
oidc_rp_scopes_list=["openid", "kvk"],
)

mock_digid_machtigen_config = partial(
mock_config,
model="OpenIDConnectDigiDMachtigenConfig",
oidc_rp_scopes_list=["openid", "bsn"],
)


@override_settings(CORS_ALLOW_ALL_ORIGINS=True, IS_HTTPS=True)
class IntegrationTestsBase(OFVCRMixin, WebTest):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate, br
Connection:
- keep-alive
User-Agent:
- python-requests/2.31.0
method: GET
uri: http://localhost:8080/realms/test/protocol/openid-connect/auth
response:
body:
string: "<!DOCTYPE html>\n<html class=\"login-pf\">\n\n<head>\n <meta charset=\"utf-8\">\n
\ <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"
/>\n <meta name=\"robots\" content=\"noindex, nofollow\">\n\n <meta
name=\"viewport\" content=\"width=device-width,initial-scale=1\"/>\n <title>Sign
in to test</title>\n <link rel=\"icon\" href=\"/resources/883g6/login/keycloak/img/favicon.ico\"
/>\n <link href=\"/resources/883g6/common/keycloak/node_modules/@patternfly/patternfly/patternfly.min.css\"
rel=\"stylesheet\" />\n <link href=\"/resources/883g6/common/keycloak/node_modules/patternfly/dist/css/patternfly.min.css\"
rel=\"stylesheet\" />\n <link href=\"/resources/883g6/common/keycloak/node_modules/patternfly/dist/css/patternfly-additions.min.css\"
rel=\"stylesheet\" />\n <link href=\"/resources/883g6/common/keycloak/lib/pficon/pficon.css\"
rel=\"stylesheet\" />\n <link href=\"/resources/883g6/login/keycloak/css/login.css\"
rel=\"stylesheet\" />\n</head>\n\n<body class=\"\">\n<div class=\"login-pf-page\">\n
\ <div id=\"kc-header\" class=\"login-pf-page-header\">\n <div id=\"kc-header-wrapper\"\n
\ class=\"\">test</div>\n </div>\n <div class=\"card-pf\">\n
\ <header class=\"login-pf-header\">\n <h1 id=\"kc-page-title\">
\ We are sorry...\n</h1>\n </header>\n <div id=\"kc-content\">\n
\ <div id=\"kc-content-wrapper\">\n\n\n <div id=\"kc-error-message\">\n
\ <p class=\"instruction\">Invalid Request</p>\n </div>\n\n\n\n
\ </div>\n </div>\n\n </div>\n </div>\n</body>\n</html>\n"
headers:
Content-Language:
- en
Content-Security-Policy:
- frame-src 'self'; frame-ancestors 'self'; object-src 'none';
Content-Type:
- text/html;charset=utf-8
Referrer-Policy:
- no-referrer
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Robots-Tag:
- none
X-XSS-Protection:
- 1; mode=block
content-length:
- '1573'
status:
code: 400
message: Bad Request
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate, br
Connection:
- keep-alive
User-Agent:
- python-requests/2.31.0
method: GET
uri: http://localhost:8080/realms/test/protocol/openid-connect/auth?response_type=code&scope=badscope&client_id=testid&redirect_uri=http%3A%2F%2Ftestserver%2Fdigid-machtigen-oidc%2Fcallback%2F&state=not-a-random-string&nonce=not-a-random-string
response:
body:
string: ''
headers:
Location:
- http://testserver/digid-machtigen-oidc/callback/?error=invalid_scope&error_description=Invalid+scopes%3A+badscope&state=not-a-random-string&iss=http%3A%2F%2Flocalhost%3A8080%2Frealms%2Ftest
Referrer-Policy:
- no-referrer
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
- nosniff
X-XSS-Protection:
- 1; mode=block
content-length:
- '0'
status:
code: 302
message: Found
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate, br
Connection:
- keep-alive
User-Agent:
- python-requests/2.31.0
method: GET
uri: http://localhost:8080/realms/test/protocol/openid-connect/auth
response:
body:
string: "<!DOCTYPE html>\n<html class=\"login-pf\">\n\n<head>\n <meta charset=\"utf-8\">\n
\ <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"
/>\n <meta name=\"robots\" content=\"noindex, nofollow\">\n\n <meta
name=\"viewport\" content=\"width=device-width,initial-scale=1\"/>\n <title>Sign
in to test</title>\n <link rel=\"icon\" href=\"/resources/1rz7o/login/keycloak/img/favicon.ico\"
/>\n <link href=\"/resources/1rz7o/common/keycloak/node_modules/@patternfly/patternfly/patternfly.min.css\"
rel=\"stylesheet\" />\n <link href=\"/resources/1rz7o/common/keycloak/node_modules/patternfly/dist/css/patternfly.min.css\"
rel=\"stylesheet\" />\n <link href=\"/resources/1rz7o/common/keycloak/node_modules/patternfly/dist/css/patternfly-additions.min.css\"
rel=\"stylesheet\" />\n <link href=\"/resources/1rz7o/common/keycloak/lib/pficon/pficon.css\"
rel=\"stylesheet\" />\n <link href=\"/resources/1rz7o/login/keycloak/css/login.css\"
rel=\"stylesheet\" />\n</head>\n\n<body class=\"\">\n<div class=\"login-pf-page\">\n
\ <div id=\"kc-header\" class=\"login-pf-page-header\">\n <div id=\"kc-header-wrapper\"\n
\ class=\"\">test</div>\n </div>\n <div class=\"card-pf\">\n
\ <header class=\"login-pf-header\">\n <h1 id=\"kc-page-title\">
\ We are sorry...\n</h1>\n </header>\n <div id=\"kc-content\">\n
\ <div id=\"kc-content-wrapper\">\n\n\n <div id=\"kc-error-message\">\n
\ <p class=\"instruction\">Invalid Request</p>\n </div>\n\n\n\n
\ </div>\n </div>\n\n </div>\n </div>\n</body>\n</html>\n"
headers:
Content-Language:
- en
Content-Security-Policy:
- frame-src 'self'; frame-ancestors 'self'; object-src 'none';
Content-Type:
- text/html;charset=utf-8
Referrer-Policy:
- no-referrer
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Robots-Tag:
- none
X-XSS-Protection:
- 1; mode=block
content-length:
- '1573'
status:
code: 400
message: Bad Request
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate, br
Connection:
- keep-alive
User-Agent:
- python-requests/2.31.0
method: GET
uri: http://localhost:8080/realms/test/protocol/openid-connect/auth?response_type=code&scope=badscope&client_id=testid&redirect_uri=http%3A%2F%2Ftestserver%2Fdigid-machtigen-oidc%2Fcallback%2F&state=not-a-random-string&nonce=not-a-random-string
response:
body:
string: ''
headers:
Location:
- http://testserver/digid-machtigen-oidc/callback/?error=invalid_scope&error_description=Invalid+scopes%3A+badscope&state=not-a-random-string&iss=http%3A%2F%2Flocalhost%3A8080%2Frealms%2Ftest
Referrer-Policy:
- no-referrer
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
- nosniff
X-XSS-Protection:
- 1; mode=block
content-length:
- '0'
status:
code: 302
message: Found
version: 1
Loading

0 comments on commit 2f8409c

Please sign in to comment.