docker desktop url protocl 技术以及使用

docker desktop 在登录的使用使用了自定义的url 协议,同时基于web 进行系统登录,认证完成之后会生成code,之后通过
url 协议进入

使用

  • docker
    协议定义
 
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLName</key>
    <string>docker-desktop</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>docker-desktop</string>
    </array>
  </dict>
</array>

js 使用
https://d36jcksde1wxzq.cloudfront.net/9241.d6356172711deaa97954.js
处理

 
function v() {
        const {search: a} = (0,
        s.TH)()
          , e = p()
          , c = `docker-desktop://auth0/complete-login${a}`;
        return (0,
        l.useEffect)((()=>{
            window.Cypress || (window.location.href = c)
        }
        ), [c]),
        l.createElement(l.Fragment, null, l.createElement(h.ql, {
            title: "Redirecting..."
        }), l.createElement(t.Z, {
            maxWidth: "sm",
            className: e.root,
            "data-testid": "desktop-auth-page"
        }, l.createElement(m.Z, {
            className: e.logo
        }), l.createElement(n.Z, {
            className: e.paper
        }, l.createElement(r.Z, {
            variant: "h2",
            component: "h1",
            className: e.title
        }, "You're almost done!"), l.createElement(r.Z, {
            className: e.explanation
        }, "We're redirecting you to the desktop app. If you don't see a dialog, please click the button below."), l.createElement(o.Z, {
            href: c,
            variant: "contained",
            color: "primary"
        }, "Proceed to Docker Desktop"))))
    }
}

参考请求格式

docker-desktop://auth0/complete-login?code=<code>

说明

app protocl 在一些基于web 认证的桌面应用中使用比较多,比如electron 就支持app protocl 可以方便的做一些认证集成
语雀,飞书等应用都已经默认包含了自己的url protocl

参考资料

https://www.npmjs.com/package/protocol-registry
https://github.com/Shubham-Kumar-2000/protocol-registry
https://stackoverflow.com/questions/18534591/how-to-register-a-url-protocol-handler-in-node-js/67231906#67231906
http://www.electronjs.org/docs/latest/api/protocol

posted on 2022-10-14 10:30  荣锋亮  阅读(47)  评论(0编辑  收藏  举报

导航