Grails 来自外部链接的用户无效

Grails 来自外部链接的用户无效,grails,spring-security,Grails,Spring Security,我有一个网站,输出Excel报告与超链接回到安全的内容。其中一个链接看起来像这样 http://www.[site].com/externalLinkDigester?externalSession=[SHA Encrypted Text] class ExternalLinkDigester{ def springSecurityService; def index = { def currentUser = springSecurityService?.c

我有一个网站,输出Excel报告与超链接回到安全的内容。其中一个链接看起来像这样

http://www.[site].com/externalLinkDigester?externalSession=[SHA Encrypted Text]
class ExternalLinkDigester{

   def springSecurityService;

    def index = {
        def currentUser = springSecurityService?.currentUser

        if (!currentUser){
            redirect(controller:'login')
        }

        def request = ExternalSession.findByName(params.externalSession);

        if (request.isExpired(){
            //show expired content page
        }


        if (sameUser(currentUser, request.user){
            //show content
        }else{
            redirect(controller:'login')
        }



    }
}
查询字符串参数(externalSession)是唯一的字母数字字符串,仅在24小时内有效,并且只能由创建报表的用户访问。我的控制器看起来像这样

http://www.[site].com/externalLinkDigester?externalSession=[SHA Encrypted Text]
class ExternalLinkDigester{

   def springSecurityService;

    def index = {
        def currentUser = springSecurityService?.currentUser

        if (!currentUser){
            redirect(controller:'login')
        }

        def request = ExternalSession.findByName(params.externalSession);

        if (request.isExpired(){
            //show expired content page
        }


        if (sameUser(currentUser, request.user){
            //show content
        }else{
            redirect(controller:'login')
        }



    }
}
问题是,无论springSecurityService.currentUser来自Excel等外部程序时,无论是什么,即使我在单击链接之前已登录,它始终为空。但是,如果我将链接复制并粘贴到浏览器中,它似乎可以正常工作。救命啊


如何以这种方式安全地访问内容?

是否可能Excel打开的浏览器与您登录的浏览器不同(例如,您使用Firefox登录,单击Excel中的链接时,默认打开Internet Explorer中的链接)。新浏览器将不具有已验证会话的会话cookie,因此“currentUser”将显示为空。

如果链接位于其他应用程序(如MS Word或outlook)中,该功能是否有效?它是具有新选项卡的同一浏览器。您的浏览器和版本是什么?据我所知,正常的行为是,如果同一会话是cookie,则所有选项卡都可以重用该会话。除非您的网站使用无cookie会话机制,即在URL中作为参数传递特殊标识符字符串。但是,基于您的示例,情况似乎并非如此,因为我没有看到任何其他参数。