小编fob*_*oss的帖子

Spring Social OAuth2'state'参数缺失或不匹配?

我正在使用Jhipster和Jhipster-ionic以及cordova开发移动应用程序.目前,我使用基于令牌的AngularJS身份验证(Satellizer)登录OAuth 2.0,我遇到了Spring Social的问题,这是我日志中的例外:

 java.lang.IllegalStateException: The OAuth2 'state' parameter is missing or doesn't match.
 at org.springframework.social.connect.web.ConnectSupport.verifyStateParameter(Connec  tSupport.java:173)
   at org.springframework.social.connect.web.ConnectSupport.completeConnection(ConnectSupport.java:155)
at org.springframework.social.connect.web.ProviderSignInController.oauth2Callback(ProviderSignInController.java:228)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497) 
Run Code Online (Sandbox Code Playgroud)

我在后端进行了调试,问题来自ConnectSupport类中的该函数

private void verifyStateParameter(NativeWebRequest request) {
String state = request.getParameter("state");
String originalState = extractCachedOAuth2State(request);
if (state == null || !state.equals(originalState)) {
    throw new IllegalStateException("The OAuth2 'state' parameter is missing    or doesn't match.");
   }
 }
Run Code Online (Sandbox Code Playgroud)

我的状态由Satellizer初始化,但originalState始终为null.任何人都对Spring Social上的这个问题有所了解.

这是我正面代码的概述:

 .config(function($authProvider) {
   $authProvider.httpInterceptor = false;
   $authProvider.withCredentials = true;

    var commonConfig = {
      popupOptions: { …
Run Code Online (Sandbox Code Playgroud)

spring spring-social angularjs jhipster satellizer

7
推荐指数
0
解决办法
425
查看次数

Angular/Rxjs 管道异步不适用于 ssr?

我在 SSR 上运行的异步管道有问题。没有错误,只有无限循环(似乎服务器正在等待 observable 被解析)。

我在用:

  1. @nestjs/ng-universal
  2. 角 9
  3. 火力基地
  4. 接收器

像这样的简单案例有效:

<p>{{ observable | async }}</p>
Run Code Online (Sandbox Code Playgroud)

但是使用结构指令不起作用:

如果

<p *ngIf="(observable$ | async) > 5">{{ observable$ | async }}</p>
Run Code Online (Sandbox Code Playgroud)

恩福

<p *ngFor="let item of items | async">{{ item }}</p>
Run Code Online (Sandbox Code Playgroud)

使用 async 是一个很好的做法,因为它会避免手动取消订阅以避免组件销毁时内存泄漏。但是,使用手动取消订阅有效。

更新 08/06/2020

当我在http://localhost:4200之后添加 index.html 时,应用程序会加载

异步在模板中是这样的:

<ng-container *ngIf="currentUser$ | async; else loadingUser">
Run Code Online (Sandbox Code Playgroud)

并且 currentUser$ 是在ngOnInit组件的方法中设置的:

  ngOnInit(): void {
    this.currentUser$ = this.authService.currentUser$;
  }
Run Code Online (Sandbox Code Playgroud)

更新 16/06/2020

当我们在组件中删除所有 OnPush 检测策略的使用时,即使在结构指令中使用异步,SSR 模式也能工作。

所以这似乎表明在结构指令中使用带有异步的 OnPush TOGETHER 在 SSR 模式下不起作用。 …

rxjs server-side-rendering angular-universal angular nestjs

5
推荐指数
1
解决办法
893
查看次数