我有一个带有用于身份验证的 oidc 客户端的 Angular 应用程序,该代码在 Chrome 和 Edge 上运行良好,但是当我尝试使用 Safari 进行身份验证时,它在多次重试/错误后工作,而在 Firefox 上它根本不起作用。我得到的错误是这样的:
Error: Uncaught (in promise): Error: No matching state found in storage
x</t.prototype.processSigninResponse/<@webpack-internal:///../../../../oidc-client/lib/oidc-client.min.js:1:5057
ZoneDelegate.prototype.invoke@webpack-internal:///../../../../zone.js/dist/zone.js:388:17
onInvoke@webpack-internal:///../../../core/esm5/core.js:4947:24
ZoneDelegate.prototype.invoke@webpack-internal:///../../../../zone.js/dist/zone.js:387:17
Zone.prototype.run@webpack-internal:///../../../../zone.js/dist/zone.js:138:24
scheduleResolveOrReject/<@webpack-internal:///../../../../zone.js/dist/zone.js:858:52
ZoneDelegate.prototype.invokeTask@webpack-internal:///../../../../zone.js/dist/zone.js:421:17
onInvokeTask@webpack-internal:///../../../core/esm5/core.js:4938:24
ZoneDelegate.prototype.invokeTask@webpack-internal:///../../../../zone.js/dist/zone.js:420:17
Zone.prototype.runTask@webpack-internal:///../../../../zone.js/dist/zone.js:188:28
drainMicroTaskQueue@webpack-internal:///../../../../zone.js/dist/zone.js:595:25
Stack trace:
resolvePromise@webpack-internal:///../../../../zone.js/dist/zone.js:809:31
resolvePromise@webpack-internal:///../../../../zone.js/dist/zone.js:775:17
scheduleResolveOrReject/<@webpack-internal:///../../../../zone.js/dist/zone.js:858:17
ZoneDelegate.prototype.invokeTask@webpack-internal:///../../../../zone.js/dist/zone.js:421:17
onInvokeTask@webpack-internal:///../../../core/esm5/core.js:4938:24
ZoneDelegate.prototype.invokeTask@webpack-internal:///../../../../zone.js/dist/zone.js:420:17
Zone.prototype.runTask@webpack-internal:///../../../../zone.js/dist/zone.js:188:28
drainMicroTaskQueue@webpack-internal:///../../../../zone.js/dist/zone.js:595:25
在我看来,它必须按照浏览器管理存储的方式进行,但我不确定这是否还有其他原因。我拥有的版本:
"@angular/animations": "5.2.1",
"@angular/common": "5.2.1",
"@angular/compiler": "5.2.1",
"@angular/core": "5.2.1",
"@angular/forms": "5.2.1",
"@angular/http": "5.2.1",
"@angular/platform-browser": "5.2.1",
"@angular/platform-browser-dynamic": "5.2.1",
"@angular/platform-server": "5.2.1",
"@angular/router": "5.2.1",
"@ng-bootstrap/ng-bootstrap": "1.0.0",
"@nguniversal/express-engine": "5.0.0-beta.5",
"@nguniversal/module-map-ngfactory-loader": "5.0.0-beta.5",
"bootstrap": "4.0.0-beta.2",
"core-js": "2.5.3",
"font-awesome": "4.7.0",
"oidc-client": "1.4.1",
"rxjs": "5.5.6",
"zone.js": "0.8.20"
处理认证回调的代码非常简单:
completeAuthentication(): Promise<void> {
if (isPlatformBrowser(this.platformId)) {
return this.manager.signinRedirectCallback()
.then(user => {
this.user = user;
});
}
}
manager
一个UserManager
实例在哪里:
@Injectable()
export class AuthService {
private manager: UserManager;
private user: User = null;
constructor(@Inject(PLATFORM_ID) private platformId: Object) {
if (isPlatformBrowser(platformId)) {
this.manager = new UserManager(getClientSettings());
this.manager.getUser().then(user => {
this.user = user;
});
}
任何想法为什么相同的代码在不同的浏览器上失败?