625b1ed7.e9e7c344.js 6.2 KB

1
  1. "use strict";(self.webpackChunkwebserial_docs=self.webpackChunkwebserial_docs||[]).push([[168],{3905:(e,t,n)=>{n.d(t,{Zo:()=>l,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},i=Object.keys(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var c=a.createContext({}),u=function(e){var t=a.useContext(c),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},l=function(e){var t=u(e.components);return a.createElement(c.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},d=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,c=e.parentName,l=s(e,["components","mdxType","originalType","parentName"]),d=u(n),m=r,h=d["".concat(c,".").concat(m)]||d[m]||p[m]||i;return n?a.createElement(h,o(o({ref:t},l),{},{components:n})):a.createElement(h,o({ref:t},l))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,o=new Array(i);o[0]=d;var s={};for(var c in t)hasOwnProperty.call(t,c)&&(s[c]=t[c]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var u=2;u<i;u++)o[u]=n[u];return a.createElement.apply(null,o)}return a.createElement.apply(null,n)}d.displayName="MDXCreateElement"},1245:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>o,default:()=>p,frontMatter:()=>i,metadata:()=>s,toc:()=>u});var a=n(7462),r=(n(7294),n(3905));const i={title:"Authentication",sidebar_label:"Authentication",sidebar_position:5},o=void 0,s={unversionedId:"authentication",id:"authentication",title:"Authentication",description:"The authentication feature in WebSerial enhances the security of your Internet of Things (IoT) devices by requiring authentication before allowing anybody to access the logs of your device. This feature ensures that only authorized individuals or systems can access and modify your devices, adding an extra layer of protection to your IoT ecosystem.",source:"@site/docs/authentication.md",sourceDirName:".",slug:"/authentication",permalink:"/authentication",draft:!1,tags:[],version:"current",sidebarPosition:5,frontMatter:{title:"Authentication",sidebar_label:"Authentication",sidebar_position:5},sidebar:"tutorialSidebar",previous:{title:"Examples",permalink:"/examples"},next:{title:"Callbacks",permalink:"/callbacks"}},c={},u=[{value:"Setting Authentication",id:"setting-authentication",level:2},{value:"Example Usage",id:"example-usage",level:3},{value:"Use Cases",id:"use-cases",level:2},{value:"Best Practices",id:"best-practices",level:2}],l={toc:u};function p(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},l,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("p",null,"The authentication feature in WebSerial enhances the security of your Internet of Things (IoT) devices by requiring authentication before allowing anybody to access the logs of your device. This feature ensures that only authorized individuals or systems can access and modify your devices, adding an extra layer of protection to your IoT ecosystem."),(0,r.kt)("h2",{id:"setting-authentication"},"Setting Authentication"),(0,r.kt)("p",null,"You can set up authentication for your device using the ",(0,r.kt)("inlineCode",{parentName:"p"},'WebSerial.setAuthentication("username", "password");')," function. This function requires two parameters: a username and a password. These credentials act as a gatekeeper, preventing unauthorized access to the webserial interface."),(0,r.kt)("h3",{id:"example-usage"},"Example Usage"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-cpp"},'#include <WebSerial.h>\n\nvoid setup() {\n ...\n\n // Set Authentication Credentials\n WebSerial.setAuthentication("myUsername", "myPassword");\n}\n\nvoid loop() {\n ...\n}\n')),(0,r.kt)("h2",{id:"use-cases"},"Use Cases"),(0,r.kt)("p",null,"The Authentication feature is crucial in various scenarios:"),(0,r.kt)("ol",null,(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},"Security"),": It safeguards your IoT devices against unauthorized access, reducing the risk of malicious actors getting access to important information in your logs.")),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},"Access Control"),": By setting unique credentials for each device, you can control access to individual devices, ensuring that only authorized personnel or systems can modify them.")),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},"Compliance"),": Some security and compliance standards require authentication mechanisms for IoT devices. WebSerial's authentication feature helps you meet these requirements."))),(0,r.kt)("h2",{id:"best-practices"},"Best Practices"),(0,r.kt)("p",null,"To ensure the effectiveness of the authentication feature, consider these best practices:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"Choose strong and unique usernames and passwords for each device.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"Avoid using default or easily guessable credentials to enhance security.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"Regularly update and rotate the authentication credentials to maintain security."))))}p.isMDXComponent=!0}}]);