-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2047 from beyonnex-io/add-permission-availability…
…-api Add new endpoint checkpermissions
- Loading branch information
Showing
38 changed files
with
2,492 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
documentation/src/main/resources/openapi/sources/paths/checkPermissions/index.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Eclipse Public License 2.0 which is available at | ||
# http://www.eclipse.org/legal/epl-2.0 | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
post: | ||
summary: Check permissions for specified entities | ||
description: |- | ||
This endpoint allows you to verify permissions for various entities on specific resources. | ||
tags: | ||
- Policies | ||
requestBody: | ||
description: JSON payload containing entities and their permissions to be checked. | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '../../schemas/checkPermissions/permissionCheckRequest.yml' | ||
responses: | ||
'200': | ||
description: Permission check results for each entity. | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '../../schemas/checkPermissions/permissionCheckResponse.yml' | ||
'401': | ||
description: Unauthorized request due to missing authentication. | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '../../schemas/errors/advancedError.yml' |
15 changes: 15 additions & 0 deletions
15
...on/src/main/resources/openapi/sources/schemas/checkPermissions/permissionCheckRequest.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Eclipse Public License 2.0 which is available at | ||
# http://www.eclipse.org/legal/epl-2.0 | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
type: object | ||
description: |- | ||
Request to check permissions for various entities and resources. | ||
additionalProperties: | ||
$ref: 'permissionEntityCheck.yml' |
14 changes: 14 additions & 0 deletions
14
...n/src/main/resources/openapi/sources/schemas/checkPermissions/permissionCheckResponse.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Eclipse Public License 2.0 which is available at | ||
# http://www.eclipse.org/legal/epl-2.0 | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
type: object | ||
description: "Response with permission check results for each entity." | ||
additionalProperties: | ||
type: boolean |
26 changes: 26 additions & 0 deletions
26
...ion/src/main/resources/openapi/sources/schemas/checkPermissions/permissionEntityCheck.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Eclipse Public License 2.0 which is available at | ||
# http://www.eclipse.org/legal/epl-2.0 | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
type: object | ||
description: |- | ||
Details for a specific permission check request. | ||
properties: | ||
resource: | ||
type: string | ||
description: "Resource path the permission check applies to." | ||
entityId: | ||
type: string | ||
description: "thingId of the entity performing the action." | ||
hasPermissions: | ||
type: array | ||
items: | ||
type: string | ||
enum: ["READ", "WRITE"] | ||
description: "Required permissions on the resource." |
48 changes: 48 additions & 0 deletions
48
documentation/src/main/resources/pages/ditto/basic-auth-checkpermissions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: Checking Permissions for Resources | ||
keywords: permissions, authorization, resources, policy, checkPermissions | ||
tags: [model] | ||
permalink: basic-auth-checkpermissions.html | ||
--- | ||
|
||
The `/checkPermissions` endpoint allows clients to validate permissions for specified entities on various resources, verifying access rights as defined in Ditto's policies. | ||
|
||
## Overview | ||
|
||
The `/checkPermissions` endpoint is part of Ditto's HTTP API, enhancing its policy-based authorization system by enabling permission validation checks on resources without modifying them. | ||
This functionality is valuable for UI-driven applications, where permissions checks can determine whether certain UI elements should be displayed or disabled based on the user’s access rights. | ||
|
||
## Request Structure | ||
|
||
Submit a `POST` request with a JSON payload specifying entities, resources, and permissions: | ||
|
||
```json | ||
{ | ||
"entity_name": { | ||
"resource": "thing:/features/lamp/properties/on", | ||
"entityId": "org.eclipse.ditto:some-thing-1", | ||
"hasPermissions": ["READ"] | ||
}, | ||
"another_entity": { | ||
"resource": "message:/features/lamp/inbox/messages/toggle", | ||
"entityId": "org.eclipse.ditto:some-thing-2", | ||
"hasPermissions": ["WRITE"] | ||
} | ||
} | ||
``` | ||
## Fields | ||
- entity_name: Identifier for the entity performing the action. | ||
- resource: Path of the target resource, starting with thing:, message:, or policy: followed by a valid resource path. | ||
- entityId: Unique identifier for the entity, such as a thingId or policyId, depending on the resource. | ||
- hasPermissions: Array of required permissions, such as READ or WRITE. | ||
|
||
## Response Structure | ||
The response indicates permission status for each entity and resource, returning a JSON object mapping entities to true (authorized) or false (unauthorized) values. | ||
|
||
```json | ||
{ | ||
"entity_name": true, | ||
"another_entity": false | ||
} | ||
``` | ||
This endpoint is especially useful for applications requiring quick permission validation for multiple entities across various resources. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.