Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint 8 - update #79

Merged
merged 57 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
0677fe3
Project list
Higunio320 Feb 7, 2024
7d1170c
Project tweaks and basic backlog items view
Higunio320 Feb 18, 2024
117ed0d
Fixed conflicts
Higunio320 Feb 22, 2024
acc5f15
Backlog view, fixed dependencies and swapped angular icons for corn i…
Higunio320 Feb 27, 2024
9209fd3
Files missing from previous commit for some reason
Higunio320 Feb 27, 2024
cc0920b
Unfinished backlog item form dialog
Higunio320 Mar 4, 2024
39a3545
Added workflow for building frontend app
szymonpoltorak Mar 5, 2024
10b7295
Merge pull request #60 from szymonpoltorak/DEV-129-frontWorkflow
szymonpoltorak Mar 5, 2024
813543b
Added api docs and fixed few api mappings
szymonpoltorak Mar 5, 2024
b77c186
Merge pull request #61 from szymonpoltorak/DEV-63-postmanApiCollection
szymonpoltorak Mar 5, 2024
4f77f6d
Finished backlog item form
Higunio320 Mar 6, 2024
4e47367
Fixes
Higunio320 Mar 6, 2024
7c04bd4
Update test.yml
szymonpoltorak Mar 6, 2024
e2c9bc7
Merge pull request #64 from szymonpoltorak/szymonpoltorak-patch-1
szymonpoltorak Mar 6, 2024
f4c3e6e
Update buildFrontend.yml
szymonpoltorak Mar 6, 2024
ff29300
Merge branch 'devel' into projects-backlog
Higunio320 Mar 6, 2024
69cad54
Update angular.json
szymonpoltorak Mar 7, 2024
fe8cc7a
Update angular.json
szymonpoltorak Mar 7, 2024
82db25f
Update angular.json
szymonpoltorak Mar 7, 2024
3b838f8
Update angular.json
szymonpoltorak Mar 7, 2024
e345f64
Merge pull request #63 from szymonpoltorak/projects-backlog
szymonpoltorak Mar 7, 2024
89d289f
Fixed icon in homepage
Higunio320 Mar 8, 2024
39c39fc
Merge pull request #65 from szymonpoltorak/DEV-144-Icon-fix
szymonpoltorak Mar 8, 2024
964ef98
fixed realm recreation logic so new realm is being created after dele…
Mar 8, 2024
dc363c2
Merge pull request #66 from szymonpoltorak/DEV-146-keycloakInitialize…
szymonpoltorak Mar 8, 2024
cfdad3f
removed setting of default signature algorithm
Mar 8, 2024
3b0d37f
Merge pull request #67 from szymonpoltorak/DEV-150-ResetDefaultSigAlgo
szymonpoltorak Mar 8, 2024
d4aeabb
added creation of placeholder users and data
Mar 8, 2024
b3694bd
Merge pull request #69 from szymonpoltorak/DEV-132-PlaceholderUsers
szymonpoltorak Mar 8, 2024
0e1cbaa
replaced string literals with enum values
Mar 9, 2024
c788a37
Merge pull request #70 from szymonpoltorak/DEV-131-EnumifiyRouterStrings
szymonpoltorak Mar 9, 2024
9410d29
specified default value while resolving env variable
Mar 9, 2024
85bd87c
increased haelthcheck retries count so slow machines have chance to b…
Mar 9, 2024
0c68341
created workflow for checking dockercompose.dev and .prod
Mar 9, 2024
f8bda82
Merge pull request #71 from szymonpoltorak/DEV-152-EnvVarDefaultValue
szymonpoltorak Mar 9, 2024
1755eeb
Merge pull request #73 from szymonpoltorak/DEV-79-DockerWorkflow
szymonpoltorak Mar 9, 2024
fe00c82
added setting of corn theme to production keycloak initializer
Mar 9, 2024
5d565db
embeded envvar directly into relevant directive
Mar 9, 2024
3ceaff4
configured production to build theme archive inside and into builder …
Mar 9, 2024
98f099d
configured production keycloak to copy theme archive directly into it…
Mar 9, 2024
6a06afa
moved theme building process into keycloak dockerfile
Mar 10, 2024
92357db
Merge pull request #76 from szymonpoltorak/DEV-123-KcThemeBuilding
szymonpoltorak Mar 10, 2024
2dd398f
removed styles.css so it can be ignored
Mar 10, 2024
0f70bef
Merge pull request #77 from szymonpoltorak/DEV-145-CssGitIgn
szymonpoltorak Mar 10, 2024
f95fd36
Basic view integration
Higunio320 Mar 10, 2024
0e80226
Changed BacklogItems by project endpoint to return page of sorted items
Mar 11, 2024
6448e9c
Integrated Backlog items view with backend
Mar 11, 2024
fe00686
Deleted placeholder code from backlogitems view
Mar 11, 2024
772dd1e
Improved the service method and added tests
Mar 12, 2024
3ac4d70
Added ability to create new backlog item from frontend
Mar 13, 2024
7501564
Added ability to change backlog item's status from frontend
Mar 13, 2024
0b9ceff
Fixed deleteById in backlogItem and added ability to delete items fro…
Mar 14, 2024
e9a9a12
Deleted unnecessary config class
Mar 14, 2024
d7ada10
Merge branch 'devel' of github.com:szymonpoltorak/Corn into DEV-134-B…
Mar 14, 2024
464b14a
Optimized imports and deleted unnecessary code
Mar 14, 2024
a397b13
Fixes
Mar 14, 2024
688d820
Merge pull request #78 from szymonpoltorak/DEV-134-Backlog-integration
szymonpoltorak Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/buildFrontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build Angular App

on:
push:
branches: [ "main", "devel" ]
pull_request:
branches: [ "main", "devel" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: cd corn-frontend; npm install

- name: Build Developer
run: cd corn-frontend; npm run ng build

- name: Build production
run: cd corn-frontend; npm run ng build --configuration=production
70 changes: 70 additions & 0 deletions .github/workflows/checkDockerDev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Check dockercompose.dev

on:
push:
branches: [ "main", "devel" ]
pull_request:
branches: [ "main", "devel" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install jq
run: sudo apt-get install -y jq

- name: Setup useful functions
run: |
rc=/tmp/rcfile
echo "lscontainers() { docker ps -qa | xargs --no-run-if-empty docker inspect; }" >> $rc
echo "asserttrue() { [ \"\$(cat)\" = \"true\" ]; }" >> $rc
echo "checkstatus() { lscontainers | jq -r '.[] | select(.Name == \"/'\"\$1\"'\").State.Status == \"'\"\$2\"'\"'; }" >> $rc
echo "ishealthy() { lscontainers | jq -r '.[] | select(.Name == \"/'\"\$1\"'\").State.Health.Status == \"healthy\"'; }" >> $rc
echo "fatal() { echo \"Check failed: \$@\" 1>&2; exit 1; }" >> $rc

- name: Boot up containers
run: docker compose -f docker-compose.dev.yml up --build -d

- name: Wait for transient states to disappear
run: sleep 200

- name: Test backend
run: |
source /tmp/rcfile
checkstatus "corn-postgres" "running" | asserttrue || fatal "BackDb"
checkstatus "corn-backend" "running" | asserttrue || fatal "BackSpring"

- name: Test frontend
run: |
source /tmp/rcfile
checkstatus "corn-frontend" "running" | asserttrue || fatal "FrontNg"

- name: Test nginx
run: |
source /tmp/rcfile
checkstatus "corn-nginx" "running" | asserttrue || fatal "NginxMain"

- name: Test keycloak
run: |
source /tmp/rcfile
checkstatus "corn-keycloak" "running" | asserttrue || fatal "KcMain"
ishealthy "corn-keycloak" | asserttrue || fatal "KcMainHealth"
checkstatus "corn-keycloak-postgres" "running" | asserttrue || fatal "KcDb"
ishealthy "corn-keycloak-postgres" | asserttrue || fatal "KcDbHealth"
checkstatus "corn-keycloak-theme" "running" | asserttrue || fatal "KcTheme"
checkstatus "corn-keycloak-initializer" "exited" | asserttrue || fatal "KcInit"

- name: Test proxies connectivity
run: |
source /tmp/rcfile
curl -qo /dev/null -w "%{http_code}" 'http://localhost:4200/api/fallible' | grep -qP '^(502|503|504).*' || exit 0 && fatal "NginxBack"
curl -qo /dev/null -w "%{http_code}" 'http://localhost:4200/' | grep -qP '^(502|503|504).*' || exit 0 && fatal "NginxFront"
curl -qo /dev/null -w "%{http_code}" 'http://localhost:8081/realms/Corn' | grep -qP '^(502|503|504).*' || exit 0 && fatal "NginxKc"

- name: Test existence of Corn realm
run: |
source /tmp/rcfile
curl 'http://localhost:8081/realms/Corn/' | jq -r '.error == null' | asserttrue || fatal "CornRealm"
69 changes: 69 additions & 0 deletions .github/workflows/checkDockerProd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Check dockercompose.prod

on:
push:
branches: [ "main", "devel" ]
pull_request:
branches: [ "main", "devel" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install jq
run: sudo apt-get install -y jq

- name: Setup useful functions
run: |
rc=/tmp/rcfile
echo "lscontainers() { docker ps -qa | xargs --no-run-if-empty docker inspect; }" >> $rc
echo "asserttrue() { [ \"\$(cat)\" = \"true\" ]; }" >> $rc
echo "checkstatus() { lscontainers | jq -r '.[] | select(.Name == \"/'\"\$1\"'\").State.Status == \"'\"\$2\"'\"'; }" >> $rc
echo "ishealthy() { lscontainers | jq -r '.[] | select(.Name == \"/'\"\$1\"'\").State.Health.Status == \"healthy\"'; }" >> $rc
echo "fatal() { echo \"Check failed: \$@\" 1>&2; exit 1; }" >> $rc

- name: Boot up containers
run: docker compose -f docker-compose.prod.yml up --build -d

- name: Wait for transient states to disappear
run: sleep 200

- name: Test backend
run: |
source /tmp/rcfile
checkstatus "corn-postgres" "running" | asserttrue || fatal "BackDb"
checkstatus "corn-backend" "running" | asserttrue || fatal "BackSpring"

- name: Test frontend
run: |
source /tmp/rcfile
checkstatus "corn-frontend" "running" | asserttrue || fatal "FrontNginx"

- name: Test nginx
run: |
source /tmp/rcfile
checkstatus "corn-nginx" "running" | asserttrue || fatal "NginxMain"

- name: Test keycloak
run: |
source /tmp/rcfile
checkstatus "corn-keycloak" "running" | asserttrue || fatal "KcMain"
ishealthy "corn-keycloak" | asserttrue || fatal "KcMainHealth"
checkstatus "corn-keycloak-postgres" "running" | asserttrue || fatal "KcDb"
ishealthy "corn-keycloak-postgres" | asserttrue || fatal "KcDbHealth"
checkstatus "corn-keycloak-initializer" "exited" | asserttrue || fatal "KcInit"

- name: Test proxies connectivity
run: |
source /tmp/rcfile
curl -qo /dev/null -w "%{http_code}" 'http://localhost:4200/api/fallible' | grep -qP '^(502|503|504).*' || exit 0 && fatal "NginxBack"
curl -qo /dev/null -w "%{http_code}" 'http://localhost:4200/' | grep -qP '^(502|503|504).*' || exit 0 && fatal "NginxFront"
curl -qo /dev/null -w "%{http_code}" 'http://localhost:8081/realms/Corn' | grep -qP '^(502|503|504).*' || exit 0 && fatal "NginxKc"

- name: Test existence of Corn realm
run: |
source /tmp/rcfile
curl 'http://localhost:8081/realms/Corn/' | jq -r '.error == null' | asserttrue || fatal "CornRealm"
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Test Application with Gradle

on:
push:
branches: [ "main" ]
branches: [ "main", "devel" ]
pull_request:
branches: [ "main", "devel" ]

Expand Down Expand Up @@ -45,4 +45,4 @@ jobs:
with:
gradle-version: '8.2'
arguments: build
build-root-directory: corn-backend
build-root-directory: corn-backend
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public final class ExternalConfig {

private static final String KCCFG_OVERRIDE_EXISTING = System.getenv("KCCFG_OVERRIDE_EXISTING");

private static final String KCCFG_CREATE_PLACEHOLDER_USERS = System.getenv("KCCFG_CREATE_PLACEHOLDER_USERS");

public static final String KCCFG_LOGIN_THEME_NAME = System.getenv("KCCFG_LOGIN_THEME_NAME");

private static final String KC_SERVER_URL = System.getenv("KC_SERVER_URL");
Expand Down Expand Up @@ -43,6 +45,10 @@ static boolean shouldOverrideExistingConfiguration() {
return "true".equalsIgnoreCase(KCCFG_OVERRIDE_EXISTING);
}

public static boolean shouldCreatePlaceholderUsers() {
return "true".equalsIgnoreCase(KCCFG_CREATE_PLACEHOLDER_USERS);
}

public static List<IdentityProviderRepresentation> getIdentityProviders() {
List<IdentityProviderRepresentation> providers = new ArrayList<>(3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ public static void main(String[] args) {
.stream()
.filter(r -> r.getRealm().equals(realm.getRealm()))
.findFirst()
.ifPresentOrElse(
r -> {
if (!ExternalConfig.shouldOverrideExistingConfiguration()) {
throw new UnsupportedOperationException("Configured not to override existing configuration => Exiting");
}
admin.realms().realm(r.getRealm()).remove();
},
() -> admin.realms().create(realm)
);
.ifPresent(r -> {
if (!ExternalConfig.shouldOverrideExistingConfiguration()) {
throw new UnsupportedOperationException("Configured not to override existing configuration => Exiting");
}
admin.realms().realm(r.getRealm()).remove();
});
admin.realms().create(realm);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

public final class CornRealm extends RealmRepresentation {
private static final String REALM_NAME = "Corn";
private static final String DEFAULT_SIGNATURE_ALGORITHM = "ES512";

public CornRealm() {
setRealm(REALM_NAME);
Expand All @@ -18,7 +17,10 @@ public CornRealm() {
setRevokeRefreshToken(true);
setRememberMe(true);
setBruteForceProtected(true);
setDefaultSignatureAlgorithm(DEFAULT_SIGNATURE_ALGORITHM);

if(ExternalConfig.shouldCreatePlaceholderUsers()) {
setUsers(PlaceholderUsers.generate());
}

if(ExternalConfig.KCCFG_LOGIN_THEME_NAME != null) {
setLoginTheme(ExternalConfig.KCCFG_LOGIN_THEME_NAME);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package keycloakinitializer.realm.corn;

import org.keycloak.representations.idm.CredentialRepresentation;
import org.keycloak.representations.idm.UserRepresentation;

import java.util.List;
import java.util.stream.Stream;

import static java.util.Collections.singletonList;

public class PlaceholderUsers {

private static final String MAIL_SUFFIX = "@mail.pl";
private static final String DEFAULT_ROLE = "default-roles-corn";

public static List<UserRepresentation> generate() {
return Stream.of(
new SimpleUser("Jan", "Kowalski", "jan", "123"),
new SimpleUser("Andrzej", "Switch", "andrzej", "123"),
new SimpleUser("John", "Doe", "john", "123"),
new SimpleUser("Jane", "Doe", "jane", "123"),
new SimpleUser("Alice", "Smith", "alice", "123"),
new SimpleUser("Bob", "Johnson", "bob", "123")
).map(SimpleUser::intoUserRepresentation).toList();
}

private record SimpleUser(String name, String surname, String username, String password) {

UserRepresentation intoUserRepresentation() {
return new UserRepresentation() {{
setUsername(username());
setFirstName(name);
setLastName(surname);
setEmail(username.toLowerCase()+MAIL_SUFFIX);
setEmailVerified(true);
setEnabled(true);
setRealmRoles(List.of(DEFAULT_ROLE));
setCredentials(singletonList(new CredentialRepresentation() {{
setType(CredentialRepresentation.PASSWORD);
setValue(password());
}}));
}};
}

}
}
21 changes: 21 additions & 0 deletions auth-server/keycloak-theme/Dockerfile.keycloak.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM alpine:3.19.1 AS build

WORKDIR /keycloak-theme

RUN apk update --no-cache && apk add --no-cache nodejs npm zip

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build:corn:prod

RUN mv themes theme

RUN zip -r corn-theme.jar theme META-INF

FROM quay.io/keycloak/keycloak:20.0.1

COPY --from=build /keycloak-theme/corn-theme.jar /opt/keycloak/providers/
21 changes: 0 additions & 21 deletions auth-server/keycloak-theme/Dockerfile.prod

This file was deleted.

6 changes: 6 additions & 0 deletions auth-server/keycloak-theme/META-INF/keycloak-themes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"themes": [{
"name" : "corn",
"types": [ "login" ]
}]
}
Loading
Loading