2016-06-30 12:46:34 +00:00
|
|
|
{
|
|
|
|
"allowRemoteResourceManagement": true,
|
|
|
|
"policyEnforcementMode": "ENFORCING",
|
|
|
|
"resources": [
|
|
|
|
{
|
|
|
|
"name": "User Profile Resource",
|
|
|
|
"uri": "/profile",
|
|
|
|
"type": "http://photoz.com/profile",
|
|
|
|
"scopes": [
|
|
|
|
{
|
2018-02-28 07:53:10 +00:00
|
|
|
"name": "profile:view"
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Album Resource",
|
|
|
|
"uri": "/album/*",
|
|
|
|
"type": "http://photoz.com/album",
|
|
|
|
"scopes": [
|
|
|
|
{
|
2018-02-28 07:53:10 +00:00
|
|
|
"name": "album:view"
|
2016-06-30 12:46:34 +00:00
|
|
|
},
|
|
|
|
{
|
2018-02-28 07:53:10 +00:00
|
|
|
"name": "album:delete"
|
2016-06-30 12:46:34 +00:00
|
|
|
},
|
|
|
|
{
|
2018-02-28 07:53:10 +00:00
|
|
|
"name": "album:create"
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Admin Resources",
|
|
|
|
"uri": "/admin/*",
|
|
|
|
"type": "http://photoz.com/admin",
|
|
|
|
"scopes": [
|
|
|
|
{
|
2018-02-28 07:53:10 +00:00
|
|
|
"name": "admin:manage"
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
]
|
2017-10-24 13:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Scope Protected Resource",
|
|
|
|
"uri": "/scope-any",
|
|
|
|
"scopes": [
|
|
|
|
{
|
|
|
|
"name": "scope-a"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "scope-b"
|
|
|
|
}
|
|
|
|
]
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"policies": [
|
|
|
|
{
|
|
|
|
"name": "Only Owner Policy",
|
|
|
|
"description": "Defines that only the resource owner is allowed to do something",
|
2018-11-09 10:31:16 +00:00
|
|
|
"type": "js",
|
2016-07-27 18:15:14 +00:00
|
|
|
"logic": "POSITIVE",
|
|
|
|
"decisionStrategy": "UNANIMOUS",
|
2016-06-30 12:46:34 +00:00
|
|
|
"config": {
|
2018-11-09 10:31:16 +00:00
|
|
|
"code": "var permission = $evaluation.getPermission();\nvar identity = $evaluation.getContext().getIdentity();\nvar resource = permission.getResource();\nif (resource) {\nif (resource.getOwner().equals(identity.getId())) {\n$evaluation.grant();\n}}"
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Any Admin Policy",
|
|
|
|
"description": "Defines that adminsitrators can do something",
|
|
|
|
"type": "role",
|
2016-07-27 18:15:14 +00:00
|
|
|
"logic": "POSITIVE",
|
|
|
|
"decisionStrategy": "UNANIMOUS",
|
2016-06-30 12:46:34 +00:00
|
|
|
"config": {
|
2016-07-27 18:15:14 +00:00
|
|
|
"applyPolicies": "[]",
|
|
|
|
"roles": "[{\"id\":\"admin\",\"required\":true}]"
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Any User Policy",
|
2016-07-28 15:31:46 +00:00
|
|
|
"description": "Defines that only users from well known clients are allowed to access",
|
2016-06-30 12:46:34 +00:00
|
|
|
"type": "role",
|
2016-07-27 18:15:14 +00:00
|
|
|
"logic": "POSITIVE",
|
|
|
|
"decisionStrategy": "UNANIMOUS",
|
2016-06-30 12:46:34 +00:00
|
|
|
"config": {
|
2016-07-27 18:15:14 +00:00
|
|
|
"applyPolicies": "[]",
|
2021-05-26 11:18:58 +00:00
|
|
|
"roles": "[{\"id\":\"user\"},{\"id\":\"photoz-restful-api/manage-albums\",\"required\":true}]"
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Only From a Specific Client Address",
|
|
|
|
"description": "Defines that only clients from a specific address can do something",
|
|
|
|
"type": "js",
|
|
|
|
"logic": "POSITIVE",
|
|
|
|
"decisionStrategy": "UNANIMOUS",
|
|
|
|
"config": {
|
2016-07-27 18:15:14 +00:00
|
|
|
"applyPolicies": "[]",
|
2018-10-02 08:40:35 +00:00
|
|
|
"code": "var contextAttributes = $evaluation.getContext().getAttributes();\n\nif (contextAttributes.containsValue('kc.client.network.ip_address', '127.0.0.1') || contextAttributes.containsValue('kc.client.network.ip_address', '0:0:0:0:0:0:0:1')) {\n $evaluation.grant();\n}"
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Administration Policy",
|
|
|
|
"description": "Defines that only administrators from a specific network address can do something.",
|
|
|
|
"type": "aggregate",
|
2016-07-27 18:15:14 +00:00
|
|
|
"logic": "POSITIVE",
|
|
|
|
"decisionStrategy": "UNANIMOUS",
|
2016-06-30 12:46:34 +00:00
|
|
|
"config": {
|
2016-07-28 15:31:46 +00:00
|
|
|
"applyPolicies": "[\"Only From a Specific Client Address\",\"Any Admin Policy\"]"
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Only Owner and Administrators Policy",
|
|
|
|
"description": "Defines that only the resource owner and administrators can do something",
|
|
|
|
"type": "aggregate",
|
2016-07-27 18:15:14 +00:00
|
|
|
"logic": "POSITIVE",
|
2016-06-30 12:46:34 +00:00
|
|
|
"decisionStrategy": "AFFIRMATIVE",
|
|
|
|
"config": {
|
2016-07-28 15:31:46 +00:00
|
|
|
"applyPolicies": "[\"Administration Policy\",\"Only Owner Policy\"]"
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Only From @keycloak.org or Admin",
|
|
|
|
"description": "Defines that only users from @keycloak.org",
|
|
|
|
"type": "js",
|
2016-07-27 18:15:14 +00:00
|
|
|
"logic": "POSITIVE",
|
|
|
|
"decisionStrategy": "UNANIMOUS",
|
2016-06-30 12:46:34 +00:00
|
|
|
"config": {
|
|
|
|
"applyPolicies": "[]",
|
2017-09-01 19:08:34 +00:00
|
|
|
"code": "var context = $evaluation.getContext();\nvar identity = context.getIdentity();\nvar attributes = identity.getAttributes();\nvar email = attributes.getValue('email').asString(0);\n\nif (identity.hasRealmRole('admin') || email.endsWith('@keycloak.org')) {\n $evaluation.grant();\n}"
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Album Resource Permission",
|
|
|
|
"description": "General policies that apply to all album resources.",
|
|
|
|
"type": "resource",
|
2016-07-27 18:15:14 +00:00
|
|
|
"logic": "POSITIVE",
|
2016-06-30 12:46:34 +00:00
|
|
|
"decisionStrategy": "AFFIRMATIVE",
|
|
|
|
"config": {
|
|
|
|
"defaultResourceType": "http://photoz.com/album",
|
|
|
|
"default": "true",
|
|
|
|
"applyPolicies": "[\"Any User Policy\",\"Administration Policy\"]"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Admin Resource Permission",
|
|
|
|
"description": "General policy for any administrative resource.",
|
|
|
|
"type": "resource",
|
|
|
|
"logic": "POSITIVE",
|
|
|
|
"decisionStrategy": "UNANIMOUS",
|
|
|
|
"config": {
|
|
|
|
"defaultResourceType": "http://photoz.com/admin",
|
|
|
|
"default": "true",
|
|
|
|
"applyPolicies": "[\"Administration Policy\"]"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "View User Permission",
|
|
|
|
"description": "Defines who is allowed to view an user profile",
|
|
|
|
"type": "scope",
|
|
|
|
"logic": "POSITIVE",
|
|
|
|
"decisionStrategy": "UNANIMOUS",
|
|
|
|
"config": {
|
|
|
|
"applyPolicies": "[\"Only From @keycloak.org or Admin\"]",
|
2018-02-28 07:53:10 +00:00
|
|
|
"scopes": "[\"profile:view\"]"
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Delete Album Permission",
|
|
|
|
"description": "A policy that only allows the owner to delete his albums.",
|
|
|
|
"type": "scope",
|
|
|
|
"logic": "POSITIVE",
|
|
|
|
"decisionStrategy": "UNANIMOUS",
|
|
|
|
"config": {
|
|
|
|
"applyPolicies": "[\"Only Owner and Administrators Policy\"]",
|
2018-02-28 07:53:10 +00:00
|
|
|
"scopes": "[\"album:delete\"]"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "View Album Permission",
|
|
|
|
"description": "A policy that only allows the owner to view his albums.",
|
|
|
|
"type": "scope",
|
|
|
|
"logic": "POSITIVE",
|
|
|
|
"decisionStrategy": "UNANIMOUS",
|
|
|
|
"config": {
|
|
|
|
"applyPolicies": "[\"Only Owner and Administrators Policy\"]",
|
|
|
|
"scopes": "[\"album:view\"]"
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
2017-10-24 13:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Deny Policy",
|
|
|
|
"type": "js",
|
|
|
|
"logic": "POSITIVE",
|
|
|
|
"decisionStrategy": "UNANIMOUS",
|
|
|
|
"config": {
|
|
|
|
"code": "// by default, grants any permission associated with this policy\n$evaluation.deny();"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Protected Scope A Permission",
|
|
|
|
"type": "scope",
|
|
|
|
"logic": "POSITIVE",
|
|
|
|
"decisionStrategy": "UNANIMOUS",
|
|
|
|
"config": {
|
|
|
|
"resources": "[\"Scope Protected Resource\"]",
|
|
|
|
"scopes": "[\"scope-a\"]",
|
|
|
|
"applyPolicies": "[\"Any User Policy\"]"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Protected Scope B Permission",
|
|
|
|
"type": "scope",
|
|
|
|
"logic": "POSITIVE",
|
|
|
|
"decisionStrategy": "UNANIMOUS",
|
|
|
|
"config": {
|
|
|
|
"resources": "[\"Scope Protected Resource\"]",
|
|
|
|
"scopes": "[\"scope-b\"]",
|
|
|
|
"applyPolicies": "[\"Deny Policy\"]"
|
|
|
|
}
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"scopes": [
|
|
|
|
{
|
2018-02-28 07:53:10 +00:00
|
|
|
"name": "profile:view"
|
2016-06-30 12:46:34 +00:00
|
|
|
},
|
|
|
|
{
|
2018-02-28 07:53:10 +00:00
|
|
|
"name": "album:view"
|
2016-06-30 12:46:34 +00:00
|
|
|
},
|
|
|
|
{
|
2018-02-28 07:53:10 +00:00
|
|
|
"name": "album:create"
|
2016-06-30 12:46:34 +00:00
|
|
|
},
|
|
|
|
{
|
2018-02-28 07:53:10 +00:00
|
|
|
"name": "album:delete"
|
2016-06-30 12:46:34 +00:00
|
|
|
},
|
|
|
|
{
|
2018-02-28 07:53:10 +00:00
|
|
|
"name": "admin:manage"
|
2016-06-30 12:46:34 +00:00
|
|
|
}
|
|
|
|
]
|
2021-05-26 11:18:58 +00:00
|
|
|
}
|