Skip to content

Commit bfa0852

Browse files
authored
Examples security validation (#8498)
Signed-off-by: Maxim Nesen <[email protected]>
1 parent 2f2b636 commit bfa0852

File tree

54 files changed

+196
-192
lines changed

Some content is hidden

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

54 files changed

+196
-192
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
^ery$ecretP&ssword
1+
changeit

examples/config/changes/src/main/java/io/helidon/config/examples/changes/OnChangeExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2020 Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2024 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ public void run() {
5454

5555
private static void logSecrets(Config secrets) {
5656
LOGGER.info("Loaded secrets are u: " + secrets.get("username").asString().get()
57-
+ ", p: " + secrets.get("password").asString().get());
57+
+ ", p: " + secrets.get("changeit").asString().get());
5858
}
5959

6060
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
^ery$ecretP&ssword
1+
changeit

examples/config/sources/src/main/java/io/helidon/config/examples/sources/DirectorySourceExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2024 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,9 +48,9 @@ public static void main(String... args) {
4848
System.out.println("Username: " + username);
4949
assert username.equals("libor");
5050

51-
String password = secrets.get("password").asString().get();
51+
String password = secrets.get("changeit").asString().get();
5252
System.out.println("Password: " + password);
53-
assert password.equals("^ery$ecretP&ssword");
53+
assert password.equals("changeit");
5454
}
5555

5656
}

examples/dbclient/jdbc/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ Instructions for H2 can be found here: http://www.h2database.com/html/cheatSheet
3030
Instructions for Oracle can be found here: https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance
3131

3232
MySQL can be run as a docker container with the following command:
33-
```shell
34-
docker run --rm --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=pokemon -e MYSQL_USER=user -e MYSQL_PASSWORD=password mysql:5.7
33+
34+
```
35+
docker run --rm --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=pokemon -e MYSQL_USER=user -e MYSQL_PASSWORD=changeit mysql:5.7
3536
```
3637

3738

examples/dbclient/jdbc/src/main/resources/application.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2019, 2021 Oracle and/or its affiliates.
2+
# Copyright (c) 2019, 2024 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -40,10 +40,10 @@ db:
4040
# MySQL configuration
4141
#
4242
# docker run --rm --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root \
43-
# -e MYSQL_DATABASE=pokemon -e MYSQL_USER=user -e MYSQL_PASSWORD=password mysql:5.7
43+
# -e MYSQL_DATABASE=pokemon -e MYSQL_USER=user -e MYSQL_PASSWORD=changeit mysql:5.7
4444
# url: jdbc:mysql://127.0.0.1:3306/pokemon?useSSL=false
4545
# username: user
46-
# password: password
46+
# password: changeit
4747
# poolName: mysql
4848
#
4949
# Oracle configuration

examples/dbclient/pokemons/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ For details, see http://www.h2database.com/html/cheatSheet.html
6767
MySQL:
6868
```shell
6969
docker run --rm --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root \
70-
-e MYSQL_DATABASE=pokemon -e MYSQL_USER=user -e MYSQL_PASSWORD=password mysql:5.7
70+
-e MYSQL_DATABASE=pokemon -e MYSQL_USER=user -e MYSQL_PASSWORD=changeit mysql:5.7
7171
```
7272

7373

examples/employee-app/src/main/java/io/helidon/service/employee/EmployeeRepositoryImplDB.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2024 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ final class EmployeeRepositoryImplDB implements EmployeeRepository {
4444
String driver = "oracle.jdbc.driver.OracleDriver";
4545

4646
String dbUserName = config.get("app.user").asString().orElse("sys as SYSDBA");
47-
String dbUserPassword = config.get("app.password").asString().orElse("password");
47+
String dbUserPassword = config.get("app.password").asString().orElse("changeit");
4848
String dbHostURL = config.get("app.hosturl").asString().orElse("localhost:1521/xe");
4949

5050
try {

examples/integrations/neo4j/neo4j-mp/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<relativePath>../../../../applications/mp/pom.xml</relativePath>
2929
</parent>
3030
<groupId>io.helidon.examples.integrations.neo4j</groupId>
31-
<artifactId>helidon-examples-integration-neo4j-mp</artifactId>
31+
<artifactId>helidon-examples-integrations-neo4j-mp</artifactId>
3232
<name>Helidon Neo4j MP integration Example</name>
3333

3434
<properties>

examples/integrations/neo4j/neo4j-se/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<relativePath>../../../../applications/se/pom.xml</relativePath>
2929
</parent>
3030
<groupId>io.helidon.examples.integrations.neo4j</groupId>
31-
<artifactId>helidon-examples-integration-neo4j-se</artifactId>
31+
<artifactId>helidon-examples-integrations-neo4j-se</artifactId>
3232
<name>Helidon Integrations Neo4j SE Example</name>
3333

3434
<properties>

examples/microprofile/idcs/src/main/resources/application.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2018, 2020 Oracle and/or its affiliates.
2+
# Copyright (c) 2018, 2024 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ security:
2929
# This is a nice way to be able to override this with local properties or env-vars
3030
idcs-uri: "https://tenant-id.identity.oracle.com"
3131
idcs-client-id: "client-id"
32-
idcs-client-secret: "client-secret"
32+
idcs-client-secret: "changeit"
3333
# Used as a base for redirects back to us
3434
frontend-uri: "http://localhost:7987"
3535
proxy-host: "if you need proxy"

examples/microprofile/oidc/src/main/resources/application.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2019, 2020 Oracle and/or its affiliates.
2+
# Copyright (c) 2019, 2024 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ security:
2323
oidc-identity-uri: "https://tenant.some-server.com/oauth2/default"
2424
# when you create a new client in identity server configuration, you should get a client id and a client secret
2525
oidc-client-id: "some client id"
26-
oidc-client-secret: "some client secret"
26+
oidc-client-secret: "changeit"
2727
# issuer of the tokens - identity server specific (maybe even configurable)
2828
oidc-issuer: "https://tenant.some-server.com/oauth2/default"
2929
# audience of the tokens - identity server specific (usually configurable)

examples/microprofile/security/src/main/resources/application.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2018, 2020 Oracle and/or its affiliates.
2+
# Copyright (c) 2018, 2024 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -27,13 +27,13 @@ security:
2727
realm: "helidon"
2828
users:
2929
- login: "jack"
30-
password: "password"
30+
password: "changeit"
3131
roles: ["user", "admin"]
3232
- login: "jill"
33-
password: "password"
33+
password: "changeit"
3434
roles: ["user"]
3535
- login: "john"
36-
password: "password"
36+
password: "changeit"
3737
web-server:
3838
paths:
3939
- path: "/static-cp[/{*}]"

examples/microprofile/tls/src/main/resources/META-INF/microprofile-config.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2020 Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2024 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@ server.host=0.0.0.0
2020

2121
#Truststore setup
2222
server.tls.trust.keystore.resource.resource-path=server.p12
23-
server.tls.trust.keystore.passphrase=password
23+
server.tls.trust.keystore.passphrase=changeit
2424
server.tls.trust.keystore.trust-store=true
2525

2626
#Keystore with private key and server certificate
2727
server.tls.private-key.keystore.resource.resource-path=server.p12
28-
server.tls.private-key.keystore.passphrase=password
28+
server.tls.private-key.keystore.passphrase=changeit
Binary file not shown.

examples/openapi-tools/quickstart-se/se-server/src/main/resources/application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2022, 2023 Oracle and/or its affiliates.
2+
# Copyright (c) 2022, 2024 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

examples/security/basic-auth-with-static-content/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ java -jar target//helidon-examples-security-webserver-basic-uath.jar
2121
Try the application:
2222

2323
The application starts on a random port, the following assumes it is `56551`
24+
2425
```shell
2526
export PORT=37667
26-
curl http://localhost:${PORT}/public
27-
curl -u "jill:password" http://localhost:${PORT}/noRoles
28-
curl -u "john:password" http://localhost:${PORT}/user
29-
curl -u "jack:password" http://localhost:${PORT}/admin
30-
curl -v -u "john:password" http://localhost:${PORT}/deny
31-
curl -u "jack:password" http://localhost:${PORT}/noAuthn
27+
curl http://localhost:56551/public
28+
curl -u "jill:changeit" http://localhost:${PORT}/noRoles
29+
curl -u "john:changeit" http://localhost:${PORT}/user
30+
curl -u "jack:changeit" http://localhost:${PORT}/admin
31+
curl -v -u "john:changeit" http://localhost:${PORT}/deny
32+
curl -u "jack:changeit" http://localhost:${PORT}/noAuthn
3233
```

examples/security/basic-auth-with-static-content/src/main/resources/application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2020 Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2024 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

examples/security/idcs-login/src/main/resources/application.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2018, 2021 Oracle and/or its affiliates.
2+
# Copyright (c) 2018, 2024 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ security:
2323
# This is a nice way to be able to override this with local properties or env-vars
2424
idcs-uri: "https://your-tenant-id.identity.oracle.com"
2525
idcs-client-id: "your-client-id"
26-
idcs-client-secret: "${CLEAR=your-client-secret}"
26+
idcs-client-secret: "${CLEAR=changeit}"
2727
proxy-host: ""
2828
providers:
2929
- abac:

examples/security/nohttp-programmatic/src/main/java/io/helidon/security/examples/security/ProgrammaticSecurity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2018, 2024 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -135,7 +135,7 @@ private Subject login() {
135135
SecurityContext securityContext = CONTEXT.get();
136136
securityContext.env(securityContext.env().derive()
137137
.path("/some/path")
138-
.header("Authorization", buildBasic("aUser", "aPassword")));
138+
.header("Authorization", buildBasic("aUser", "changeit")));
139139

140140
AuthenticationResponse response = securityContext.atnClientBuilder().buildAndGet();
141141

examples/security/outbound-override/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ java -jar target/helidon-examples-security-outbound-override.jar
1212
```
1313

1414
Try the endpoints:
15+
1516
```shell
16-
curl -u "jack:password" http://localhost:8080/propagate
17-
curl -u "jack:password" http://localhost:8080/override
18-
curl -u "jill:anotherPassword" http://localhost:8080/propagate
19-
curl -u "jill:anotherPassword" http://localhost:8080/override
17+
curl -u "jack:changeit" http://localhost:8080/propagate
18+
curl -u "jack:changeit" http://localhost:8080/override
19+
curl -u "jill:changeit" http://localhost:8080/propagate
20+
curl -u "jill:changeit" http://localhost:8080/override
2021
```

examples/security/outbound-override/src/main/java/io/helidon/security/examples/outbound/OutboundOverrideExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
2+
* Copyright (c) 2018, 2024 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -94,7 +94,7 @@ private static void override(ServerRequest req, ServerResponse res) {
9494

9595
webTarget(servingPort)
9696
.property(HttpBasicAuthProvider.EP_PROPERTY_OUTBOUND_USER, "jill")
97-
.property(HttpBasicAuthProvider.EP_PROPERTY_OUTBOUND_PASSWORD, "anotherPassword")
97+
.property(HttpBasicAuthProvider.EP_PROPERTY_OUTBOUND_PASSWORD, "changeit")
9898
.request(String.class)
9999
.thenAccept(result -> res.send("You are: " + context.userName()
100100
+ ", backend service returned: " + result + "\n"))

examples/security/outbound-override/src/main/resources/client-service-jwt.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2018, 2020 Oracle and/or its affiliates.
2+
# Copyright (c) 2018, 2024 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -25,13 +25,13 @@ security:
2525
- http-basic-auth:
2626
users:
2727
- login: "john"
28-
password: "johnnyPassword"
28+
password: "changeit"
2929
roles: ["admin"]
3030
- login: "jack"
31-
password: "password"
31+
password: "changeit"
3232
roles: ["user", "admin"]
3333
- login: "jill"
34-
password: "anotherPassword"
34+
password: "changeit"
3535
roles: ["user"]
3636
- jwt:
3737
allow-impersonation: true

examples/security/outbound-override/src/main/resources/client-service.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2018, 2020 Oracle and/or its affiliates.
2+
# Copyright (c) 2018, 2024 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -19,13 +19,13 @@ security:
1919
- http-basic-auth:
2020
users:
2121
- login: "john"
22-
password: "johnnyPassword"
22+
password: "changeit"
2323
roles: ["admin"]
2424
- login: "jack"
25-
password: "password"
25+
password: "changeit"
2626
roles: ["user", "admin"]
2727
- login: "jill"
28-
password: "anotherPassword"
28+
password: "changeit"
2929
roles: ["user"]
3030
outbound:
3131
- name: "propagate-all"

examples/security/outbound-override/src/main/resources/serving-service.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2018, 2024 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -19,10 +19,10 @@ security:
1919
- http-basic-auth:
2020
users:
2121
- login: "jack"
22-
password: "password"
22+
password: "changeit"
2323
roles: ["user", "admin"]
2424
- login: "jill"
25-
password: "anotherPassword"
25+
password: "changeit"
2626
roles: ["user"]
2727
web-server:
2828
defaults:

examples/security/outbound-override/src/test/java/io/helidon/security/examples/outbound/OutboundOverrideExampleTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2024 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ public void testOverrideExample() {
6161
String value = webClient.get()
6262
.path("/override")
6363
.property(HttpBasicAuthProvider.EP_PROPERTY_OUTBOUND_USER, "jack")
64-
.property(HttpBasicAuthProvider.EP_PROPERTY_OUTBOUND_PASSWORD, "password")
64+
.property(HttpBasicAuthProvider.EP_PROPERTY_OUTBOUND_PASSWORD, "changeit")
6565
.request(String.class)
6666
.await();
6767

@@ -73,7 +73,7 @@ public void testPropagateExample() {
7373
String value = webClient.get()
7474
.path("/propagate")
7575
.property(HttpBasicAuthProvider.EP_PROPERTY_OUTBOUND_USER, "jack")
76-
.property(HttpBasicAuthProvider.EP_PROPERTY_OUTBOUND_PASSWORD, "password")
76+
.property(HttpBasicAuthProvider.EP_PROPERTY_OUTBOUND_PASSWORD, "changeit")
7777
.request(String.class)
7878
.await();
7979

0 commit comments

Comments
 (0)