Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make configurable delete request for Bootstrap Server #670

Merged
merged 3 commits into from
Apr 3, 2019

Conversation

sbernard31
Copy link
Contributor

Before this PR, bootstrap server always starts with delete request on "/".
Now in BootstrapConfig, there is a toDelete list of path to object to delete.

@sbernard31 sbernard31 force-pushed the custom_bootstrap_handler branch from a1517bf to be20408 Compare April 2, 2019 16:05
@sbernard31 sbernard31 changed the base branch from custom_bootstrap_handler to master April 2, 2019 16:26
@sbernard31 sbernard31 force-pushed the bootstrap_delete_config branch from bf94dee to f7628dd Compare April 2, 2019 16:27
@sbernard31 sbernard31 force-pushed the bootstrap_delete_config branch from f7628dd to b76c670 Compare April 3, 2019 15:18
@sbernard31 sbernard31 merged commit b76c670 into master Apr 3, 2019
@sbernard31
Copy link
Contributor Author

bs server demo UI create a bootstrap config which will delete "/0" and "/1".
For custom config you can use REST API.

Here a python script as example, to delete "/" as before this PR:

import requests
import json

BASE_URL = "https://leshan.eclipseprojects.io/bs/"  # the URL of the server.
url = BASE_URL + "api/bootstrap/clientendpoint"  # the client endpoint here !
data = {
        "toDelete": ["/"],
        "servers": {"0": {"shortId": 123,
                        "lifetime": 20,
                        "defaultMinPeriod": 1,
                        "defaultMaxPeriod": None,
                        "disableTimeout": None,
                        "notifIfDisabled": True,
                        "binding": "U"}},
        "security": {"0":{"uri": "coaps://leshan.eclipseprojects.io:5784",
                        "bootstrapServer": True,
                        "securityMode": "PSK",
                        "publicKeyOrId": [98,111,111,116,115,116,114,97,112,95,99,108,105,101,110,116,95,105,100,101,110,116,105,116,121], #binary represenation of "bootstrap_client_identity"
                        "serverPublicKey" : [],
                        "secretKey": [115,101,99,114,101,116,95,107,101,121], #binary representation of "private_key", the hexa value is 7365637265745f6b6579
                        "smsSecurityMode": "NO_SEC",
                        "smsBindingKeyParam" : [],
                        "smsBindingKeySecret" : [],
                        "serverSmsNumber" : "+3343577911",
                        "serverId" : 0,
                        "clientOldOffTime" : 20},
                   "1":{"uri": "coaps://leshan.eclipseprojects.io:5684",
                        "bootstrapServer": False,
                        "securityMode": "PSK",
                        "publicKeyOrId": [115,101,99,117,114,101,95,99,108,105,101,110,116,95,105,100],#represenation of "secure_client_id"
                        "serverPublicKey" : [],
                        "secretKey": [112,114,105,118,97,116,101,95,107,101,121], #binary representation of "private_key", the hexa value is 707269766174655f6b6579
                        "smsSecurityMode": "NO_SEC",
                        "smsBindingKeyParam" : [],
                        "smsBindingKeySecret" : [],
                        "serverSmsNumber" : "+3343577464",
                        "serverId" : 123,
                        "clientOldOffTime" : 1}},
        "acls": {"0":{
                        "objectId": 3,
                        "objectInstanceId": 0,
                        "acls": {3333: 1},
                        "AccessControlOwner":123}}
        };

headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(url, data=json.dumps(data), headers=headers)
print r.status_code
print r.content

@sbernard31 sbernard31 deleted the bootstrap_delete_config branch May 23, 2019 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant