[英]Okta login page goes to infinite loop after user authentication
like this像这样
My Angular app integrated Okta access and user management API. The application backend is hosted in AWS Beanstaik and front end angular app is hosted S3.我的 Angular 应用程序集成了 Okta 访问和用户管理 API。应用程序后端托管在 AWS Beanstaik 中,前端 angular 应用程序托管在 S3 中。
I checked the.network response by chrome dev tools and I got this我通过 chrome 开发工具检查了 .network 响应,我得到了这个
{"expiresAt":"2021-09-03T02:59:39.000Z","status":"SUCCESS","sessionToken":"20111F_ApSDB7zPMeay5y2V4nG8yUlU0i4ICgHyAOMYvc5Miq743wse","_embedded":{"user":{"id":"00ubopju1CRuT02ji5d6","passwordChanged":"2021-03-13T22:58:33.000Z","profile":{"login":"Rafi12534@Gmail.com","firstName":"Mohammed","lastName":"Samsuddin","locale":"en","timeZone":"America/Los_Angeles"}}},"_links":{"cancel":{"href":"https://dev-97379822.okta.com/api/v1/authn/cancel","hints":{"allow":["POST"]}}}}
login component code:登录组件代码:
import { Component, OnInit } from '@angular/core';
import { OktaAuthService } from '@okta/okta-angular';
import * as OktaSignIn from '@okta/okta-signin-widget';
import myAppConfig from '../../config/my-app-config';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
oktaSignin: any;
constructor(private oktaAuthService: OktaAuthService) {
this.oktaSignin = new OktaSignIn({
logo: 'assets/images/logo_for_favicon.png',
features: {
registration: true
},
baseUrl: myAppConfig.oidc.issuer.split('/oauth2')[0], // return everything in url before '/oauth2'
clientId: myAppConfig.oidc.clientId,
redirectUri: myAppConfig.oidc.redirectUri,
authParams: {
pkce: true, // Proof Key for Code Exchange.
// Proof Key for Code Exchange (PKCE, pronounced pixie)
// extension describes a technique for public clients to mitigate
// the threat of having the authorization code intercepted.
issuer: myAppConfig.oidc.issuer,
scopes: myAppConfig.oidc.scopes
}
});
}
ngOnInit(): void {
this.oktaSignin.remove(); // remove previous element that rendered there
this.oktaSignin.renderEl({
el: '#okta-sign-in-widget'}, // render element with given id
// this name should be same as div tag id in login.component.html
(response) => {
if (response.status === "SUCCESS") {
this.oktaAuthService.signInWithRedirect();
}
},
(error) => {
throw error;
}
);
}
}
After authentication okta try to authenticate again that's what maybe put it into infinite loop.身份验证后,okta 尝试再次进行身份验证,这可能会使它陷入无限循环。
I had the same problem and I solve it like this:我有同样的问题,我是这样解决的:
In the my-app-config file in your case, Its probably configured like that, pointing localhost in the redirectUri:在你的 my-app-config 文件中,它可能是这样配置的,在 redirectUri 中指向本地主机:
Just change it to your real url for example:只需将其更改为您的真实 url 例如:
redirectUri: 'http://example.com/login/callback'
And it should resolve the auth loop.它应该解决身份验证循环。
I hope that solves the problem for you!我希望这能为您解决问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.