Skip to content

Commit 3943d24

Browse files
committed
rfac: now token is needed in header, during cd request
1 parent ff219c8 commit 3943d24

File tree

8 files changed

+25
-14
lines changed

8 files changed

+25
-14
lines changed

src/client/src/pages/script/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,8 @@ const Script = () => {
133133
<div className="cd-command">
134134
<p>
135135
curl -X POST \<br />
136-
-H "Authorization: Bearer your-auth-token" \<br />
137136
-H "Content-Type: application/json" \<br />
138-
{`${getHost()}/api/protected/deliver/${project?.name}`}
137+
{`${getHost()}/api/protected/deliver/${project?.name}?token="your-auth-token"`}
139138
</p>
140139
</div>
141140
</div>

src/producer/src/main/java/com/fordevio/producer/controllers/CDController.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,42 @@
88
import org.springframework.web.bind.annotation.PathVariable;
99
import org.springframework.web.bind.annotation.PostMapping;
1010
import org.springframework.web.bind.annotation.RequestMapping;
11+
import org.springframework.web.bind.annotation.RequestParam;
1112
import org.springframework.web.bind.annotation.RestController;
1213

1314
import com.fordevio.producer.models.Project;
1415
import com.fordevio.producer.models.ProjectExecute;
1516
import com.fordevio.producer.payloads.response.MessageResponse;
1617
import com.fordevio.producer.services.database.ProjectHandler;
18+
import com.fordevio.producer.services.security.jwt.JwtUtils;
1719
import com.fordevio.producer.services.tasks.QueueService;
1820

1921
import lombok.extern.slf4j.Slf4j;
2022

2123
@Slf4j
2224
@RestController
23-
@RequestMapping("/api/protected/deliver")
25+
@RequestMapping("/api/deliver")
2426
public class CDController {
2527

2628
@Autowired
2729
private ProjectHandler projectHandler;
2830

2931
@Autowired
3032
private QueueService queueService;
33+
34+
@Autowired
35+
private JwtUtils jwtUtils;
3136

3237
@PostMapping("/{projectName}")
33-
public ResponseEntity<?> deliverProject(@PathVariable String projectName){
38+
public ResponseEntity<?> deliverProject(@PathVariable String projectName, @RequestParam(required = true) String token){
39+
try{
40+
jwtUtils.validateJwtToken(token);
41+
}catch(Exception e){
42+
log.warn("Invalid token", e);
43+
return ResponseEntity.badRequest().body(new MessageResponse(e.getMessage()));
44+
}
3445
try{
46+
3547
Project project = projectHandler.getProjectByName(projectName);
3648
if(project == null){
3749
return ResponseEntity.badRequest().body(new MessageResponse("Project does not exist"));
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"files": {
33
"main.css": "/static/css/main.092e2e82.css",
4-
"main.js": "/static/js/main.181c3982.js",
4+
"main.js": "/static/js/main.0ae8f9bc.js",
55
"static/js/453.419a5d54.chunk.js": "/static/js/453.419a5d54.chunk.js",
66
"static/media/autocd-logo.png": "/static/media/autocd-logo.a4cd8552835c4e76a8b9.png",
77
"index.html": "/index.html",
88
"main.092e2e82.css.map": "/static/css/main.092e2e82.css.map",
9-
"main.181c3982.js.map": "/static/js/main.181c3982.js.map",
9+
"main.0ae8f9bc.js.map": "/static/js/main.0ae8f9bc.js.map",
1010
"453.419a5d54.chunk.js.map": "/static/js/453.419a5d54.chunk.js.map"
1111
},
1212
"entrypoints": [
1313
"static/css/main.092e2e82.css",
14-
"static/js/main.181c3982.js"
14+
"static/js/main.0ae8f9bc.js"
1515
]
1616
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="A tool to automate the process of Continuous Deployment in monolithic servers"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>autoCD</title><script defer="defer" src="/static/js/main.181c3982.js"></script><link href="/static/css/main.092e2e82.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="A tool to automate the process of Continuous Deployment in monolithic servers"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>autoCD</title><script defer="defer" src="/static/js/main.0ae8f9bc.js"></script><link href="/static/css/main.092e2e82.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

src/producer/src/main/resources/static/static/js/main.181c3982.js renamed to src/producer/src/main/resources/static/static/js/main.0ae8f9bc.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/producer/src/main/resources/static/static/js/main.181c3982.js.LICENSE.txt renamed to src/producer/src/main/resources/static/static/js/main.0ae8f9bc.js.LICENSE.txt

File renamed without changes.

src/producer/src/main/resources/static/static/js/main.0ae8f9bc.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/producer/src/main/resources/static/static/js/main.181c3982.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)