1

我有一个带有用于身份验证的 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;
            });
        }

任何想法为什么相同的代码在不同的浏览器上失败?

4

1 回答 1

1

我意识到我正在独立于实际承诺执行重定向,completeAuthentication()因此我失败了。我只是将它添加到then,一切都很好。

于 2018-02-05T09:18:32.087 回答