-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[🐷变更] 默认关闭redis依赖 [🐵新增] flywave版本支持分隔,便于人眼识别
- Loading branch information
Showing
130 changed files
with
8,014 additions
and
698 deletions.
There are no files selected for viewing
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
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
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
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
35 changes: 35 additions & 0 deletions
35
wings-example/src/main/java/pro/fessional/wings/example/controller/ErrorController.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,35 @@ | ||
package pro.fessional.wings.example.controller; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; | ||
import pro.fessional.mirana.data.DataResult; | ||
import pro.fessional.mirana.data.R; | ||
|
||
/** | ||
* @author trydofor | ||
* @since 2020-06-21 | ||
*/ | ||
@ControllerAdvice | ||
@Slf4j | ||
public class ErrorController extends ResponseEntityExceptionHandler { | ||
|
||
@ExceptionHandler(OAuth2Exception.class) | ||
@ResponseBody | ||
public DataResult<String> handleOAuth2Exception(OAuth2Exception ex) { | ||
String err = ex.toString(); | ||
log.info("wings handle exception, oauth2 {}", err); | ||
return R.ng(err); | ||
} | ||
|
||
@ExceptionHandler(Exception.class) | ||
@ResponseBody | ||
public DataResult<String> handleAnyException(Exception ex) { | ||
String c = ex.getClass().getSimpleName(); | ||
log.info("wings handle exception, " + c, ex); | ||
return R.ng("unknown exception, " + c + ":" + ex.getMessage()); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
wings-example/src/main/java/pro/fessional/wings/example/controller/LoginController.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,64 @@ | ||
package pro.fessional.wings.example.controller; | ||
|
||
import lombok.Setter; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.security.oauth2.common.OAuth2AccessToken; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
import org.springframework.web.client.RestTemplate; | ||
import pro.fessional.wings.slardar.security.WingsOAuth2xHelper; | ||
import pro.fessional.wings.slardar.security.WingsTokenStore; | ||
import pro.fessional.wings.slardar.servlet.TypedRequestUtil; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
/** | ||
* @author trydofor | ||
* @since 2019-11-13 | ||
*/ | ||
@Controller | ||
public class LoginController { | ||
|
||
@Setter(onMethod = @__({@Autowired})) | ||
private WingsOAuth2xHelper wingsOAuth2XHelper; | ||
|
||
@Setter(onMethod = @__({@Autowired})) | ||
private WingsTokenStore wingsTokenStore; | ||
|
||
@Setter(onMethod = @__({@Autowired})) | ||
private RestTemplate restTemplate; | ||
|
||
@Setter(onMethod = @__({@Value("${wings.oauth.token.url}")})) | ||
private String oauthTokenUrl; | ||
|
||
@Setter(onMethod = @__({@Value("${wings.slardar.oauth2x.client.staff.client-id}")})) | ||
private String oauthClientId; | ||
|
||
@PostMapping(value = {"/login.json"}) | ||
@ResponseBody | ||
public OAuth2AccessToken login(@RequestParam("username") String username, @RequestParam("password") String password) { | ||
WingsOAuth2xHelper.Login info = new WingsOAuth2xHelper.Login(); | ||
info.setLoginUrl(oauthTokenUrl); | ||
info.setClientId(oauthClientId); // 必须配置中有,否则失败 | ||
info.setUsername(username); | ||
info.setPassword(password); | ||
info.setOauthPasswordAlias("name_pass"); | ||
info.setClientIdAlias("web_admin"); | ||
info.setGrantTypeAlias("admin"); | ||
//info.setAccessToken3rd("bac0c873-e1cc-4740-8b9b-a903dcaaedfe"); | ||
|
||
return wingsOAuth2XHelper.login(restTemplate, info); | ||
} | ||
|
||
@RequestMapping(value = {"/logout.json"}) | ||
@ResponseBody | ||
public String logout(HttpServletRequest request) { | ||
String accessToken = TypedRequestUtil.getAccessToken(request); | ||
wingsOAuth2XHelper.logout(wingsTokenStore, accessToken); | ||
return "logout " + accessToken; | ||
} | ||
} |
Oops, something went wrong.