-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yingbo Wang
committed
Oct 18, 2022
1 parent
725790d
commit f86decd
Showing
12 changed files
with
179 additions
and
14 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...uthority-center/src/main/java/com/wyb/rms/auth/center/controller/AuthorityController.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,49 @@ | ||
package com.wyb.rms.auth.center.controller; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.wyb.rms.auth.center.service.IJWTService; | ||
import com.wyb.rms.common.vo.JwtToken; | ||
import com.wyb.rms.common.vo.UsernameAndPassword; | ||
import com.wyb.rms.mvc.annotation.IgnoreResponseAdvice; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* <h1>对外暴露的授权服务接口</h1> | ||
*/ | ||
@Slf4j | ||
@RestController | ||
@RequestMapping("/authority") | ||
public class AuthorityController { | ||
|
||
private final IJWTService ijwtService; | ||
|
||
public AuthorityController(IJWTService ijwtService) { | ||
this.ijwtService = ijwtService; | ||
} | ||
|
||
/** | ||
* <h2>从授权中心获取 Token (其实就是登录功能), 且返回信息中没有统一响应的包装</h2> | ||
*/ | ||
@IgnoreResponseAdvice | ||
@PostMapping("/token") | ||
public JwtToken token(@RequestBody UsernameAndPassword usernameAndPassword) throws Exception { | ||
|
||
log.info("request to get token with param: [{}]", JSON.toJSONString(usernameAndPassword)); | ||
return new JwtToken(ijwtService.generateToken(usernameAndPassword.getUsername(), usernameAndPassword.getPassword())); | ||
} | ||
|
||
/** | ||
* <h2>注册用户并返回当前注册用户的 Token, 即通过授权中心创建用户</h2> | ||
*/ | ||
@IgnoreResponseAdvice | ||
@PostMapping("/register") | ||
public JwtToken register(@RequestBody UsernameAndPassword usernameAndPassword) throws Exception { | ||
|
||
log.info("register user with param: [{}]", JSON.toJSONString(usernameAndPassword)); | ||
return new JwtToken(ijwtService.registerUserAndGenerateToken(usernameAndPassword)); | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
rms-mall-gateway/src/main/resources/gateway-flow-rule-api-sentinel.json
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,14 @@ | ||
[ | ||
{ | ||
"apiName": "nacos-client-api", | ||
"predicateItems": [ | ||
{ | ||
"pattern": "/imooc/ecommerce-nacos-client/nacos-client/project-config" | ||
}, | ||
{ | ||
"pattern": "/imooc/ecommerce-nacos-client/**", | ||
"matchStrategy": 1 | ||
} | ||
] | ||
} | ||
] |
14 changes: 14 additions & 0 deletions
14
rms-mall-gateway/src/main/resources/gateway-flow-rule-sentinel.json
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,14 @@ | ||
[ | ||
{ | ||
"resource": "e-commerce-nacos-client", | ||
"resourceMode": 0, | ||
"count": 3, | ||
"intervalSec": 60 | ||
}, | ||
{ | ||
"resource": "nacos-client-api", | ||
"resourceMode": 1, | ||
"count": 1, | ||
"intervalSec": 60 | ||
} | ||
] |
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,17 @@ | ||
### 登录 | ||
POST 127.0.0.1:9001/imooc/e-commerce/login | ||
Content-Type: application/json | ||
|
||
{ | ||
"username": "[email protected]", | ||
"password": "25d55ad283aa400af464c76d713c07ad" | ||
} | ||
|
||
### 注册 | ||
POST 127.0.0.1:9001/imooc/e-commerce/register | ||
Content-Type: application/json | ||
|
||
{ | ||
"username": "[email protected]", | ||
"password": "25d55ad283aa400af464c76d713c07ad" | ||
} |
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,5 @@ | ||
### 查询服务 | ||
GET http://127.0.0.1:9001/imooc/rms-mall-nacos-client/nacos-client/service-instance?serviceId=rms-mall-gateway | ||
Accept: application/json | ||
e-commerce-user: eyJhbGciOiJSUzI1NiJ9.eyJlLWNvbW1lcmNlLXVzZXIiOiJ7XCJpZFwiOjEwLFwidXNlcm5hbWVcIjpcIndhbmd5YkBxcS5jb21cIn0iLCJqdGkiOiJiYTU0MjBjNy0wMTM1LTRhZjYtOGVjYS0wZGUwZmQ5OTI5ZDgiLCJleHAiOjE2NjYxMDg4MDB9.eulJFnRt_I7ycLFhcZVi2wLk8HdWvnHgrXKqBm9j86StFnMl4D4fSFgWGOQoD1dwFgOMT00JhHb77hK1wsxQDMbymIj9iii5m21tNmdRfGY7FbwMh7Bd9M2s3_wkct7xHxcdyQ-z7T_0GgUYRJsT6zpTzBW5bloiltG_V1mqNCxRpvXo9HlztizZg69BaZuVSpoSee-w9g74_cvS9FsZyB9ztu19d6pz-OoByjBbWC0u4F_9TS8zCkWsGpGTReiKiP4MVPVHv44BqAUqJFLsLky7kPRx351tVQDuCNT5mXN0U-Pu4HEOtIV59C8GwvtXJooLAQtsJ5vccF_ax_WkMQ | ||
token: imooc |
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,17 @@ | ||
### 登录 | ||
POST http://www.ecommerce.com/imooc/e-commerce/login | ||
Content-Type: application/json | ||
|
||
{ | ||
"username": "[email protected]", | ||
"password": "25d55ad283aa400af464c76d713c07ad" | ||
} | ||
|
||
### 查询服务 Nginx -> Gatyeway -> MicroService | ||
GET http://www.ecommerce.com/imooc/ecommerce-nacos-client/nacos-client/service-instance?serviceId=e-commerce-gateway | ||
Accept: application/json | ||
e-commerce-user: eyJhbGciOiJSUzI1NiJ9.eyJlLWNvbW1lcmNlLXVzZXIiOiJ7XCJpZFwiOjEsXCJ1c2VybmFtZVwiOlwiUWlueWlAaW1vb2MuY29tXCJ9IiwianRpIjoiZTk3Yjg2NjEtMjczYy00ZGFkLThhNTEtNzFjNzBlNTI4MDI0IiwiZXhwIjoxNjMwODU3NjAwfQ.K2yehUtgZOQnHgUAKezuqdAVl9JVN0y_8xx1UiNXHP_oiHDmBYxUbdkBvjq3cvBQLF_UKjfuYaZ0zmdJq3QgHqLThIS35Bd9pewjlcxUmDvLaVPzrdj-Ov22lbT6GmPwqcC2b_Fx0TqvEMe_1QGAQjcLCNCS8Pg9xmahY1_nf-5hqiSezRJBlLBko7aa82TkfkGZjfC_7rP6ev6F22l3_Bi-FUf5WnXqxqao260nD-tH-hN5wJ-_tZ4B5y2pVgtGBH_ebbGFiBl2eE9Azmz2vwbEoPWbrQvKGPj6R1v-w8uX7m4okNatxe0eqc_O2S8UGjQ7IIsB7fqXJ8b37yJt5A | ||
token: imooc | ||
|
||
### SpringBoot Admin | ||
http://www.ecommerce.com/e-commerce-admin |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
server: | ||
port: 8000 | ||
servlet: | ||
context-path: /rms-mall-nacos-client | ||
spring: | ||
profiles: | ||
active: dev | ||
|
4 changes: 2 additions & 2 deletions
4
rms-mall-nacos-client/src/main/resources/http/nacos-client.http
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