%PDF- %PDF-
Direktori : /proc/self/root/snap/lxd/29351/share/lxd-ui/assets/ |
Current File : //proc/self/root/snap/lxd/29351/share/lxd-ui/assets/CertificateGenerate-67a1d99d.js |
import{r as h,j as e,d as s,u as S,L as I,N as D,C as L}from"./index-13b2882d.js";import{c as R,a as u,b as E,u as M}from"./index.esm-82c30f37.js";const x="Firefox",_="Chrome (Linux)",f="Chrome (Windows)",w="Edge",N="macOS",U=[x,_,f,w,N],X=({sendPfx:l})=>{const[a,r]=h.useState(x),i=e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:"p-list__item",children:["This opens a certificate management dialog. Click ",e.jsx("code",{children:"Import..."}),"then ",e.jsx("code",{children:"Next"})," and select the ",e.jsx("code",{children:"lxd-ui.pfx"})," file you just downloaded. Enter your password, or leave the field empty if you have not set one. Click ",e.jsx("code",{children:"Next"}),"."]}),e.jsxs("li",{className:"p-list__item",children:["Select ",e.jsx("code",{children:"Automatically select the certificate store"})," and click"," ",e.jsx("code",{children:"Next"}),", then click ",e.jsx("code",{children:"Finish"}),"."]}),e.jsx("li",{className:"p-list__item",children:"Restart the browser and open LXD-UI. Select the LXD-UI certificate."})]}),t=e.jsxs("li",{className:"p-list__item u-clearfix",children:["Download ",e.jsx("code",{children:"lxd-ui.pfx"}),l&&e.jsx("div",{className:"u-float-right--large",children:e.jsx(s.Button,{onClick:l,children:"Download pfx"})})]});return e.jsx(s.Row,{children:e.jsxs(s.Col,{size:8,children:[e.jsx(s.Tabs,{links:U.map(c=>({label:c,active:c===a,onClick:()=>r(c)}))}),a===x&&e.jsx("div",{role:"tabpanel","aria-label":"firefox",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[t,e.jsxs("li",{className:"p-list__item",children:["Paste this link into the address bar:",e.jsx("div",{className:"p-code-snippet u-no-margin--bottom",children:e.jsx("pre",{className:"p-code-snippet__block",children:e.jsx("code",{children:"about:preferences#privacy"})})})]}),e.jsxs("li",{className:"p-list__item",children:["Scroll down to the certificates section and click the"," ",e.jsx("code",{children:"View Certificates"})," button."]}),e.jsxs("li",{className:"p-list__item",children:["In the popup click ",e.jsx("code",{children:"Your certificates"})," and then"," ",e.jsx("code",{children:"Import"}),"."]}),e.jsxs("li",{className:"p-list__item",children:["Select the ",e.jsx("code",{children:"lxd-ui.pfx"})," file you just downloaded. Enter your password, or leave the field empty if you have not set one."]}),e.jsx("li",{className:"p-list__item",children:"Restart the browser and open LXD-UI. Select the LXD-UI certificate."})]})}),a===_&&e.jsx("div",{role:"tabpanel","aria-label":"chrome linux",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[t,e.jsxs("li",{className:"p-list__item",children:["Paste into the address bar:",e.jsx("div",{className:"p-code-snippet u-no-margin--bottom",children:e.jsx("pre",{className:"p-code-snippet__block",children:e.jsx("code",{children:"chrome://settings/certificates"})})})]}),e.jsxs("li",{className:"p-list__item",children:["Click the ",e.jsx("code",{children:"Import"})," button and select the"," ",e.jsx("code",{children:"lxd-ui.pfx"})," file you just downloaded. Enter your password, or leave the field empty if you have not set one."]}),e.jsx("li",{className:"p-list__item",children:"Restart the browser and open LXD-UI. Select the LXD-UI certificate."})]})}),a===f&&e.jsx("div",{role:"tabpanel","aria-label":"chrome windows",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[t,e.jsxs("li",{className:"p-list__item",children:["Paste into the address bar:",e.jsx("div",{className:"p-code-snippet u-no-margin--bottom",children:e.jsx("pre",{className:"p-code-snippet__block",children:e.jsx("code",{children:"chrome://settings/security"})})})]}),e.jsxs("li",{className:"p-list__item",children:["Scroll down to the ",e.jsx("code",{children:"Advanced settings"})," and click"," ",e.jsx("code",{children:"Manage device certificates"})]}),i]})}),a===w&&e.jsx("div",{role:"tabpanel","aria-label":"edge windows",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[t,e.jsxs("li",{className:"p-list__item",children:["Paste into the address bar:",e.jsx("div",{className:"p-code-snippet u-no-margin--bottom",children:e.jsx("pre",{className:"p-code-snippet__block",children:e.jsx("code",{children:"edge://settings/privacy"})})})]}),e.jsxs("li",{className:"p-list__item",children:["Scroll to the ",e.jsx("code",{children:"Security"})," section and click"," ",e.jsx("code",{children:"Manage Certificates"})]}),i]})}),a===N&&e.jsx("div",{role:"tabpanel","aria-label":"safari macos",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[e.jsx("li",{className:"p-list__item",children:e.jsx(s.Notification,{severity:"caution",className:"u-no-margin--bottom",children:"The certificate must be protected by password. An empty password will fail to be imported on macOS."})}),t,e.jsx("li",{className:"p-list__item",children:"Start the Keychain Access app on your Mac, select the login keychain."}),e.jsxs("li",{className:"p-list__item",children:["Drag the ",e.jsx("code",{children:"lxd-ui.pfx"})," file onto the Keychain Access app."]}),e.jsx("li",{className:"p-list__item",children:"If you are asked to provide a name and password, type the name and password for an administrator user on this computer."}),e.jsx("li",{className:"p-list__item",children:"Restart the browser and open LXD-UI. Select the LXD-UI certificate."})]})})]})})},z=({onConfirm:l,onClose:a})=>{const r=R().shape({password:u(),passwordConfirm:u().oneOf([E("password"),null],"Passwords must match")}),i=M({initialValues:{password:"",passwordConfirm:""},validationSchema:r,onSubmit:c=>{l(c.password)}}),t=()=>{l("")};return e.jsxs(s.Modal,{close:a,title:"Add a password",buttonRow:e.jsxs(e.Fragment,{children:[e.jsx(s.Button,{className:"u-no-margin--bottom",onClick:t,children:"Skip"}),e.jsx(s.Button,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>i.submitForm(),disabled:i.values.password!==i.values.passwordConfirm||i.values.password.length===0,children:"Generate certificate"})]}),children:[e.jsx("p",{children:"Protect your certificate by adding a password."}),e.jsx(s.Input,{id:"password",type:"password",label:"Password",onBlur:i.handleBlur,onChange:i.handleChange,value:i.values.password,error:i.touched.password?i.errors.password:null,help:"For macOS an empty password is not allowed. On other systems this step can be skipped."}),e.jsx(s.Input,{id:"passwordConfirm",type:"password",label:"Password confirmation",onBlur:i.handleBlur,onChange:i.handleChange,value:i.values.passwordConfirm,error:i.touched.passwordConfirm?i.errors.passwordConfirm:null})]})},A=()=>{const[l,a]=h.useState(!1),[r,i]=h.useState(!1),[t,c]=h.useState(null),{isAuthenticated:b,isAuthLoading:g}=S();if(g)return e.jsx(I,{});if(b)return e.jsx(D,{to:"/ui",replace:!0});const j=()=>{i(!1)},C=()=>{i(!0)},v=d=>{j(),a(!0);const n=new Worker(new URL("/ui/assets/certificate-3aff5cf1.js",self.location),{type:"module"});n.onmessage=o=>{c(o.data),a(!1),n.terminate()},n.onerror=o=>{console.error("Web Worker error:",o),a(!1),n.terminate()},n.postMessage(d)},k=(d,n)=>{const o=`data:application/octet-stream;base64,${n}`,p=document.createElement("a");p.href=o,p.download=d,p.click()},y=(d,n)=>{const p=`data:text/plain;charset=utf-8,${encodeURIComponent(n)}`,m=document.createElement("a");m.href=p,m.download=d,m.click()};return e.jsx(L,{mainClassName:"certificate-generate",header:e.jsx("div",{className:"p-panel__header is-sticky",children:e.jsx("h1",{className:"p-panel__title",children:"Setup LXD UI"})}),children:e.jsx(s.Row,{className:"u-no-margin--left",children:e.jsx(s.Col,{size:12,children:e.jsxs("ol",{className:"p-stepped-list--detailed",children:[e.jsx("li",{className:"p-stepped-list__item",children:e.jsxs(s.Row,{children:[e.jsx(s.Col,{size:3,children:e.jsx("h2",{className:"p-stepped-list__title p-heading--5",children:"Generate"})}),e.jsx(s.Col,{size:6,children:e.jsx("div",{className:"p-stepped-list__content",children:e.jsx("p",{children:"Create a new certificate"})})}),e.jsxs(s.Col,{size:3,children:[r&&e.jsx(z,{onClose:j,onConfirm:v}),e.jsxs(s.Button,{onClick:C,appearance:"positive",disabled:l||t!==null,hasIcon:l,"aria-label":`${l?"Generating":"Generate"} certificate`,children:[l&&e.jsx(s.Icon,{className:"is-light u-animation--spin",name:"spinner"}),e.jsx("span",{children:l?"Generating":"Generate"})]}),t!==null&&e.jsx(s.Icon,{name:"success"})]})]})}),e.jsx("li",{className:"p-stepped-list__item",children:e.jsxs(s.Row,{children:[e.jsx(s.Col,{size:3,children:e.jsx("h2",{className:"p-stepped-list__title p-heading--5",children:"Trust"})}),e.jsx(s.Col,{size:6,children:e.jsxs("div",{className:"p-stepped-list__content",children:[e.jsxs("p",{children:["Download ",e.jsx("code",{children:"lxd-ui.crt"})," and add it to the LXD trust store"]}),e.jsx("div",{className:"p-code-snippet",children:e.jsx("pre",{className:"p-code-snippet__block--icon",children:e.jsx("code",{children:"lxc config trust add Downloads/lxd-ui.crt"})})})]})}),t&&e.jsx(s.Col,{size:3,children:e.jsx(s.Button,{onClick:()=>y(`lxd-ui-${location.hostname}.crt`,t.crt),children:"Download crt"})})]})}),e.jsx("li",{className:"p-stepped-list__item",children:e.jsxs(s.Row,{children:[e.jsx(s.Col,{size:3,children:e.jsx("h2",{className:"p-stepped-list__title p-heading--5",children:"Import"})}),e.jsx(s.Col,{size:8,children:e.jsx(X,{sendPfx:t?()=>k(`lxd-ui-${location.hostname}.pfx`,t.pfx):void 0})})]})}),e.jsx("li",{className:"p-stepped-list__item u-no-margin--bottom",children:e.jsxs(s.Row,{children:[e.jsx(s.Col,{size:3,children:e.jsx("h2",{className:"p-stepped-list__title p-heading--5",children:"Done"})}),e.jsx(s.Col,{size:6,children:e.jsx("div",{className:"p-stepped-list__content",children:e.jsx("p",{children:"Enjoy LXD UI."})})})]})})]})})})})};export{A as default};