Skip to content

Commit 10c09c4

Browse files
authored
Merge pull request #361 from FlowCI/develop
Develop
2 parents 2354d51 + ffd666e commit 10c09c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+360
-365
lines changed

core/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@
6464
<artifactId>minio</artifactId>
6565
</dependency>
6666

67+
<dependency>
68+
<groupId>org.codehaus.groovy</groupId>
69+
<artifactId>groovy-all</artifactId>
70+
<type>pom</type>
71+
</dependency>
72+
6773
<dependency>
6874
<groupId>com.github.ben-manes.caffeine</groupId>
6975
<artifactId>caffeine</artifactId>

core/src/main/java/com/flowci/core/agent/domain/CreateOrUpdateSshAgentHost.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import lombok.Getter;
2121
import lombok.Setter;
2222

23+
import javax.validation.constraints.Max;
24+
import javax.validation.constraints.Min;
2325
import javax.validation.constraints.NotEmpty;
2426
import javax.validation.constraints.NotNull;
2527
import java.util.HashSet;
@@ -39,12 +41,21 @@ public class CreateOrUpdateSshAgentHost {
3941
@NotEmpty
4042
private String name;
4143

44+
@NotEmpty
4245
private String secret;
4346

47+
@NotEmpty
4448
private String user;
4549

50+
@NotEmpty
4651
private String ip;
4752

53+
@Min(1)
54+
@Max(Integer.MAX_VALUE)
55+
private int port = 22;
56+
57+
@Min(1)
58+
@Max(Integer.MAX_VALUE)
4859
private int maxSize = 5;
4960

5061
public AgentHost toObj() {
@@ -57,6 +68,7 @@ public AgentHost toObj() {
5768
host.setIp(ip);
5869
host.setTags(tags);
5970
host.setMaxSize(maxSize);
71+
host.setPort(port);
6072
return host;
6173
}
6274

core/src/main/java/com/flowci/core/agent/domain/ShellIn.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.flowci.core.agent.domain;
22

3+
import com.fasterxml.jackson.annotation.JsonIgnore;
34
import com.flowci.domain.DockerOption;
45
import com.flowci.domain.StringVars;
56
import com.flowci.domain.Vars;
7+
import com.flowci.util.StringHelper;
68
import com.google.common.base.Strings;
79
import lombok.Getter;
810
import lombok.Setter;
@@ -31,6 +33,9 @@ public final class ShellIn extends CmdIn {
3133

3234
private List<DockerOption> dockers;
3335

36+
@JsonIgnore
37+
private String condition;
38+
3439
private List<String> scripts = new LinkedList<>();
3540

3641
private int timeout = 1800;
@@ -57,4 +62,9 @@ public void addEnvFilters(Set<String> exports) {
5762
public void addInputs(StringVars vars) {
5863
inputs.putAll(vars);
5964
}
65+
66+
@JsonIgnore
67+
public boolean hasCondition() {
68+
return StringHelper.hasValue(condition);
69+
}
6070
}

core/src/main/java/com/flowci/core/agent/domain/SshAgentHost.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class SshAgentHost extends AgentHost {
3535
@NonNull
3636
private String ip;
3737

38-
private int port = 22;
38+
private int port;
3939

4040
public SshAgentHost() {
4141
setType(Type.SSH);

core/src/main/java/com/flowci/core/auth/AuthController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ private User getFromAuthorization(String authorization) {
7171
String email = values[0];
7272
String passwordOnMd5 = values[1];
7373

74-
return new User(email, passwordOnMd5, null);
74+
return new User(email, passwordOnMd5, null, null);
7575
}
7676
}

core/src/main/java/com/flowci/core/auth/WebAuth.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
@Component("webAuth")
4646
public class WebAuth implements HandlerInterceptor {
4747

48-
private static final String MagicToken = "helloflowciadmin";
49-
5048
private static final String HeaderToken = "Token";
5149

5250
private static final String ParameterToken = "token";
@@ -91,15 +89,10 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
9189
return true;
9290
}
9391

94-
return authService.setAsDefaultAdmin();
92+
return true;
9593
}
9694

9795
String token = getToken(request);
98-
99-
if (Objects.equals(token, MagicToken)) {
100-
return authService.setAsDefaultAdmin();
101-
}
102-
10396
if (!authService.set(token)) {
10497
throw new AuthenticationException("Invalid token");
10598
}

core/src/main/java/com/flowci/core/auth/service/AuthService.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,4 @@ public interface AuthService {
6565
*/
6666
Optional<User> get(String token);
6767

68-
/**
69-
* Set current user from default admin form config properties
70-
*/
71-
boolean setAsDefaultAdmin();
7268
}

core/src/main/java/com/flowci/core/auth/service/AuthServiceImpl.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,4 @@ public Optional<User> get(String token) {
153153

154154
return Optional.empty();
155155
}
156-
157-
@Override
158-
public boolean setAsDefaultAdmin() {
159-
User defaultAdmin = userService.defaultAdmin();
160-
sessionManager.set(defaultAdmin);
161-
return true;
162-
}
163156
}

core/src/main/java/com/flowci/core/common/config/AppProperties.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ public class AppProperties {
6060

6161
private boolean socketContainer;
6262

63-
@Bean("adminProperties")
64-
@ConfigurationProperties(prefix = "app.admin")
65-
public Admin admin() {
66-
return new Admin();
67-
}
68-
6963
@Bean("zkProperties")
7064
@ConfigurationProperties(prefix = "app.zookeeper")
7165
public Zookeeper zk() {
@@ -108,18 +102,6 @@ public Minio minio() {
108102
return new Minio();
109103
}
110104

111-
@Data
112-
@Validated
113-
public static class Admin {
114-
115-
@NotBlank
116-
@Email
117-
private String defaultEmail;
118-
119-
@NotBlank
120-
private String defaultPassword;
121-
}
122-
123105
@Data
124106
public static class Flow {
125107

core/src/main/java/com/flowci/core/common/config/WebConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public void addInterceptors(InterceptorRegistry registry) {
7878

7979
registry.addInterceptor(webAuth)
8080
.addPathPatterns("/users/**")
81+
.excludePathPatterns("/users/default")
8182
.addPathPatterns("/flows/**")
8283
.addPathPatterns("/jobs/**")
8384
.addPathPatterns("/agents/**")

0 commit comments

Comments
 (0)