star7th / showdoc

ShowDoc is a tool greatly applicable for an IT team to share documents online一个非常适合IT团队的在线API文档、技术文档工具
https://www.showdoc.com.cn
Other
12.16k stars 2.18k forks source link

通用登录生成的特殊链接,通过iframe的方式嵌入,会自动跳到登录页面,请教大神们怎样处理?翻遍了整个issues,也没找到答案! #2218

Open lvreninfo opened 2 months ago

lvreninfo commented 2 months ago

通用登录生成的特殊链接,通过iframe的方式嵌入打开,会自动跳到登录页面,请教大神们怎样处理?? 翻遍了整个issues,也没找到答案!

showdoc.vue

<template>
   <iframe :src="iframeSrc" class="showdoc_iframe" frameborder="0" /> 
</template>

   <script lang="ts" setup>
    import md5 from 'js-md5'

    const host = 'http://192.168.8.20:7001'
    const timeStamp = Date.now() * 1000
    const username = 'jyp'

    const redirect = encodeURIComponent('http://192.168.8.20:7001/web/#/item/index')
    const LoginSecretKey = 'e2de81cfd831bc68bd1aba74cf1fc368'
    const token = md5(`${username}${LoginSecretKey}${timeStamp}`)

    const iframeSrc = `${host}/server/?s=/api/extLogin/bySecretKey&username=${username}&time=${timeStamp}&token=${token}&redirect=${redirect}`

 </script>

当你直接访问通过浏览器地址栏访问 iframeSrc 地址,是正常登录并跳转了!通过iframe就会自动跳到登录页面

star7th commented 2 months ago

不清楚。不打算支持这种方式。这种方式可能会引起安全问题。

suyuanlin commented 1 week ago

不清楚。不打算支持这种方式。这种方式可能会引起安全问题。

大佬,有解决方案吗?可以设置md5是一次性的,每次都是新的md5,这样安全又上升了一个台阶

star7th commented 1 week ago

没有解决方案。MD5不解决问题。只要暴露到前端,就是不安全