Skip to content
This repository was archived by the owner on Feb 26, 2021. It is now read-only.

Commit cc67a40

Browse files
authored
Merge pull request #115 from secureCodeBox/configure-multiple-users
Configure multiple users, groups and tenants via the application.yaml config
2 parents c391aed + 07ed891 commit cc67a40

File tree

6 files changed

+489
-84
lines changed

6 files changed

+489
-84
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ LABEL org.opencontainers.image.title="secureCodeBox Engine" \
5252
org.opencontainers.image.revision=$COMMIT_ID \
5353
org.opencontainers.image.created=$BUILD_DATE
5454

55+
VOLUME ["/scb-engine/config"]
56+
5557
ENTRYPOINT ["./init.sh"]
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
package io.securecodebox.engine.helper;
2+
3+
import org.springframework.boot.context.properties.ConfigurationProperties;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.validation.annotation.Validated;
6+
7+
import javax.validation.constraints.Email;
8+
import javax.validation.constraints.NotEmpty;
9+
import javax.validation.constraints.Pattern;
10+
import java.util.ArrayList;
11+
import java.util.List;
12+
13+
@Validated
14+
@Configuration
15+
@ConfigurationProperties(prefix = "securecodebox")
16+
public class AuthConfiguration {
17+
18+
private List<UserConfiguration> users = new ArrayList<>();
19+
20+
private List<GroupConfiguration> groups = new ArrayList<>();
21+
22+
private List<TenantConfiguration> tenants = new ArrayList<>();
23+
24+
public static class UserConfiguration {
25+
@NotEmpty
26+
// See: https://docs.camunda.org/manual/7.11/update/minor/79-to-710/#whitelist-pattern-for-user-group-and-tenant-ids
27+
// Minus the camunda admin part. As scanner users are never the camunda admin
28+
@Pattern(regexp = "[a-zA-Z0-9]+")
29+
private String id;
30+
@NotEmpty
31+
private String password;
32+
@Email
33+
private String email;
34+
@NotEmpty
35+
private String firstname = "Technical-User";
36+
@NotEmpty
37+
private String lastname = "Scanner-User";
38+
private List<String> groups = new ArrayList<>();
39+
private List<String> tenants = new ArrayList<>();
40+
41+
public String getId() {
42+
return id;
43+
}
44+
45+
public void setId(String id) {
46+
this.id = id;
47+
}
48+
49+
public String getPassword() {
50+
return password;
51+
}
52+
53+
public void setPassword(String password) {
54+
this.password = password;
55+
}
56+
57+
public String getEmail() {
58+
return email;
59+
}
60+
61+
public void setEmail(String email) {
62+
this.email = email;
63+
}
64+
65+
public String getFirstname() {
66+
return firstname;
67+
}
68+
69+
public void setFirstname(String firstname) {
70+
this.firstname = firstname;
71+
}
72+
73+
public String getLastname() {
74+
return lastname;
75+
}
76+
77+
public void setLastname(String lastname) {
78+
this.lastname = lastname;
79+
}
80+
81+
public List<String> getGroups() {
82+
return groups;
83+
}
84+
85+
public void setGroups(List<String> groups) {
86+
this.groups = groups;
87+
}
88+
89+
public List<String> getTenants() {
90+
return tenants;
91+
}
92+
93+
public void setTenants(List<String> tenants) {
94+
this.tenants = tenants;
95+
}
96+
}
97+
98+
public static class GroupConfiguration {
99+
@NotEmpty
100+
// See: https://docs.camunda.org/manual/7.11/update/minor/79-to-710/#whitelist-pattern-for-user-group-and-tenant-ids
101+
// Minus the camunda admin part. As scanner users are never the camunda admin
102+
@Pattern(regexp = "[a-zA-Z0-9]+")
103+
private String id;
104+
105+
@NotEmpty
106+
private String name;
107+
108+
private List<GroupAuthorizations> authorizations = new ArrayList<>();
109+
110+
public static class GroupAuthorizations {
111+
@NotEmpty
112+
private String resource;
113+
114+
private List<String> permissions = new ArrayList<>();
115+
116+
public String getResource() {
117+
return resource;
118+
}
119+
120+
public void setResource(String resource) {
121+
this.resource = resource;
122+
}
123+
124+
public List<String> getPermissions() {
125+
return permissions;
126+
}
127+
128+
public void setPermissions(List<String> permissions) {
129+
this.permissions = permissions;
130+
}
131+
}
132+
133+
public String getId() {
134+
return id;
135+
}
136+
137+
public void setId(String id) {
138+
this.id = id;
139+
}
140+
141+
public String getName() {
142+
return name;
143+
}
144+
145+
public void setName(String name) {
146+
this.name = name;
147+
}
148+
149+
public List<GroupAuthorizations> getAuthorizations() {
150+
return authorizations;
151+
}
152+
153+
public void setAuthorizations(List<GroupAuthorizations> authorizations) {
154+
this.authorizations = authorizations;
155+
}
156+
}
157+
158+
public static class TenantConfiguration {
159+
@NotEmpty
160+
// See: https://docs.camunda.org/manual/7.11/update/minor/79-to-710/#whitelist-pattern-for-user-group-and-tenant-ids
161+
// Minus the camunda admin part. As scanner users are never the camunda admin
162+
@Pattern(regexp = "[a-zA-Z0-9]+")
163+
private String id;
164+
@NotEmpty
165+
private String name;
166+
167+
public String getId() {
168+
return id;
169+
}
170+
171+
public void setId(String id) {
172+
this.id = id;
173+
}
174+
175+
public String getName() {
176+
return name;
177+
}
178+
179+
public void setName(String name) {
180+
this.name = name;
181+
}
182+
}
183+
184+
public List<UserConfiguration> getUsers() {
185+
return users;
186+
}
187+
188+
public void setScanner(List<UserConfiguration> users) {
189+
this.users = users;
190+
}
191+
192+
public void setUsers(List<UserConfiguration> users) {
193+
this.users = users;
194+
}
195+
196+
public List<GroupConfiguration> getGroups() {
197+
return groups;
198+
}
199+
200+
public void setGroups(List<GroupConfiguration> groups) {
201+
this.groups = groups;
202+
}
203+
204+
public List<TenantConfiguration> getTenants() {
205+
return tenants;
206+
}
207+
208+
public void setTenants(List<TenantConfiguration> tenants) {
209+
this.tenants = tenants;
210+
}
211+
}

0 commit comments

Comments
 (0)