成功登录后,后端中的Azure Active Directory会将前端应用程序重定向到登录页面

我对Azure active Directory有问题。我的后端是用kotlin编写的,并且使用Spring Security进行端点认证。使用@PreAuthorize(hasRole = xx)保护端点。

此应用程序的前端是用react编写的。为了保护它,我使用了react aad msal软件包。

现在,在前端成功登录后,我的应用程序应调用API的端点,但我得到的不是

  

在'https://login.microsoftonline.com/common/oauth2/authorize处获取数据的访问权限? %3D&redirect_uri = http://localhost:8080/login/oaut>源自“空”的源代码“ h2 / code / azure”(从>“ http://localhost:8080/monitoring/emails/templates”重定向)已被CORS策略阻止:对预检请求的响应未通过访问控制>检查:所请求的资源上不存在“ access-control-allow-origin”标头。如果不透明的响应满足您的需求,请将请求的模式设置为“ no-?> cors”以在禁用CORS的情况下获取资源

并且找不到任何解决方案。

这是我的安全配置:

    public static function addMissingDates($dateStart,$dateEnd,$expTables) {
        $newExpTable = [];
        $begin = new DateTime( $dateStart );
        $end = new DateTime($dateEnd);
        $end = $end->modify( '+1 day' );

        $interval = new DateInterval('P1D');
        $daterange = new DatePeriod($begin,$interval,$end);

        foreach($daterange as $date) {
            foreach ($expTables as $expTable) {
                if($date->format("Y-m-d") === $expTable->date) {
                    $newExpTable[] = $expTable;
                    continue 2;
                }
            }
            $exp = new \stdClass();
            $exp->found = false;
            $exp->date = $date->format("Y-m-d");
            $newExpTable[] = $exp;
        }


        return $newExpTable;
    }
xiangan2010 回答:成功登录后,后端中的Azure Active Directory会将前端应用程序重定向到登录页面

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3089651.html

大家都在问