2015-04-17 21 views
8

我只想知道是否有任何方法可以跳過Spring Boot中的用戶審批屏幕 - Spring Security OAuth2。我聽說過自定義用戶審批處理程序,但我不確定如何覆蓋它以禁用用戶審批流程並執行直接重定向。在Spring Boot中跳過OAuth用戶審批OAuth2

謝謝

+0

有什麼理由?我有這種形式返回到我的/授權請求,我想禁用它,但我不知道這是否是安全和良好的解決方案! – BigDong

回答

13

您不需要自定義處理程序跳過批准(因爲無論如何2.0)。您只需將客戶端詳細信息中的autoApprove標誌設置爲「true」(或要自動批准的範圍模式列表)即可。

+2

爲了確保這個特別清晰,請注意@Dave Syer已經將其引用至報價中。如果您將客戶端詳細信息存儲在數據庫中,則此值需要是數據庫中的字符串,而不是true的布爾值。 – petesavitsky

+0

這似乎不適用於'authorization_code'授權類型。 – eugene

+0

恰恰當它工作時。不確定你的意思。 –

2

這是我改變了它在我的JHipster應用:

 @Override 
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception { 
     clients 
      .inMemory() 
      .withClient(jhipsterProperties.getSecurity().getAuthentication().getOauth().getClientid()) 
      .autoApprove(true) 
      .scopes("read", "write") 
      .authorities(AuthoritiesConstants.ADMIN, AuthoritiesConstants.USER) 
      .authorizedGrantTypes("password", "refresh_token") 
      .secret(jhipsterProperties.getSecurity().getAuthentication().getOauth().getSecret()) 
      .accessTokenValiditySeconds(jhipsterProperties.getSecurity().getAuthentication().getOauth().getTokenValidityInSeconds()); 
    } 
相關問題