ONLYOFFICE协作编辑页面中文档下载地址url携带(传输)sessionid测试

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hotqin888/article/details/82818559

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方式。

猜你喜欢

转载自blog.csdn.net/hotqin888/article/details/82818559