fix: checkstyle

This commit is contained in:
vran
2022-03-02 20:11:15 +08:00
parent 57fbdbbd22
commit dfeaac5292
9 changed files with 51 additions and 51 deletions

View File

@@ -1,9 +1,9 @@
package com.databasir.api;
import com.databasir.common.JsonData;
import com.databasir.core.domain.app.OAuthAppService;
import com.databasir.core.domain.app.OpenAuthAppService;
import com.databasir.core.domain.app.data.*;
import com.databasir.core.domain.app.handler.OAuthHandler;
import com.databasir.core.domain.app.handler.OpenAuthHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -19,11 +19,11 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
@Controller
@RequiredArgsConstructor
public class OAuth2AppController {
public class OpenAuth2AppController {
private final OAuthHandler oAuthHandler;
private final OpenAuthHandler openAuthHandler;
private final OAuthAppService oAuthAppService;
private final OpenAuthAppService openAuthAppService;
/**
* 无需授权
@@ -31,7 +31,7 @@ public class OAuth2AppController {
@GetMapping("/oauth2/authorization/{registrationId}")
@ResponseBody
public JsonData<String> authorization(@PathVariable String registrationId) {
String authorization = oAuthHandler.authorization(registrationId);
String authorization = openAuthHandler.authorization(registrationId);
return JsonData.ok(authorization);
}
@@ -41,7 +41,7 @@ public class OAuth2AppController {
@GetMapping("/oauth2/apps")
@ResponseBody
public JsonData<List<OAuthAppResponse>> listApps() {
return JsonData.ok(oAuthAppService.listAll());
return JsonData.ok(openAuthAppService.listAll());
}
@GetMapping(Routes.OAuth2App.LIST_PAGE)
@@ -50,14 +50,14 @@ public class OAuth2AppController {
public JsonData<Page<OAuthAppPageResponse>> listPage(@PageableDefault(sort = "id", direction = DESC)
Pageable page,
OAuthAppPageCondition condition) {
return JsonData.ok(oAuthAppService.listPage(page, condition));
return JsonData.ok(openAuthAppService.listPage(page, condition));
}
@GetMapping(Routes.OAuth2App.GET_ONE)
@PreAuthorize("hasAnyAuthority('SYS_OWNER')")
@ResponseBody
public JsonData<OAuthAppDetailResponse> getOne(@PathVariable Integer id) {
return JsonData.ok(oAuthAppService.getOne(id));
return JsonData.ok(openAuthAppService.getOne(id));
}
@@ -65,7 +65,7 @@ public class OAuth2AppController {
@PreAuthorize("hasAnyAuthority('SYS_OWNER')")
@ResponseBody
public JsonData<Integer> create(@RequestBody @Valid OAuthAppCreateRequest request) {
Integer id = oAuthAppService.create(request);
Integer id = openAuthAppService.create(request);
return JsonData.ok(id);
}
@@ -73,7 +73,7 @@ public class OAuth2AppController {
@PreAuthorize("hasAnyAuthority('SYS_OWNER')")
@ResponseBody
public JsonData<Void> updateById(@RequestBody @Valid OAuthAppUpdateRequest request) {
oAuthAppService.updateById(request);
openAuthAppService.updateById(request);
return JsonData.ok();
}
@@ -81,7 +81,7 @@ public class OAuth2AppController {
@PreAuthorize("hasAnyAuthority('SYS_OWNER')")
@ResponseBody
public JsonData<Void> deleteById(@PathVariable Integer id) {
oAuthAppService.deleteById(id);
openAuthAppService.deleteById(id);
return JsonData.ok();
}
}

View File

@@ -1,7 +1,6 @@
package com.databasir.api.config;
import com.databasir.api.Routes;
import com.databasir.api.config.oauth2.DatabasirOauth2LoginFilter;
import com.databasir.api.config.security.*;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
@@ -46,7 +45,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.and()
.authorizeRequests()
.antMatchers("/login", Routes.Login.REFRESH_ACCESS_TOKEN).permitAll()
.antMatchers("/oauth2/apps", "/oauth2/failure", "/oauth2/authorization/*", "/oauth2/login/*").permitAll()
.antMatchers("/oauth2/apps", "/oauth2/failure", "/oauth2/authorization/*", "/oauth2/login/*")
.permitAll()
.antMatchers("/", "/*.html", "/js/**", "/css/**", "/img/**", "/*.ico").permitAll()
.anyRequest().authenticated()
.and()

View File

@@ -2,7 +2,7 @@ package com.databasir.api.config.oauth2;
import com.databasir.api.config.security.DatabasirUserDetailService;
import com.databasir.core.domain.user.data.UserDetailResponse;
import com.databasir.core.domain.app.OAuthAppService;
import com.databasir.core.domain.app.OpenAuthAppService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
@@ -28,16 +28,16 @@ public class DatabasirOauth2LoginFilter extends AbstractAuthenticationProcessing
public static final String OAUTH_LOGIN_URI = "/oauth2/login/*";
@Autowired
private OAuthAppService oAuthAppService;
private OpenAuthAppService openAuthAppService;
@Autowired
private DatabasirUserDetailService databasirUserDetailService;
public DatabasirOauth2LoginFilter(AuthenticationManager authenticationManager,
OAuth2AuthenticationSuccessHandler oAuth2AuthenticationSuccessHandler,
OAuth2AuthenticationSuccessHandler auth2AuthenticationSuccessHandler,
AuthenticationFailureHandler authenticationFailureHandler) {
super(OAUTH_LOGIN_URI, authenticationManager);
this.setAuthenticationSuccessHandler(oAuth2AuthenticationSuccessHandler);
this.setAuthenticationSuccessHandler(auth2AuthenticationSuccessHandler);
this.setAuthenticationFailureHandler(authenticationFailureHandler);
}
@@ -46,7 +46,7 @@ public class DatabasirOauth2LoginFilter extends AbstractAuthenticationProcessing
throws AuthenticationException, IOException, ServletException {
Map<String, String[]> params = request.getParameterMap();
String registrationId = new AntPathMatcher().extractPathWithinPattern(OAUTH_LOGIN_URI, request.getRequestURI());
UserDetailResponse userDetailResponse = oAuthAppService.oauthCallback(registrationId, params);
UserDetailResponse userDetailResponse = openAuthAppService.oauthCallback(registrationId, params);
UserDetails details = databasirUserDetailService.loadUserByUsername(userDetailResponse.getUsername());
DatabasirOAuth2Authentication authentication = new DatabasirOAuth2Authentication(details);
if (!userDetailResponse.getEnabled()) {