-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat($gateway): make Swagger and Spring Security work together
- Loading branch information
Johnny Miller (锺俊)
committed
Dec 21, 2020
1 parent
efb83ad
commit c2c4721
Showing
16 changed files
with
285 additions
and
266 deletions.
There are no files selected for viewing
160 changes: 0 additions & 160 deletions
160
...main/java/com/jmsoftware/maf/gateway/universal/aspect/MethodArgumentValidationAspect.java
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
gateway/src/main/java/com/jmsoftware/maf/gateway/universal/aspect/ValidateArgument.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...a/com/jmsoftware/maf/gateway/universal/configuration/CustomServerAccessDeniedHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.jmsoftware.maf.gateway.universal.configuration; | ||
|
||
import com.jmsoftware.maf.gateway.universal.util.ResponseUtil; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.security.access.AccessDeniedException; | ||
import org.springframework.security.web.server.authorization.ServerAccessDeniedHandler; | ||
import org.springframework.web.server.ServerWebExchange; | ||
import reactor.core.publisher.Mono; | ||
|
||
/** | ||
* Description: CustomServerAccessDeniedHandler, change description here. | ||
* | ||
* @author 钟俊(zhongjun), email: zhongjun@toguide.cn, date: 12/21/2020 10:12 AM | ||
**/ | ||
@Slf4j | ||
@Configuration | ||
public class CustomServerAccessDeniedHandler implements ServerAccessDeniedHandler { | ||
@Override | ||
public Mono<Void> handle(ServerWebExchange exchange, AccessDeniedException denied) { | ||
log.error("Access denied! Exception message: {}. Request URL: [{}] {}", denied.getMessage(), | ||
exchange.getRequest().getMethod(), exchange.getRequest().getURI()); | ||
return ResponseUtil.renderJson(exchange, HttpStatus.FORBIDDEN, null); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...om/jmsoftware/maf/gateway/universal/configuration/ServerAuthenticationEntryPointImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.jmsoftware.maf.gateway.universal.configuration; | ||
|
||
import com.jmsoftware.maf.gateway.universal.util.ResponseUtil; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.security.core.AuthenticationException; | ||
import org.springframework.security.web.server.ServerAuthenticationEntryPoint; | ||
import org.springframework.web.server.ServerWebExchange; | ||
import reactor.core.publisher.Mono; | ||
|
||
/** | ||
* Description: ServerAuthenticationEntryPointImpl, change description here. | ||
* | ||
* @author 钟俊(zhongjun), email: zhongjun@toguide.cn, date: 12/21/2020 9:48 AM | ||
**/ | ||
@Slf4j | ||
@Configuration | ||
public class ServerAuthenticationEntryPointImpl implements ServerAuthenticationEntryPoint { | ||
@Override | ||
public Mono<Void> commence(ServerWebExchange serverWebExchange, AuthenticationException e) { | ||
log.error("Exception occurred when authenticating! Exception message: {}. Request URL: [{}] {}", e.getMessage(), | ||
serverWebExchange.getRequest().getMethod(), serverWebExchange.getRequest().getURI()); | ||
return ResponseUtil.renderJson(serverWebExchange, HttpStatus.NETWORK_AUTHENTICATION_REQUIRED, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.