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

Add experimental support of OSCORE. #1277

Merged
merged 6 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion build-config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ Contributors:
<logback.configurationFile>logback-leshan-test.xml</logback.configurationFile>
</systemPropertyVariables>
<parallel>classes</parallel>
<threadCount>4</threadCount>
<!-- TODO OSCORE threadcount should be set to 4 again as soon as
instability was resolved see : https://github.com/eclipse/leshan/pull/1180#issuecomment-1007587985 -->
<threadCount>1</threadCount>
<excludes>
<exclude>**/*$*</exclude>
</excludes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ public static LeshanBootstrapServer createBsLeshanServer(LeshanBsServerDemoCLI c
builder.setConfigStore(bsConfigStore);
builder.setSecurityStore(new BootstrapSecurityStoreAdapter(securityStore));

// TODO OSCORE Temporary cli option to deactivate OSCORE
if (!cli.main.disableOscore) {
builder.setEnableOscore(true);
}

return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public static class BootstrapServerGeneralSection extends GeneralSection {
"Set the filename for the configuration.", //
"Default: ${DEFAULT-VALUE}" })
public String configFilename;

@Option(names = { "-no", "--disable-oscore" },
description = { //
"Disable experimental OSCORE feature." })
public Boolean disableOscore = false;
}

/* ********************************** DTLS Section ******************************** */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,50 +27,95 @@
class="examplePatch"
></v-text-field>
<security-input
:mode.sync="server.mode"
v-if="server"
:mode.sync="server.security.mode"
@update:mode="$emit('input', server)"
:details.sync="server.details"
:details.sync="server.security.details"
@update:details="$emit('input', server)"
:defaultrpk="defaultrpk"
:defaultx509="defaultx509"
/>
<!-- OSCORE Object -->
<v-switch
v-model="useOSCORE"
@change="useOSCOREChanged($event)"
label="Using OSCORE (Experimental - for now can not be used with DTLS)"
></v-switch>
<oscore-input
v-if="useOSCORE"
v-model="server.oscore"
@input="$emit('input', server)"
>
</oscore-input>
</div>
</template>
<script>
import securityInput from "./SecurityInput.vue";
import OscoreInput from "@leshan-server-core-demo/components/security/OscoreInput.vue";

export default {
components: { securityInput },
components: { securityInput, OscoreInput },
props: {
value: Object,
defaultNoSecValue: String,
defaultSecureValue: String,
defaultrpk: {
default: function() {
default: function () {
return {};
},
type: Object,
},
defaultx509: {
default: function() {
default: function () {
return {};
},
type: Object,
},
},
data() {
return {
server: { mode: "no_sec" }, // internal server Config
useOSCORE: false, // true if OSCORE is used
server: null, // internal server Config
};
},
beforeMount() {
this.initValue(this.value);
},
watch: {
value(v) {
if (!v) {
this.server = { mode: "no_sec" };
this.initValue(v);
},
},
methods: {
initValue(initialValue) {
if (!initialValue) {
this.server = { security: { mode: "no_sec" } };
this.useOSCORE = false;
} else {
this.server = v;
this.server = initialValue;
this.useOSCORE = initialValue.oscore ? true : false;
}
},
useOSCOREChanged(useOSCORE) {
if (useOSCORE) {
this.server.oscore = {};
} else {
this.server.oscore = undefined;
}
this.$emit("input", this.server);
},
/*exclusifTlsOrOSCORE() {
if (this.useDTLS) {
this.$emit("update:tls", { mode: "psk", details: {} });
this.$emit("update:oscore", undefined);
} else if (this.useOSCORE) {
this.$emit("update:tls", undefined);
this.$emit("update:oscore", {});
} else {
this.$emit("update:tls", undefined);
this.$emit("update:oscore", undefined);
}
},*/
},
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
<v-card-text class="pb-0">
<p>
This information will be used to add a
<strong>LWM2M Bootstrap Server</strong> to your LWM2M Client during the bootstrap
Session by writing 1 instance for object <code>/0</code>.
</p>
<p>
By default no LWM2M Bootstrap server is added.
<strong>LWM2M Bootstrap Server</strong> to your LWM2M Client during the
bootstrap Session by writing 1 instance for object <code>/0</code>.
</p>
<p>By default no LWM2M Bootstrap server is added.</p>
</v-card-text>
<v-form
ref="form"
Expand Down Expand Up @@ -60,14 +58,14 @@ export default {
data() {
return {
addServer: false,
internalServer: { mode: "no_sec" }, // internal Bootstrap server Config
internalServer: { security: { mode: "no_sec" } }, // internal Bootstrap server Config
};
},
watch: {
value(v) {
if (!v) {
this.addServer = false;
this.internalServer = { mode: "no_sec" };
this.internalServer = { security: { mode: "no_sec" } };
} else {
this.addServer = true;
this.internalServer = v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@
>
Previous
</v-btn>
<v-btn text @click="close">
Cancel
</v-btn>
<v-btn text @click="close"> Cancel </v-btn>
</v-card-actions>
</v-card>
</v-dialog>
Expand Down Expand Up @@ -193,9 +191,9 @@ export default {
this.config = {
endpoint: null,
security: null,
dm: { mode: "no_sec" },
dm: { security: { mode: "no_sec" } },
bs: null,
toDelete: ["/0", "/1"],
toDelete: ["/0", "/1", "/21"],
autoIdForSecurityObject: false,
};
this.currentStep = 1;
Expand All @@ -217,7 +215,7 @@ export default {
if (res.dm) {
if (!res.dm.url) {
res.dm.url =
res.dm.mode == "no_sec"
res.dm.security.mode == "no_sec"
? this.defval.dm.url.nosec
: this.defval.dm.url.sec;
}
Expand All @@ -226,29 +224,34 @@ export default {
if (res.bs) {
if (!res.bs.url) {
res.bs.url =
res.bs.mode == "no_sec"
res.bs.security.mode == "no_sec"
? this.defval.bs.url.nosec
: this.defval.bs.url.sec;
}

// apply default rpk value for bs server
if (res.bs.mode == "rpk") {
if (res.bs.security.mode == "rpk") {
for (const key in this.defaultrpk) {
if (!res.bs.details[key]) {
res.bs.details[key] = this.defaultrpk[key];
if (!res.bs.security.details[key]) {
res.bs.security.details[key] = this.defaultrpk[key];
}
}
}
// apply default x509 value for bs server
if (res.bs.mode == "x509") {
if (res.bs.security.mode == "x509") {
for (const key in this.defaultx509) {
if (!res.bs.details[key]) {
res.bs.details[key] = this.defaultx509[key];
if (!res.bs.security.details[key]) {
res.bs.security.details[key] = this.defaultx509[key];
}
}
}
}

// apply endpoint to security
if (res.security) {
res.security.endpoint = res.endpoint;
}

return res;
},
close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
existing configuration on the <strong>LWM2M client</strong>.
</p>
<p>
By default, objects <code>/0</code> and <code>/1</code> are deleted,
By default, objects <code>/0</code>, <code>/1</code> and <code>/21</code> are deleted,
then you will be able to define LWM2M Server and LWM2M Bootstrap Server
to add.
</p>
Expand Down
41 changes: 7 additions & 34 deletions leshan-bsserver-demo/webapp/src/components/wizard/SecurityStep.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@
a demo.
</p>
</v-card-text>
<v-form ref="form" :value="valid" @input="$emit('update:valid', !useDTLS || $event)">
<v-switch class="pl-5"
v-model="useDTLS"
@change="updateUseDTLS($event)"
label="Using (D)TLS"
></v-switch>
<v-form ref="form" :value="valid" @input="$emit('update:valid', $event)">
<security-info-input
v-show="useDTLS"
:mode="internalSecurityInfo.mode"
:details="internalSecurityInfo.details"
@update:mode="updateMode($event)"
@update:details="updateDetails($event)"
:tls.sync="internalSecurityInfo.tls"
:oscore.sync="internalSecurityInfo.oscore"
@update:tls="$emit('input', internalSecurityInfo)"
@update:oscore="$emit('input', internalSecurityInfo)"
/>
</v-form>
</v-card>
Expand All @@ -48,40 +42,19 @@ export default {
},
data() {
return {
useDTLS: false,
internalSecurityInfo: { mode: "psk", details: {} },
internalSecurityInfo: {},
};
},
watch: {
value(v) {
if (!v) {
this.useDTLS = false;
this.internalSecurityInfo = { mode: "psk", details: {} };
this.internalSecurityInfo = {};
} else {
this.useDTLS = true;
this.internalSecurityInfo = v;
}
},
},
methods: {
updateUseDTLS(useDTLS) {
if (useDTLS) {
this.$emit("input", this.internalSecurityInfo);
this.resetValidation();
this.$emit('update:valid', false);
} else {
this.$emit("input", null);
this.$emit('update:valid', true);
}
},
updateMode(mode) {
this.internalSecurityInfo.mode = mode;
this.$emit("input", this.internalSecurityInfo);
},
updateDetails(mode) {
this.internalSecurityInfo.details = mode;
this.$emit("input", this.internalSecurityInfo);
},
resetValidation() {
this.$refs.form.resetValidation();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ export default {
data() {
return {
addServer: true,
internalServer: { mode: "no_sec" }, // internal server Config
internalServer: { security: { mode: "no_sec" } }, // internal server Config
};
},
watch: {
value(v) {
if (!v) {
this.addServer = false;
this.internalServer = { mode: "no_sec" };
this.internalServer = { security: { mode: "no_sec" } };
} else {
this.addServer = true;
this.internalServer = v;
Expand Down
Loading