admin管理员组文章数量:1644604
onlyoffice协作页面里有个文档下载地址,这个地址是第一个人打开这个文档的时候,服务器会根据这个文档地址,将文档管理服务器里的文档下载到onlyoffice document server的内存中,第二个人打开就直接用key打开了……
问题是,这个文档地址,如何确权呢,因为onlyoffice在请求这个地址的时候,估计请求头里没有带sessionid,所以即使用户登录了,文档无服务器端也无法取得用户的登录信息。
将这个文档地址,带上sessionid就行了。
"document": {
"fileType": "{{.fileType}}",
"key": "{{.Key}}",//"Khirz6zTPdfd7"
"title": "{{.Doc.FileName}}",
"url": "http://192.168.99.1/attachment/onlyoffice/{{.Doc.FileName}}?hotqinsessionid={{.Sessionid}}",
"info": {
这样,在文档服务器端,可以直接取得用户登录名了。
beego:
//用户登录后,服务器端将信息写入session
func (c *LoginController) LoginPost() {
if err == nil {
c.SetSession("uname", user.Username)
c.SetSession("pwd", user.Password)
…………
//浏览器请求下载文档
func (c *AttachController) Attachment() {
var useridstring string
_, _, uid, isadmin, _ := checkprodRole(c.Ctx)
// if uid != 0 {
useridstring = strconv.FormatInt(uid, 10)
//根据请求携带的sessionid获取用户登录信息
func checkprodRole(ctx *context.Context) (uname, role string, uid int64, isadmin, islogin bool) {
v := ctx.Input.CruSession.Get("uname")
当然,官方推荐的是token方式。
版权声明:本文标题:ONLYOFFICE协作编辑页面中文档下载地址url携带(传输)sessionid测试 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1729392110a1199601.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论