spring-attic / spring-security-oauth

Support for adding OAuth1(a) and OAuth2 features (consumer and provider) for Spring web applications.

Home Page:http://github.com/spring-projects/spring-security-oauth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

这段代码可以优化(this code below can be optimise)

lingpeiyong opened this issue · comments

image
代码位置(file location):/spring-security-oauth/spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/request/DefaultOAuth2RequestFactory.java

  1. checkUserScopes 这个方法不需要clientDetails这个参数(the method of checkUserScopes is not need clientDetails parameter)
  2. extractScopes 这个方法里clientDetailsService.loadClientByClientId(clientId) 可以放在 if ((scopes == null || scopes.isEmpty())) 方法里,这样当判断为false时,可以减少一次数据库的查询操作。
    clientDetailsService.loadClientByClientId(clientId) in the method of "extractScopes" can be write in the body of " if ((scopes == null || scopes.isEmpty())) " , that can reduce one database query operation

wether loadClientByClientId is going to query database is determined by ur loadClientByClientId method implication.
you can cache Details