简体   繁体   English

由于连接不安全,Okta 未重定向

[英]Okta Not Redirecting due to insecure connection

I got a request from the partner website to establish SSO with them and they provided their OKTA keys to us.我从合作伙伴网站收到了与他们建立 SSO 的请求,他们向我们提供了他们的 OKTA 密钥。

Vue.use(Auth, {
  issuer: 'https://{theirURL}.com/',
  clientId: '{theirCliendId}',
  redirectUri: 'http://localhost:8080/auth/callback',
  scope: 'openid profile email'
})


let token = {};

const handleAuth = cb => {
  webAuth.parseHash((error, authResult) => {
    if (authResult && authResult.accessToken && authResult.idToken) {
      token.accessToken = authResult.accessToken;
      token.idToken = authResult.idToken;
      token.expiry = new Date().getTime() + authResult.expiresIn * 100000000;
      cb();
    } else {
      console.log(error);
    }
  });
};

const isLogged = () => {
  console.log("heyt", token)
  return token.accessToken && new Date().getTime() < token.expiry;
};

const login = () => {
  webAuth.authorize();
};

const logUserOut = () => {
  token = {};
};

above is the code I used for setting up and I was able to get to their Login page from my website and I was able to signin.以上是我用于设置的代码,我能够从我的网站访问他们的登录页面,并且能够登录。

However, when it was redirecting to my side (LOCALHOST), it gave me an error as below但是,当它重定向到我这边(LOCALHOST)时,它给了我一个错误,如下所示

This site can't provide a secure connection此站点无法提供安全连接

What am I doing wrong?我究竟做错了什么? Is it impossible to test in on localhost?在本地主机上测试是不可能的吗? They mustve been testing on localhost when they were developing.他们在开发时一定在 localhost 上进行了测试。

Please let me know what to do!!请让我知道该怎么做!! Thanks in advance!提前致谢!

Edit:编辑:

Access to fetch at 'https://{theirURL}' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. CORS 策略已阻止从源“http://localhost:8080”获取“https://{theirURL}”的访问权限:请求的资源上不存在“Access-Control-Allow-Origin”header。 If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.如果不透明的响应满足您的需求,请将请求的模式设置为“no-cors”以获取禁用 CORS 的资源。

This message is shown on console after it was logged in and tried to redirect back to my page.此消息在登录并尝试重定向回我的页面后显示在控制台上。

The quickest and simplest solution is the following:最快和最简单的解决方案如下:

"serve": "vue-cli-service serve --https true"

Then, just say "okay" when it's warning you that the connection is not safe and you're ready using https on localhost!然后,当它警告您连接不安全并且您已准备好在 localhost 上使用https时,只需说“好的”!

As shown in this answer: https://stackoverflow.com/a/64149923/8816585如这个答案所示: https://stackoverflow.com/a/64149923/8816585

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM