Skip to content

Commit

Permalink
Merge pull request #96 from aissam-en/add-policy-creation-instructions
Browse files Browse the repository at this point in the history
Add policy creation instructions
  • Loading branch information
thjaeckle authored Jul 5, 2024
2 parents 642ffdc + 80ff11c commit 9f6965f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rest-to-websocket/FrontendApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class FrontendApp {
const thingId = this.config.thingId;
const connectionConfig = this.connectionConfigFunction();

this.baseUrl = `http://${connectionConfig.getHost()}/api/1/things/${thingId}`;
this.baseUrl = `http://${connectionConfig.getHost()}/api/2/things/${thingId}`; // updated from v1 to v2

const basicAuth = btoa(`${connectionConfig.getUsername()}:${connectionConfig.getPassword()}`);
$.ajaxSetup({
Expand Down
33 changes: 33 additions & 0 deletions rest-to-websocket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,39 @@ All we need for this example is a running Eclipse Ditto instance.
Please follow the guidelines at the [Eclipse Ditto](https://eclipse.dev/ditto/installation-running.html)
project to get started.

Additionally, you should create the policy `org.eclipse.ditto:smartcoffee` (if it does not exist), example of creating a policy:
```sh
curl --request PUT \
--url http://localhost:8080/api/2/policies/org.eclipse.ditto:smartcoffee \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ZGl0dG86ZGl0dG8=' \
--data '{
"entries": {
"owner": {
"subjects": {
"nginx:ditto": {
"type": "admin aissam"
}
},
"resources": {
"thing:/": {
"grant": ["READ", "WRITE"],
"revoke": []
},
"policy:/": {
"grant": ["READ", "WRITE"],
"revoke": []
},
"message:/": {
"grant": ["READ", "WRITE"],
"revoke": []
}
}
}
}
}'
```

To use the UI, you can simply open `index.html` in your favorite (hopefully
state-of-the-art :wink:) browser.

Expand Down
2 changes: 1 addition & 1 deletion rest-to-websocket/SmartCoffeeApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class DittoWebSocket {
}

connect(connectionConfig, callback) {
const baseUrl = `ws://${connectionConfig.getUsername()}:${connectionConfig.getPassword()}@${connectionConfig.getHost()}/ws/1`;
const baseUrl = `ws://${connectionConfig.getUsername()}:${connectionConfig.getPassword()}@${connectionConfig.getHost()}/ws/2`; // updated from v1 to v2
this.ws = new WebSocket(baseUrl);
this.ws.onopen = () => this.onOpen(callback);
}
Expand Down

0 comments on commit 9f6965f

Please sign in to comment.