Skip to content

Commit aee0c8f

Browse files
authored
Update LDAP group pattern property in ProjectServiceImpl and add info to application yaml… (#16)
This pull request makes significant improvements to the application's configuration, focusing on environment variable management, documentation, and flexibility for deployment in different environments. The main changes involve restructuring the `application.yaml` file to better organize configuration sections, enhance documentation, and ensure that sensitive or environment-specific values are supplied via environment variables. Additionally, there is a small fix in the `ProjectServiceImpl` class to align a configuration property key. **Configuration and Environment Management Improvements:** * Refactored `application.yaml` to consistently use environment variables for sensitive and environment-specific settings (e.g., database credentials, OAuth2 endpoints, external service URLs), improving security and deployment flexibility. * Enhanced inline documentation throughout `application.yaml` to clarify the purpose and usage of each configuration option, making onboarding and troubleshooting easier. [[1]](diffhunk://#diff-7f1ba62cb5d27efca72927e6323654ce62284153382d96af57c77893160b3fadR1-R103) [[2]](diffhunk://#diff-7f1ba62cb5d27efca72927e6323654ce62284153382d96af57c77893160b3fadL79-R163) [[3]](diffhunk://#diff-7f1ba62cb5d27efca72927e6323654ce62284153382d96af57c77893160b3fadL159-R228) [[4]](diffhunk://#diff-7f1ba62cb5d27efca72927e6323654ce62284153382d96af57c77893160b3fadR244-R246) [[5]](diffhunk://#diff-7f1ba62cb5d27efca72927e6323654ce62284153382d96af57c77893160b3fadR270-R279) * Added or expanded configuration sections for logging, Spring Boot infrastructure, security, actuator endpoints, OpenTelemetry, and external integrations (Ansible, OpenShift, Bitbucket, Projects Info Service), with detailed comments and improved defaulting via environment variables. [[1]](diffhunk://#diff-7f1ba62cb5d27efca72927e6323654ce62284153382d96af57c77893160b3fadR1-R103) [[2]](diffhunk://#diff-7f1ba62cb5d27efca72927e6323654ce62284153382d96af57c77893160b3fadL79-R163) [[3]](diffhunk://#diff-7f1ba62cb5d27efca72927e6323654ce62284153382d96af57c77893160b3fadL159-R228) [[4]](diffhunk://#diff-7f1ba62cb5d27efca72927e6323654ce62284153382d96af57c77893160b3fadR244-R246) [[5]](diffhunk://#diff-7f1ba62cb5d27efca72927e6323654ce62284153382d96af57c77893160b3fadR270-R279) **Code Consistency and Bug Fixes:** * Updated the property key in `ProjectServiceImpl.java` from `ldap.group.pattern` to `services.project.ldap.group.pattern` to match the new configuration structure, ensuring the correct value is injected.
1 parent 28b7333 commit aee0c8f

2 files changed

Lines changed: 131 additions & 75 deletions

File tree

application.yaml

Lines changed: 130 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,106 @@
1+
# Base HTTP server configuration.
2+
# Override these values with environment variables when deploying to another environment.
3+
server:
4+
# TCP port used by the Spring Boot application.
5+
port: 8080
6+
7+
# Application logging configuration.
8+
# Raise levels temporarily for troubleshooting; keep them lower in shared environments.
19
logging:
210
level:
11+
# Core Spring framework logs.
312
org.springframework: INFO
13+
# Security filter chain and JWT validation logs.
414
org.springframework.security: TRACE
15+
# Custom external service integration logs.
516
org.opendevstack.apiservice.externalservice: DEBUG
617

7-
# ──────────────────────────────────────────────────────────────────────────────
8-
# Persistence — PostgreSQL datasource + JPA / Hibernate
9-
#
10-
# Schema is managed externally via Liquibase (database module / Makefile).
11-
# Hibernate is set to `validate` so it only checks that entities match the
12-
# existing schema at boot — it never creates or alters tables.
13-
#
14-
# Required env vars (no defaults — must be explicitly set per environment):
15-
# DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD
16-
# ──────────────────────────────────────────────────────────────────────────────
18+
# Spring Boot infrastructure configuration.
19+
# Most values here should be supplied from environment variables or a secret store.
1720
spring:
21+
security:
22+
oauth2:
23+
resourceserver:
24+
jwt:
25+
# URL of the identity provider JWK set used to validate JWT signatures.
26+
jwk-set-uri: ${OAUTH2_JWK_SET_URI:}
27+
# Expected issuer claim of incoming JWTs.
28+
issuer-uri: ${OAUTH2_ISSUER:}
29+
audiences:
30+
# Allowed audience values for access tokens accepted by this API.
31+
- ${OAUTH2_AUDIENCE:}
32+
- ${OAUTH2_AUDIENCE2:99999}
1833
datasource:
19-
url: jdbc:postgresql://${DB_HOST:localhost}:${DB_PORT:5432}/${DB_NAME:devstack}
20-
username: ${DB_USERNAME:devstack}
21-
password: ${DB_PASSWORD:devstack}
34+
# JDBC connection string for the PostgreSQL database.
35+
# Example: jdbc:postgresql://localhost:5432/ods_api_service
36+
url: ${ODS_API_SERVICE_DB_DATASOURCE_URL}
37+
# Database user used by the application.
38+
username: ${ODS_API_SERVICE_DB_USER:opendevstack}
39+
# Database password. Use a secret manager or injected environment variable in non-local setups.
40+
password: ${ODS_API_SERVICE_DB_PASSWORD:opendevstack}
41+
# JDBC driver class. Keep this aligned with the database engine in use.
2242
driver-class-name: org.postgresql.Driver
2343
hikari:
24-
# Pool sizing — tune per environment
25-
maximum-pool-size: ${DB_POOL_MAX_SIZE:10}
26-
minimum-idle: ${DB_POOL_MIN_IDLE:2}
27-
connection-timeout: 30000
28-
idle-timeout: 600000
29-
max-lifetime: 1800000
44+
# Maximum number of open connections in the pool.
45+
maximum-pool-size: ${HIKARI_POOL_MAX_SIZE:10}
46+
# Minimum number of idle connections kept ready.
47+
minimum-idle: ${HIKARI_MIN_IDLE:2}
48+
# Time to wait for a free connection before failing, in milliseconds.
49+
connection-timeout: ${HIKARI_CONNECTION_TIMEOUT:30000}
50+
# How long an idle connection may stay in the pool, in milliseconds.
51+
idle-timeout: ${HIKARI_IDLE_TIMEOUT:600000}
52+
# Maximum lifetime of a pooled connection, in milliseconds.
53+
max-lifetime: ${HIKARI_MAX_LIFETIME:1800000}
3054
jpa:
3155
hibernate:
32-
# NEVER auto-create/alter — Liquibase owns the schema
33-
ddl-auto: validate
56+
# Schema management mode. Use validate/update locally, avoid create/create-drop in shared environments.
57+
ddl-auto: ${JPA_HIBERNATE_DDL_AUTO:validate}
3458
properties:
3559
hibernate:
36-
dialect: org.hibernate.dialect.PostgreSQLDialect
37-
# Log slow queries (> 500 ms) via Hibernate statistics
38-
generate_statistics: false
39-
# Avoid lazy-loading pitfalls: keep Session scoped to Service, not Request
40-
open-in-view: false
41-
show-sql: false
42-
43-
spring:
44-
security:
45-
oauth2:
46-
resourceserver:
47-
jwt:
48-
issuer-uri: https://sts.windows.net/${AZURE_TENANT_ID}/
60+
# Enable Hibernate statistics only while investigating performance issues.
61+
generate_statistics: ${JPA_HIBERNATE_GENERATE_STATISTICS:false}
62+
# Disable the Open Session in View pattern by default.
63+
open-in-view: ${JPA_OPEN_IN_VIEW:false}
64+
# Log SQL statements only for debugging.
65+
show-sql: ${JPA_SHOW_SQL:false}
66+
management:
67+
endpoints:
68+
web:
69+
exposure:
70+
# Minimal actuator exposure under spring.*; the top-level management block below extends this further.
71+
include: ${MANAGEMENT_ENDPOINTS_INCLUDE:health}
4972

73+
# Custom application-level security switches.
5074
app:
5175
security:
76+
# Master switch for application authentication and authorization.
77+
enabled: true
5278
public-endpoints:
79+
# Endpoints listed here remain reachable without authentication.
5380
- /actuator/health
54-
- /actuator/health/**
81+
- /actuator/info
82+
- /api/v1/projects/*/platforms
5583

84+
# Spring Boot Actuator configuration.
85+
# Restrict these endpoints in production if they expose operational details.
5686
management:
5787
endpoints:
5888
web:
5989
exposure:
90+
# Explicit list of actuator endpoints exposed over HTTP.
6091
include: openapi, swagger-ui, beans, caches, configprops, env, health, httpexchanges, info, loggers, mappings
6192
endpoint:
6293
configprops:
94+
# Shows bound configuration values in actuator output.
6395
show-values: always
6496
env:
97+
# Shows environment-derived values in actuator output.
6598
show-values: always
6699
loggers:
100+
# Allows runtime log level inspection and updates.
67101
access: unrestricted
68102
health:
103+
# Exposes full health details and individual contributors.
69104
show-details: always
70105
show-components: always
71106
info:
@@ -76,64 +111,68 @@ management:
76111
recording:
77112
# Show all available info in /actuator/httpexchanges and also in Swagger
78113
include: request-headers, response-headers, authorization_header, cookie_headers, principal, remote_address, session_id, time_taken
79-
springdoc:
80-
show-actuator: true
81-
swagger-ui:
82-
doc-expansion: none
83-
try-it-out-enabled: true
84-
filter: true
85-
tags-sorter: alpha
86-
operations-sorter: alpha
87-
88-
openapi:
89-
servers:
90-
- url: "https://localhost:8080"
91-
description: "Development environment"
92114

115+
116+
# OpenTelemetry settings.
117+
# Configure OTLP endpoint and sampling according to your observability platform.
93118
otel:
94-
service:
95-
name: devstack-api-service-dev
96-
version: 0.0.3
97-
exporter:
98-
otlp:
99-
endpoint: http://opentelemetry.example.com
100-
traces:
101-
exporter: logging,otlp
102-
sampler: parentbased_traceidratio
103-
sampler_arg: 1.0
104-
metrics:
105-
exporter: none
106-
resource:
107-
attributes: service.name=devstack-api-service,service.version=0.0.3,deployment.environment=development
108-
instrumentation:
109-
jdbc:
110-
enabled: false
111-
logback-appender:
112-
enabled: true
119+
service:
120+
# Logical service name and version attached to telemetry data.
121+
name: devstack-api-service-dev
122+
version: 0.0.3
123+
exporter:
124+
otlp:
125+
# Endpoint of the OpenTelemetry collector.
126+
endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT}
127+
traces:
128+
# Send traces to both application logs and the OTLP collector.
129+
exporter: logging,otlp
130+
# Parent-based ratio sampling. sampler_arg=1.0 means sample all traces.
131+
sampler: parentbased_traceidratio
132+
sampler_arg: 1.0
133+
metrics:
134+
# Metrics export is disabled here.
135+
exporter: none
136+
resource:
137+
# Resource attributes attached to every exported span.
138+
attributes: service.name=devstack-api-service,service.version=0.0.3,deployment.environment=development
139+
instrumentation:
140+
jdbc:
141+
# JDBC instrumentation is disabled, likely to reduce noise or overhead.
142+
enabled: false
143+
logback-appender:
144+
# Enables trace correlation through logback.
145+
enabled: true
113146

114147
# External Service Configuration
115148
automation:
116149
platform:
117150
ansible:
151+
# Toggle the Ansible automation integration.
118152
enabled: true
153+
# Base URL of the Ansible Automation Platform / AWX API.
119154
base-url: ${ANSIBLE_BASE_URL:http://localhost:8080/api/v2}
155+
# Credentials used to authenticate against Ansible.
120156
username: ${ANSIBLE_USERNAME:admin}
121157
password: ${ANSIBLE_PASSWORD:password}
158+
# Request timeout in milliseconds.
122159
timeout: ${ANSIBLE_TIMEOUT:30000}
123160
ssl:
161+
# When false, TLS certificates are not validated. Keep true outside local development.
124162
verify-certificates: ${ANSIBLE_SSL_VERIFY:true}
163+
# Optional custom trust store settings for private CA certificates.
125164
trust-store-path: ${ANSIBLE_SSL_TRUSTSTORE_PATH:}
126165
trust-store-password: ${ANSIBLE_SSL_TRUSTSTORE_PASSWORD:}
127166
trust-store-type: ${ANSIBLE_SSL_TRUSTSTORE_TYPE:JKS}
128167

129168
uipath:
130169
# Base URL of the UIPath Orchestrator instance
131170
host: ${UIPATH_HOST:https://orchestrator.example.com}
132-
171+
133172
# Authentication credentials
134173
clientId: ${UIPATH_CLIENT_ID:your-client-id}
135174
clientSecret: ${UIPATH_CLIENT_SECRET:your-client-secret}
136-
175+
137176
# Tenancy name (default: "default")
138177
tenancy-name: ${UIPATH_TENANCY_NAME:default}
139178

@@ -143,10 +182,10 @@ automation:
143182
# API endpoints (defaults shown, can be overridden)
144183
login-endpoint: /api/Account/Authenticate
145184
queue-items-endpoint: /odata/QueueItems
146-
185+
147186
# Request timeout in milliseconds
148187
timeout: 30000
149-
188+
150189
# SSL Configuration
151190
ssl:
152191
# Set to false to disable certificate verification (DEV ONLY!)
@@ -156,25 +195,37 @@ automation:
156195
trust-store-password: ${TRUSTSTORE_PASSWORD:changeit}
157196
trust-store-type: ${UIPATH_SSL_TRUST_STORE_TYPE:JKS}
158197

159-
160198
apis:
161199
project-users:
200+
# Workflow name triggered for project user automation tasks.
162201
ansible-workflow-name: ${API_PROJECT_USERS_WORKFLOW_NAME:ansible++workflow}
163202
token:
203+
# Secret used to sign internal tokens. Replace the default in every non-local environment.
164204
secret: ${API_PROJECT_USERS_TOKEN_SECRET:devstack-api-service-jwt-secret-key-256bit-change-in-production}
205+
# Token lifetime in hours.
165206
expiration-hours: ${API_PROJECT_USERS_TOKEN_EXPIRATION_HOURS:24}
166207

208+
projects:
209+
# Workflow name used for project provisioning automation.
210+
ansible-workflow-name: ${API_PROJECTS_MINIEDP_PROVISION_WORKFLOW_NAME}
211+
# Supported project locations, typically provided as a comma-separated environment variable.
212+
locations: ${API_PROJECTS_LOCATIONS}
167213

168214
externalservices:
169215
openshift:
170216
instances:
171217
# Development OpenShift instance
172218
dev:
219+
# API URL of the target cluster.
173220
api-url: ${OPENSHIFT_US_TEST_API_URL:https://api.dev.ocp.example.com:6443}
221+
# Service account or user token used to access the cluster API.
174222
token: ${OPENSHIFT_US_TEST_TOKEN:your-dev-token-here}
223+
# Default namespace/project to operate in.
175224
namespace: ${OPENSHIFT_US_TEST_NAMESPACE:devstack-dev}
225+
# HTTP client timeouts in milliseconds.
176226
connection-timeout: 30000
177227
read-timeout: 30000
228+
# When true, the client accepts untrusted certificates.
178229
trust-all-certificates: ${OPENSHIFT_US_TEST_TRUST_ALL:true}
179230

180231
# Test OpenShift instance
@@ -190,15 +241,17 @@ externalservices:
190241
instances:
191242
# Development Bitbucket instance
192243
dev:
244+
# Base REST URL of the Bitbucket server.
193245
base-url: ${BITBUCKET_DEV_BASE_REST_URL:https://bitbucket.dev.example.com}
246+
# Preferred authentication method: bearer token.
194247
bearer-token: ${BITBUCKET_DEV_BEARER_TOKEN:}
195248
# OR use basic auth if bearer token is not available:
196249
# username: ${BITBUCKET_DEV_USERNAME:admin}
197250
# password: ${BITBUCKET_DEV_PASSWORD:your-dev-password-here}
198251
connection-timeout: 30000
199252
read-timeout: 30000
200253
trust-all-certificates: ${BITBUCKET_DEV_TRUST_ALL:true}
201-
254+
202255
# Production Bitbucket instance
203256
prod:
204257
base-url: ${BITBUCKET_PROD_BASE_REST_URL:https://bitbucket.prod.example.com}
@@ -214,11 +267,14 @@ externalservices:
214267
clusters:
215268
# Test Cluster
216269
test:
270+
# Base cluster domain used to derive webhook proxy routes.
217271
cluster-base: ${WEBHOOK_PROXY_TEST_CLUSTER_BASE:apps.cluster.ocp.com}
218272
connection-timeout: ${WEBHOOK_PROXY_TEST_CONNECTION_TIMEOUT:30000}
219273
read-timeout: ${WEBHOOK_PROXY_TEST_READ_TIMEOUT:30000}
220274
trust-all-certificates: ${WEBHOOK_PROXY_TEST_TRUST_ALL:false}
275+
# Relative path to the Jenkinsfile used when none is supplied.
221276
default-jenkinsfile-path: ${WEBHOOK_PROXY_TEST_JENKINSFILE_PATH:Jenkinsfile}
222277

223278
projects-info-service:
224-
base-url: ${PROJECTS_INFO_SERVICE_BASE_URL:http://localhost:8081}
279+
# Base URL of the downstream Projects Info Service consumed by this application.
280+
base-url: ${PROJECTS_INFO_SERVICE_BASE_URL:http://localhost:8081}

service-projects/src/main/java/org/opendevstack/apiservice/serviceproject/service/impl/ProjectServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class ProjectServiceImpl implements ProjectService {
2020
private static final String TEAM_ROLE = "TEAM";
2121
private static final String STAKEHOLDER_ROLE = "STAKEHOLDER";
2222

23-
@Value("${ldap.group.pattern}")
23+
@Value("${services.project.ldap.group.pattern}")
2424
private String ldapGroupPattern;
2525

2626
private final ProjectRepository projectRepository;

0 commit comments

Comments
 (0)