/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/CertificateGenerate-BZlwN6Mx.js
import{r as m,f as k,g as _,h as v,i as y,j as e,d as t,u as I,c as S,b as F,N as M}from"./index-B3cgCbnJ.js";const G=({onConfirm:s,onClose:o,isPasswordRequired:r})=>{const[a,n]=m.useState(r),l=k().shape({password:_(),passwordConfirm:_().oneOf([v("password"),""],"Passwords must match")}),i=y({initialValues:{password:"",passwordConfirm:""},validationSchema:l,onSubmit:x=>{s(x.password)}}),h=()=>{s("")};return e.jsxs(t.Modal,{close:o,title:"Create Certificate",buttonRow:e.jsx(e.Fragment,{children:a?e.jsx(t.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>void i.submitForm(),disabled:i.values.password!==i.values.passwordConfirm||i.values.password.length===0,children:"Generate and download"}):e.jsx(t.Button,{appearance:"positive",className:"u-no-margin--bottom",onClick:h,children:"Generate and download"})}),children:[e.jsx(t.Notification,{severity:"caution",className:"u-no-margin--bottom",children:"Passwords are required for client certificates on macOS. On other platforms, a password is optional."}),e.jsx(t.Switch,{label:"Password protected",checked:a,onChange:()=>{n(!a)}}),a&&e.jsxs(e.Fragment,{children:[e.jsx(t.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}),e.jsx(t.Input,{id:"passwordConfirm",type:"password",label:"Confirm password",onBlur:i.handleBlur,onChange:i.handleChange,value:i.values.passwordConfirm,error:i.touched.passwordConfirm?i.errors.passwordConfirm:null})]})]})},R=({isPasswordRequired:s})=>{const[o,r]=m.useState(!1),[a,n]=m.useState(!1),[l,i]=m.useState(null),h=()=>{n(!1)},x=()=>{n(!0)},C=f=>{h(),r(!0);const c=new Worker(new URL("/ui/assets/certificate-CjDjm-lw.js",import.meta.url),{type:"module"});c.onmessage=d=>{i(d.data),r(!1),N(`lxd-ui-${location.hostname}.pfx`,d.data.pfx),c.terminate()},c.onerror=d=>{console.error("Web Worker error:",d),r(!1),c.terminate()},c.postMessage(f)},N=(f,c)=>{const d=`data:application/octet-stream;base64,${c}`,j=document.createElement("a");j.href=d,j.download=f,j.click()};return e.jsxs(e.Fragment,{children:[a&&e.jsx(G,{onClose:h,onConfirm:C,isPasswordRequired:s}),e.jsxs("div",{children:[e.jsxs(t.Button,{onClick:x,disabled:o||l!==null,className:"u-no-margin--bottom",hasIcon:!0,"aria-label":`${o?"Generating":"Generate"} certificate`,children:[o?e.jsx(t.Icon,{className:"u-animation--spin",name:"spinner"}):e.jsx(t.Icon,{name:"begin-downloading",alt:"download"}),e.jsx("span",{children:o?"Generating":"Generate certificate"})]}),l!==null&&e.jsx(t.Icon,{name:"success"})]})]})},p="Firefox",w="Chrome on Linux",g="Chrome on Windows",b="Microsoft Edge",u="macOS",A=[p,w,g,b,u],E=()=>{const s=navigator.userAgent.toLowerCase(),o=s.includes("macintosh")||s.includes("mac os"),r=s.includes("windows"),a=s.includes("linux"),n=s.includes("edg/"),l=s.includes("firefox"),i=s.includes("chrome");return l?p:o?u:n?b:i&&r?g:i&&a?w:p},L=()=>{const[s,o]=m.useState(E()),r=e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:"p-list__item",children:["In the modal that appears, click ",e.jsx("b",{children:"Import..."})]}),e.jsxs("li",{className:"p-list__item",children:["Follow the instructions in the Certificate Import Wizard. When prompted with ",e.jsx("b",{children:"File to Import"}),", click ",e.jsx("b",{children:"Browse"})," and choose the certificate you downloaded. In order to see the certificate file, ensure that the file type picker is set to"," ",e.jsx("b",{children:"Personal Information Exchange (*.pfx;*.p12)"}),"."]}),e.jsx("li",{className:"p-list__item",children:e.jsx("b",{children:"Restart the browser."})})]}),a=e.jsxs("li",{className:"p-list__item u-clearfix",children:["Create and download a client certificate:",e.jsx(R,{isPasswordRequired:s===u})]});return e.jsx(t.Row,{children:e.jsxs(t.Col,{size:10,children:[e.jsx(t.Tabs,{links:A.map(n=>({label:n,active:n===s,onClick:()=>{o(n)}}))}),s===p&&e.jsx("div",{role:"tabpanel","aria-label":"firefox",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[a,e.jsxs("li",{className:"p-list__item",children:["Go to Firefox’s privacy settings:",e.jsx("pre",{className:"p-code-snippet__block u-no-margin--bottom",children:e.jsx("code",{children:"about:preferences#privacy"})})]}),e.jsxs("li",{className:"p-list__item",children:["Scroll down to the certificates section and click"," ",e.jsx("b",{children:"View Certificates"})]}),e.jsxs("li",{className:"p-list__item",children:["In the modal that appears, go to Your ",e.jsx("b",{children:"certificates"})," and click Import"]}),e.jsx("li",{className:"p-list__item",children:"Select the .pfx file you just downloaded. If you created a password for the certificate, type it in now."}),e.jsx("li",{className:"p-list__item",children:e.jsx("b",{children:"Restart the browser."})})]})}),s===w&&e.jsx("div",{role:"tabpanel","aria-label":"chrome linux",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[a,e.jsxs("li",{className:"p-list__item",children:["Go to the import certificate page within Chrome's certificate manager:",e.jsx("pre",{className:"p-code-snippet__block u-no-margin--bottom",children:e.jsx("code",{children:"chrome://certificate-manager/clientcerts/platformclientcerts"})})]}),e.jsxs("li",{className:"p-list__item",children:["Select ",e.jsx("b",{children:"Import"})," and choose the .pfx file you just downloaded. If you created a password for the certificate, type it in now."]}),e.jsx("li",{className:"p-list__item",children:e.jsx("b",{children:"Restart the browser."})})]})}),s===g&&e.jsx("div",{role:"tabpanel","aria-label":"chrome windows",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[a,e.jsxs("li",{className:"p-list__item",children:["Go to Chrome's certificate settings:",e.jsx("pre",{className:"p-code-snippet__block u-no-margin--bottom",children:e.jsx("code",{children:"chrome://settings/certificates"})})]}),e.jsxs("li",{className:"p-list__item",children:["Near the bottom of the page, click ",e.jsx("b",{children:"Manage certificates"})]}),e.jsxs("li",{className:"p-list__item",children:["Make sure"," ",e.jsx("b",{children:"Use imported local certificates from your operating system"})," ","is toggled on, and click"," ",e.jsx("b",{children:"Manage imported certificates from Windows"})," "]}),r]})}),s===b&&e.jsx("div",{role:"tabpanel","aria-label":"edge windows",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[a,e.jsxs("li",{className:"p-list__item",children:["Go to Edge's certificate settings:",e.jsx("pre",{className:"p-code-snippet__block u-no-margin--bottom",children:e.jsx("code",{children:"edge://settings/privacy"})})]}),e.jsxs("li",{className:"p-list__item",children:["Under ",e.jsx("b",{children:"Security"}),", click ",e.jsx("b",{children:"Manage certificates"})]}),r]})}),s===u&&e.jsx("div",{role:"tabpanel","aria-label":"safari macos",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[a,e.jsxs("li",{className:"p-list__item",children:["Launch the ",e.jsx("b",{children:"Keychain Access app"})," (you will need to authenticate using your mac’s login credentials)"]}),e.jsxs("li",{className:"p-list__item",children:["Import the certificate file that was created earlier. This can be done either by dragging the file from Finder onto Keychain Access, or with ",e.jsx("b",{children:" File > Import Items..."})]}),e.jsx("li",{className:"p-list__item",children:"Unlock the certificate by typing in the password used to create it."}),e.jsx("li",{className:"p-list__item",children:e.jsx("b",{children:"Restart the browser."})})]})})]})})},O=()=>{const{isAuthenticated:s,isAuthLoading:o}=I(),r=S(),{data:a}=F(),n=a==null?void 0:a.client_certificate;return o?e.jsx(t.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0}):s?e.jsx(M,{to:"/ui",replace:!0}):e.jsx(t.CustomLayout,{mainClassName:"certificates",children:e.jsxs(t.Row,{children:[e.jsx(t.Col,{size:1}),e.jsxs(t.Col,{size:10,children:[e.jsxs(t.Notification,{actions:n?[]:[{label:"I already have a client certificate",onClick:()=>{r("/ui/login/certificate-add")}}],title:"TLS login",severity:"information",children:["LXD uses mutual TLS for server client-server authentication. Your browser must have a client certificate installed and selected in order to proceed."," ",e.jsxs("a",{href:"https://github.com/canonical/lxd-ui/wiki/Authentication-Setup-FAQ",target:"_blank",rel:"noopener noreferrer",children:["Authentication Setup FAQ",e.jsx(t.Icon,{className:"external-link-icon",name:"external-link"})]})]}),n&&e.jsx(t.Notification,{actions:[{label:"Skip to step 2: Identity trust token",onClick:()=>{r("/ui/login/certificate-add")}}],title:"Client certificate already present",severity:"positive",children:"It looks like you already have a client certificate installed and selected, skip to the next step."}),e.jsx(L,{})]})]})})};export{O as default};
Copyright ©2k19 -
Hexid
|
Tex7ure