Compare commits

...
24 Commits
Author SHA1 Message Date
2martens 64faaa3c4a fix: Remove policy checker
continuous-integration/drone/tag Build is passing
2025-07-26 14:25:15 +02:00
2martens 32581e9cc8 fix: Make sure application starts up again
continuous-integration/drone/tag Build is passing
2025-07-26 14:14:06 +02:00
2martens 93016dabfa fix: Align ServiceProperties with rest of properties 2025-07-26 13:37:52 +02:00
2martens 6fb144ef43 fix: Remove config server and kafka
continuous-integration/drone/tag Build is passing
2025-07-26 13:31:34 +02:00
2martens 04bec53671 fix: Change ServiceProperties to open class
continuous-integration/drone/tag Build is passing
2025-07-26 13:24:13 +02:00
2martens 40ed9b8fba maintenance: Update versions
continuous-integration/drone/tag Build is passing
2025-07-26 12:59:46 +02:00
2martens a8d2aaef09 fix: Change realm to twomartens 2025-07-26 12:23:47 +02:00
2martens 6add2baa40 fix: Prevent endless loop
continuous-integration/drone/tag Build is passing
2024-06-09 11:12:47 +02:00
2martens 6c13815fc3 chore: Add dummy election result for 2024 2024-05-06 22:26:55 +02:00
2martens 1443dfce1b chore: Update requests for Bezirkswahl 2024 2024-05-06 21:58:28 +02:00
2martens ddf24b42e2 chore: Add http request to create election 2024-05-06 21:58:15 +02:00
2martens f2c1d1ea49 Revert "fix: Remove kafka"
continuous-integration/drone/tag Build is passing
This reverts commit 0082305a5a.
2024-03-08 22:21:27 +01:00
2martens aaec4e940a fix: Prevent memory leak 2024-03-08 22:19:55 +01:00
2martens a02dfa100c chore: Version update
continuous-integration/drone/tag Build is passing
2024-03-06 15:19:53 +01:00
2martens 0082305a5a fix: Remove kafka
continuous-integration/drone/tag Build is passing
2024-03-06 15:06:32 +01:00
2martens 11345c94a5 fix: Update values in correct repository 2024-01-06 15:41:51 +01:00
2martens f5f773a90b Added logging and reformatted, updated drone config
continuous-integration/drone/tag Build is passing
continuous-integration/drone/promote/test Build is passing
2023-10-30 13:30:17 +01:00
2martens 323337ed64 Added quotes around bootstrap server property
continuous-integration/drone/tag Build is passing
2023-10-30 00:32:19 +01:00
2martens b04d6f4389 Added support for passing ports in via environment variables 2023-10-29 18:07:50 +01:00
2martens 517f2b4f1b Fixed kafka errors
continuous-integration/drone/tag Build is passing
2023-10-29 01:07:02 +02:00
2martens f089d70d5f Remove deprecated usage 2023-10-29 00:50:55 +02:00
2martens 2a78b47d83 Added configs to producer and consumer as well
continuous-integration/drone/tag Build is passing
2023-10-29 00:42:47 +02:00
2martens 84baee6ebb Upgrade gradle version 2023-10-28 11:00:50 +02:00
2martens 35a1b49412 Removed chart 2023-08-23 08:28:47 +02:00
26 changed files with 1380 additions and 1394 deletions
+7 -23
View File
@@ -118,10 +118,13 @@ steps:
- ssh-keyscan -H git.2martens.de > $HOME/.ssh/known_hosts 2>/dev/null - ssh-keyscan -H git.2martens.de > $HOME/.ssh/known_hosts 2>/dev/null
- git clone ssh://giteajim@git.2martens.de:22/2martens/cloud-configuration.git . - git clone ssh://giteajim@git.2martens.de:22/2martens/cloud-configuration.git .
- git checkout main - git checkout main
- name: modify deployed image - name: update image version
image: alpine image: alpine
commands: commands:
- sed -i -r "s/(wahlrecht_image_version:).*/\1\ ${DRONE_SEMVER}/" ansible/inventories/host_vars/api-server/public.yaml - mkdir $HOME/bin
- wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_arm64 -O $HOME/bin/yq && chmod +x $HOME/bin/yq
- sed -i -r "s/(tag:).*/\1\ \"${DRONE_SEMVER}\"/" argocd/wahlrecht/${DRONE_DEPLOY_TO}/overwrite_values.yaml
- cd argocd/wahlrecht/${DRONE_DEPLOY_TO} && $HOME/bin/yq '. *= load("overwrite_values.yaml")' default_values.yaml > values.yaml
- name: save modified variable file - name: save modified variable file
image: alpine/git image: alpine/git
environment: environment:
@@ -134,32 +137,13 @@ steps:
- touch $HOME/.ssh/known_hosts - touch $HOME/.ssh/known_hosts
- chmod 600 $HOME/.ssh/known_hosts - chmod 600 $HOME/.ssh/known_hosts
- ssh-keyscan -H git.2martens.de > $HOME/.ssh/known_hosts 2>/dev/null - ssh-keyscan -H git.2martens.de > $HOME/.ssh/known_hosts 2>/dev/null
- git add ansible/inventories/host_vars/api-server/public.yaml - git add argocd/wahlrecht/${DRONE_DEPLOY_TO}/*
- git diff-index --quiet HEAD || git commit -m "[Drone] Changed wahlrecht_image_version to ${DRONE_SEMVER}" - git diff-index --quiet HEAD || git commit -m "[Drone] Changed wahlrecht_image_version to ${DRONE_SEMVER}"
- git push origin main - git push origin main
- name: deploy image
image: plugins/ansible:latest
volumes:
- name: cache
path: /root/.ansible
settings:
playbook: ansible/deploy_spring.yaml
inventory: ansible/inventories/production
galaxy: ansible/requirements.yaml
galaxy_force: false
private_key:
from_secret: private_ssh_key
vault_password:
from_secret: vault_password
volumes:
- name: cache
host:
path: /var/lib/drone/cache/.ansible
trigger: trigger:
target: target:
- production - test
event: event:
include: include:
- promote - promote
-20
View File
@@ -1,20 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="MainApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
<module name="wahlrecht.server.main" />
<option name="SPRING_BOOT_MAIN_CLASS" value="de.twomartens.wahlrecht.MainApplication" />
<extension name="net.ashald.envfile">
<option name="IS_ENABLED" value="true" />
<option name="IS_SUBST" value="false" />
<option name="IS_PATH_MACRO_SUPPORTED" value="false" />
<option name="IS_IGNORE_MISSING_FILES" value="false" />
<option name="IS_ENABLE_EXPERIMENTAL_INTEGRATIONS" value="false" />
<ENTRIES>
<ENTRY IS_ENABLED="true" PARSER="runconfig" IS_EXECUTABLE="false" />
<ENTRY IS_ENABLED="true" PARSER="env" IS_EXECUTABLE="false" PATH=".env" />
</ENTRIES>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
@@ -54,7 +54,7 @@ normalization.runtimeClasspath.metaInf {
} }
tasks.register("cleanLibs") { tasks.register("cleanLibs") {
delete("${buildDir}/libs") delete("${layout.buildDirectory}/libs")
} }
tasks.build { tasks.build {
@@ -9,10 +9,10 @@ apply(plugin="com.netflix.nebula.release")
tasks.register("writeVersionProperties") { tasks.register("writeVersionProperties") {
group = "version" group = "version"
mustRunAfter("release") mustRunAfter("release")
outputs.file("$buildDir/version.properties") outputs.file("${layout.buildDirectory}/version.properties")
val directory = buildDir val directory = layout.buildDirectory.asFile
doLast { doLast {
Files.createDirectories(directory.toPath()) Files.createDirectories(directory.get().toPath())
File("$buildDir/version.properties").writeText("VERSION=${project.version}\n") File("${layout.buildDirectory}/version.properties").writeText("VERSION=${project.version}\n")
} }
} }
+15 -14
View File
@@ -1,21 +1,22 @@
[versions] [versions]
spring-boot = "3.1.2" spring-boot = "3.5.4"
spring-doc = "2.1.0" spring-doc = "2.8.9"
spring-cloud = "2022.0.4" spring-cloud = "2025.0.0"
spring-grpc = "2.14.0.RELEASE" spring-grpc = "2.14.0.RELEASE"
grpc = "1.57.0" grpc = "1.57.0"
tomcat-annotations = "6.0.53" tomcat-annotations = "6.0.53"
httpclient = "5.2.1" httpclient = "5.5"
slf4j = "2.0.7" slf4j = "2.0.17"
log4j = "2.20.0" log4j = "2.25.1"
log4j-ecs = "1.5.0" log4j-ecs = "1.7.0"
mapstruct = "1.5.5.Final" mapstruct = "1.6.3"
junit = "5.10.0" junit = "5.13.4"
assertj = "3.24.2" assertj = "3.27.3"
mockito = "5.4.0" mockito = "5.18.0"
keycloak = "22.0.1" keycloak = "26.3.2"
keycloak-policy-enforcer = "26.0.6"
kotlin-logging = "3.0.5" kotlin-logging = "3.0.5"
kotlin-reflect = "1.9.0" kotlin-reflect = "2.2.0"
kotlin-lombok = "1.9.0" kotlin-lombok = "1.9.0"
plugin-nebula-release = "17.2.2" plugin-nebula-release = "17.2.2"
plugin-lombok = "8.0.1" plugin-lombok = "8.0.1"
@@ -47,7 +48,7 @@ spring-ui = { module = "org.springdoc:springdoc-openapi-starter-webmvc-ui", vers
spring-sec = { module = "org.springdoc:springdoc-openapi-starter-common", version.ref = "spring-doc" } spring-sec = { module = "org.springdoc:springdoc-openapi-starter-common", version.ref = "spring-doc" }
spring-openapi = { module = "org.springdoc:springdoc-openapi-starter-webmvc-api", version.ref = "spring-doc" } spring-openapi = { module = "org.springdoc:springdoc-openapi-starter-webmvc-api", version.ref = "spring-doc" }
keycloak-core = { module = "org.keycloak:keycloak-core", version.ref = "keycloak" } keycloak-core = { module = "org.keycloak:keycloak-core", version.ref = "keycloak" }
keycloak-policy-enforcer = { module = "org.keycloak:keycloak-policy-enforcer", version.ref = "keycloak" } keycloak-policy-enforcer = { module = "org.keycloak:keycloak-policy-enforcer", version.ref = "keycloak-policy-enforcer" }
grpc-api = { module = "io.grpc:grpc-api", version.ref = "grpc" } grpc-api = { module = "io.grpc:grpc-api", version.ref = "grpc" }
grpc-context = { module = "io.grpc:grpc-context", version.ref = "grpc" } grpc-context = { module = "io.grpc:grpc-context", version.ref = "grpc" }
grpc-core = { module = "io.grpc:grpc-core", version.ref = "grpc" } grpc-core = { module = "io.grpc:grpc-core", version.ref = "grpc" }
+1 -1
View File
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
File diff suppressed because it is too large Load Diff
+60
View File
@@ -0,0 +1,60 @@
PUT http://localhost:12000/wahlrecht/v1/election
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJkalp3QzZGZEZ4eHl4R0RfX3JRYVhIMzNCc0Fxa29fYXZoelRlX19IYUxRIn0.eyJleHAiOjE3MTQ5ODE3NDUsImlhdCI6MTcxNDk4MDg0NSwiYXV0aF90aW1lIjoxNzE0OTc5Njk1LCJqdGkiOiIyMzcwNTU4My1mYTE2LTQ4NWYtODNlMC0xMWIyZjg0ODEyM2YiLCJpc3MiOiJodHRwczovL2lkLjJtYXJ0ZW5zLmRlL3JlYWxtcy8ybWFydGVucyIsImF1ZCI6WyJ0c3ctdGltZXRhYmxlLWZyb250ZW5kIiwiYWNjb3VudCIsInRpbWV0YWJsZSJdLCJzdWIiOiJkOTRiMzU3My05ZjdhLTRjYmMtYTg5MS1kZGRjYWQ1MjE0YjMiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJ3YWhscmVjaHQiLCJzZXNzaW9uX3N0YXRlIjoiZGIxNmVmNzItZTUyMi00ZWE4LThjNjAtYjRjYmRiMTEzNjEyIiwiYWNyIjoiMCIsImFsbG93ZWQtb3JpZ2lucyI6WyJodHRwczovL2FwaS4ybWFydGVucy5kZSIsImh0dHA6Ly9sb2NhbGhvc3Q6MTIwMDAiXSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbIm9mZmxpbmVfYWNjZXNzIiwiQ09SRV9FTEVDVElPTl9EQVRBX0NPTlRSSUJVVE9SIiwiZGVmYXVsdC1yb2xlcy13YWhscmVjaHQiLCJBRE1JTiIsInVtYV9hdXRob3JpemF0aW9uIiwiVVNFUiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7InRzdy10aW1ldGFibGUtZnJvbnRlbmQiOnsicm9sZXMiOlsiQUNUSVZFX1BMQU4iLCJQRVJTT05BTF9QTEFOIiwiRlJFRV9QTEFOIl19LCJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX0sInRpbWV0YWJsZSI6eyJyb2xlcyI6WyJBRE1JTiIsIlBFUlNPTkFMX1BMQU4iLCJGUkVFX1BMQU4iXX19LCJzY29wZSI6InByb2ZpbGUgZW1haWwiLCJzaWQiOiJkYjE2ZWY3Mi1lNTIyLTRlYTgtOGM2MC1iNGNiZGIxMTM2MTIiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwibmFtZSI6IkppbSBNYXJ0ZW5zIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiZ2l0aHViQDJtYXJ0ZW5zLmRlIiwiZ2l2ZW5fbmFtZSI6IkppbSIsImxvY2FsZSI6ImVuIiwiZmFtaWx5X25hbWUiOiJNYXJ0ZW5zIiwiZW1haWwiOiJnaXRodWJAMm1hcnRlbnMuZGUifQ.VWDniNAGZOdBbQ3rIia81VqchT9fL0PbT4TS8ORpueRTVe8j2gatwDEPz3ocIFNevNh5hv0gQpjcYT8XGh5rk8oNbHrFg48uJZC5SfINzEEq9JYUQCLf_LGiXmfCODwKaRZc6EVFYU34t7d-SXrN0qNcFooFnV7erD57GJB--19nVOAv1zsQKDV_lJYz6SHGlPZol0PBOHwRaREjgsS1zw8kNOBZYFiuaAbHCOl3rrZb0YZevB1_qtPWtdCOCEjCIlGURIU6Wn6xTNUG1MkE2yytArJS1yGUfBnDDg1mAck5q_fl0a9T7lucyhakSNjauFGUWIsJP4ADdJZhn8CDVQ
Content-Type: application/json
{
"name": "Bezirkswahl 2024",
"day": "2024-06-09",
"votingThreshold": "THREE",
"totalNumberOfSeats": 51,
"constituencies": [
{
"electionName": "Bezirkswahl 2024",
"number": 5,
"name": "Niendorf",
"numberOfSeats": 5
},
{
"electionName": "Bezirkswahl 2024",
"number": 6,
"name": "Schnelsen",
"numberOfSeats": 3
},
{
"electionName": "Bezirkswahl 2024",
"number": 7,
"name": "Eidelstedt",
"numberOfSeats": 4
},
{
"electionName": "Bezirkswahl 2024",
"number": 8,
"name": "Stellingen",
"numberOfSeats": 3
},
{
"electionName": "Bezirkswahl 2024",
"number": 4,
"name": "Lokstedt",
"numberOfSeats": 3
},
{
"electionName": "Bezirkswahl 2024",
"number": 3,
"name": "Rotherbaum/Harvestehude",
"numberOfSeats": 4
},
{
"electionName": "Bezirkswahl 2024",
"number": 1,
"name": "Eimsbüttel-Nord",
"numberOfSeats": 3
},
{
"electionName": "Bezirkswahl 2024",
"number": 2,
"name": "Eimsbüttel-Süd/Hoheluft-West",
"numberOfSeats": 5
}
]
}
File diff suppressed because it is too large Load Diff
-3
View File
@@ -1,3 +0,0 @@
apiVersion: v2
name: wahlrecht
version: 0.2.4
-201
View File
@@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-4
View File
@@ -1,4 +0,0 @@
# Wahlrecht API
This chart installs the Wahlrecht API
into the Kubernetes cluster.
-2
View File
@@ -9,6 +9,4 @@ dependencies {
implementation(libs.bundles.spring.boot.security) implementation(libs.bundles.spring.boot.security)
annotationProcessor(libs.mapstruct.processor) annotationProcessor(libs.mapstruct.processor)
kapt(libs.mapstruct.processor) kapt(libs.mapstruct.processor)
implementation(libs.spring.cloud.starter.config)
implementation(libs.spring.cloud.starter.bus.kafka)
} }
@@ -15,9 +15,9 @@ import org.springframework.context.annotation.Configuration
name = "oauth2", name = "oauth2",
type = SecuritySchemeType.OAUTH2, type = SecuritySchemeType.OAUTH2,
flows = OAuthFlows( flows = OAuthFlows(
implicit = OAuthFlow( authorizationCode = OAuthFlow(
authorizationUrl = "https://id.2martens.de/realms/2martens/protocol/openid-connect/auth", authorizationUrl = "https://id.2martens.de/realms/twomartens/protocol/openid-connect/auth",
tokenUrl = "https://id.2martens.de/realms/2martens/protocol/openid-connect/token" tokenUrl = "https://id.2martens.de/realms/twomartens/protocol/openid-connect/token"
) )
) )
) )
@@ -11,13 +11,10 @@ import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Configuration
import org.springframework.http.HttpMethod import org.springframework.http.HttpMethod
import org.springframework.security.config.Customizer
import org.springframework.security.config.annotation.web.builders.HttpSecurity import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer
import org.springframework.security.oauth2.jwt.JwtDecoder import org.springframework.security.oauth2.jwt.JwtDecoder
import org.springframework.security.oauth2.jwt.NimbusJwtDecoder import org.springframework.security.oauth2.jwt.NimbusJwtDecoder
import org.springframework.security.oauth2.server.resource.web.authentication.BearerTokenAuthenticationFilter
import org.springframework.security.web.SecurityFilterChain import org.springframework.security.web.SecurityFilterChain
import java.io.IOException import java.io.IOException
@@ -38,8 +35,6 @@ open class WebSecurityConfiguration {
.authorizeHttpRequests { it.requestMatchers(*PERMITTED_PATHS.toTypedArray<String>()).permitAll() } .authorizeHttpRequests { it.requestMatchers(*PERMITTED_PATHS.toTypedArray<String>()).permitAll() }
.authorizeHttpRequests { it.requestMatchers(HttpMethod.OPTIONS).permitAll() } .authorizeHttpRequests { it.requestMatchers(HttpMethod.OPTIONS).permitAll() }
.authorizeHttpRequests { it.anyRequest().authenticated() } .authorizeHttpRequests { it.anyRequest().authenticated() }
.oauth2ResourceServer { obj: OAuth2ResourceServerConfigurer<HttpSecurity?> -> obj.jwt(Customizer.withDefaults()) }
.addFilterAfter(createPolicyEnforcerFilter(), BearerTokenAuthenticationFilter::class.java)
return http.build() return http.build()
} }
@@ -2,13 +2,12 @@ package de.twomartens.wahlrecht.property
import io.swagger.v3.oas.annotations.media.Schema import io.swagger.v3.oas.annotations.media.Schema
import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.cloud.context.config.annotation.RefreshScope import org.springframework.boot.context.properties.bind.ConstructorBinding
import java.time.ZoneId import java.time.ZoneId
@RefreshScope
@ConfigurationProperties(prefix = "de.twomartens.wahlrecht") @ConfigurationProperties(prefix = "de.twomartens.wahlrecht")
@Schema(description = "Properties, to configure this Application") @Schema(description = "Properties, to configure this Application")
class ServiceProperties { data class ServiceProperties @ConstructorBinding constructor(
lateinit var defaultTimeZone: ZoneId val defaultTimeZone: ZoneId,
lateinit var greeting: String val greeting: String
} )
@@ -4,11 +4,9 @@ import io.swagger.v3.oas.annotations.media.Schema
import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.bind.ConstructorBinding import org.springframework.boot.context.properties.bind.ConstructorBinding
import org.springframework.boot.convert.DurationUnit import org.springframework.boot.convert.DurationUnit
import org.springframework.cloud.context.config.annotation.RefreshScope
import java.time.Duration import java.time.Duration
import java.time.temporal.ChronoUnit import java.time.temporal.ChronoUnit
@RefreshScope
@ConfigurationProperties(prefix = "de.twomartens.wahlrecht.statusprobe") @ConfigurationProperties(prefix = "de.twomartens.wahlrecht.statusprobe")
@Schema(description = "Properties, to configure this Application") @Schema(description = "Properties, to configure this Application")
data class StatusProbeProperties @ConstructorBinding constructor( data class StatusProbeProperties @ConstructorBinding constructor(
@@ -30,6 +30,7 @@ class SpringPolicyEnforcer(private val policyEnforcer: PolicyEnforcer,
private fun authorize(request: HttpRequest, response: HttpResponse): AuthorizationContext { private fun authorize(request: HttpRequest, response: HttpResponse): AuthorizationContext {
val enforcementMode = policyEnforcerConfig.enforcementMode val enforcementMode = policyEnforcerConfig.enforcementMode
log.debug("Authorize with enforcement mode: [{}]", enforcementMode)
return if (EnforcementMode.DISABLED == enforcementMode) { return if (EnforcementMode.DISABLED == enforcementMode) {
createAuthorizedContext() createAuthorizedContext()
} else policyEnforcer.enforce(request, response) } else policyEnforcer.enforce(request, response)
@@ -12,18 +12,15 @@ import org.keycloak.adapters.authorization.spi.ConfigurationResolver
import org.keycloak.adapters.authorization.spi.HttpRequest import org.keycloak.adapters.authorization.spi.HttpRequest
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig import org.keycloak.representations.adapters.config.PolicyEnforcerConfig
import java.io.IOException import java.io.IOException
import java.util.concurrent.ConcurrentHashMap
class SpringPolicyEnforcerFilter(private val configResolver: ConfigurationResolver) : Filter { class SpringPolicyEnforcerFilter(private val configResolver: ConfigurationResolver) : Filter {
private val policyEnforcer: MutableMap<PolicyEnforcerConfig, SpringPolicyEnforcer> = ConcurrentHashMap()
@Throws(IOException::class, ServletException::class) @Throws(IOException::class, ServletException::class)
override fun doFilter(servletRequest: ServletRequest, servletResponse: ServletResponse?, filterChain: FilterChain) { override fun doFilter(servletRequest: ServletRequest, servletResponse: ServletResponse?, filterChain: FilterChain) {
val request = servletRequest as HttpServletRequest val request = servletRequest as HttpServletRequest
val response = servletResponse as HttpServletResponse? val response = servletResponse as HttpServletResponse?
val httpRequest = ServletHttpRequest(request) { extractBearerToken(request) } val httpRequest = ServletHttpRequest(request) { extractBearerToken(request) }
val policyEnforcer = getOrCreatePolicyEnforcer(httpRequest) val policyEnforcer = createPolicyEnforcer(httpRequest)
val authzContext = policyEnforcer.enforce(httpRequest, ServletHttpResponse(response)) val authzContext = policyEnforcer.enforce(httpRequest, ServletHttpResponse(response))
request.setAttribute(AuthorizationContext::class.java.name, authzContext) request.setAttribute(AuthorizationContext::class.java.name, authzContext)
if (authzContext.isGranted) { if (authzContext.isGranted) {
@@ -53,8 +50,8 @@ class SpringPolicyEnforcerFilter(private val configResolver: ConfigurationResolv
return null return null
} }
private fun getOrCreatePolicyEnforcer(request: HttpRequest): SpringPolicyEnforcer { private fun createPolicyEnforcer(request: HttpRequest): SpringPolicyEnforcer {
return policyEnforcer.computeIfAbsent(configResolver.resolve(request)) { createPolicyEnforcer(it) } return createPolicyEnforcer(configResolver.resolve(request))
} }
private fun createPolicyEnforcer(enforcerConfig: PolicyEnforcerConfig): SpringPolicyEnforcer { private fun createPolicyEnforcer(enforcerConfig: PolicyEnforcerConfig): SpringPolicyEnforcer {
@@ -247,6 +247,7 @@ class CalculationService(
var assignedSeats: Long var assignedSeats: Long
var assignedSeatsPerVotingResult: Map<VotingResult, Int> var assignedSeatsPerVotingResult: Map<VotingResult, Int>
log.debug("Calculate assigned seats with initial election number {}", electionNumber) log.debug("Calculate assigned seats with initial election number {}", electionNumber)
var numberOfAttempts = 5
do { do {
electionNumberHistory.add(electionNumber) electionNumberHistory.add(electionNumber)
val seatsPerVotingResult: MutableMap<VotingResult, Double> = mutableMapOf() val seatsPerVotingResult: MutableMap<VotingResult, Double> = mutableMapOf()
@@ -277,7 +278,11 @@ class CalculationService(
) )
log.debug("Calculated higher election number {}", electionNumber) log.debug("Calculated higher election number {}", electionNumber)
} }
} while (assignedSeats != numberOfSeats.toLong()) numberOfAttempts--
} while (assignedSeats != numberOfSeats.toLong() && numberOfAttempts > 0)
if (numberOfAttempts == 0 && assignedSeats != numberOfSeats.toLong()) {
log.error("With the given result, the solution can never be calculated")
}
return assignedSeatsPerVotingResult return assignedSeatsPerVotingResult
} }
@@ -1,9 +0,0 @@
server.port: 12000
management.server.port: 12001
spring:
config:
import:
- "classpath:config/wahlrecht.yaml"
- "optional:configserver:${CONFIGSERVER_SCHEME:http}://${CONFIGSERVER_HOST:configserver}:${CONFIGSERVER_PORT:8888}${CONFIGSERVER_PREFIX:/config}"
@@ -1,7 +0,0 @@
spring:
config:
import:
- "configserver:${CONFIGSERVER_SCHEME:http}://${CONFIGSERVER_HOST:configserver}:${CONFIGSERVER_PORT:8888}${CONFIGSERVER_PREFIX:/config}"
kafka:
bootstrap-servers:
- ${KAFKA_HOST:kafka}:${KAFKA_PORT:9092}
@@ -1,12 +1,12 @@
server: server:
port: 12000 port: ${PORT:12000}
shutdown: graceful shutdown: graceful
forward-headers-strategy: framework forward-headers-strategy: framework
### technical configurations ### ### technical configurations ###
management: management:
# for security, don't use same port as application # for security, don't use same port as application
server.port: 12001 server.port: ${ACTUATOR_PORT:12001}
health: health:
livenessState.enabled: true livenessState.enabled: true
readinessState.enabled: true readinessState.enabled: true
@@ -24,9 +24,6 @@ management:
http.server.requests: true http.server.requests: true
spring: spring:
cloud:
config:
name: wahlrecht
main: main:
banner-mode: off banner-mode: off
profiles: profiles:
@@ -38,7 +35,7 @@ spring:
oauth2: oauth2:
resourceserver: resourceserver:
jwt: jwt:
jwk-set-uri: ${KEYCLOAK_URL:https://id.2martens.de}/realms/${KEYCLOAK_REALM:2martens}/protocol/openid-connect/certs jwk-set-uri: ${KEYCLOAK_URL:https://id.2martens.de}/realms/${KEYCLOAK_REALM:twomartens}/protocol/openid-connect/certs
application: application:
name: wahlrecht name: wahlrecht
@@ -87,3 +84,12 @@ resttemplate:
connectionRestHealthIndicatorTimeoutInMillis: 5000 connectionRestHealthIndicatorTimeoutInMillis: 5000
readTimeoutRestTemplateInMillis: 5000 readTimeoutRestTemplateInMillis: 5000
connectionRestTemplateTimeoutInMillis: 5000 connectionRestTemplateTimeoutInMillis: 5000
de.twomartens.wahlrecht:
defaultTimeZone: Europe/Berlin
greeting: "Hello %s, on millenium"
statusprobe:
scheduleDuration: 60
maxKafkaFailureDuration: 5
maxBlobFailureCount: 5
maxFailurePercent: 50
@@ -1,2 +0,0 @@
de.twomartens.wahlrecht:
greeting: "Moin %s, you are test"
@@ -1,8 +0,0 @@
de.twomartens.wahlrecht:
defaultTimeZone: Europe/Berlin
greeting: "Hello %s, on millenium"
statusprobe:
scheduleDuration: 60
maxKafkaFailureDuration: 5
maxBlobFailureCount: 5
maxFailurePercent: 50
@@ -1,5 +1,5 @@
{ {
"realm": "2martens", "realm": "twomartens",
"auth-server-url": "https://id.2martens.de", "auth-server-url": "https://id.2martens.de",
"resource": "wahlrecht", "resource": "wahlrecht",
"http-method-as-scope": true "http-method-as-scope": true