Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 5 additions & 6 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,14 @@ jobs:
mkdir -p logs

echo "🚀 Starting Policy Decision Point..."
# Running with env vars mapping to what the code expects (based on docker-compose.test.yml analysis)
PORT=8082 \
LOG_LEVEL=debug \
DB_HOST=localhost \
DB_PORT=5433 \
DB_USERNAME=postgres \
DB_PASSWORD=password \
DB_NAME=policy_db \
DB_SSLMODE=disable \
CHOREO_OPENDIF_DATABASE_HOSTNAME=localhost \
CHOREO_OPENDIF_DATABASE_PORT=5433 \
CHOREO_OPENDIF_DATABASE_USERNAME=postgres \
CHOREO_OPENDIF_DATABASE_PASSWORD=password \
CHOREO_OPENDIF_DATABASE_DATABASENAME=policy_db \
RUN_MIGRATION=true \
./bin/policy-decision-point > logs/pdp.log 2>&1 &
PDP_PID=$!
Expand Down
45 changes: 0 additions & 45 deletions exchange/policy-decision-point/.choreo/component.yaml

This file was deleted.

20 changes: 10 additions & 10 deletions exchange/policy-decision-point/.env.template
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# DataBase Configuration
CHOREO_OPENDIF_DATABASE_HOSTNAME={your_database_host}
CHOREO_OPENDIF_DATABASE_PORT={your_database_host_port}
CHOREO_OPENDIF_DATABASE_NAME={your_database_name}
CHOREO_OPENDIF_DATABASE_USERNAME={your_database_username}
CHOREO_OPENDIF_DATABASE_PASSWORD={your_database_password}
# Database Configuration
DB_HOST={your_database_host}
DB_PORT={your_database_port}
DB_USERNAME={your_database_username}
DB_PASSWORD={your_database_password}
DB_NAME={your_database_name}
DB_SSLMODE={disable|require|verify-ca|verify-full}

# Migration Configuration
RUN_MIGRATION=false

# Local Server Configuration
PORT=8081
LOG_LEVEL=debug

# Server Configuration
PORT=8082
LOG_LEVEL=info
17 changes: 9 additions & 8 deletions exchange/policy-decision-point/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ ARG GIT_COMMIT
# Install build dependencies
RUN apk add --no-cache git ca-certificates tzdata

# Copy go mod files and source code
COPY exchange/policy-decision-point/go.mod exchange/policy-decision-point/go.sum ./
COPY exchange/policy-decision-point/ .

# Copy shared packages from exchange/shared
COPY exchange/shared/ /shared/
# Copy go mod files first for better layer caching
COPY exchange/policy-decision-point/go.mod exchange/policy-decision-point/go.sum ./exchange/policy-decision-point/
# Copy shared dependencies
COPY exchange/shared/utils/ ./exchange/shared/utils/

# Download dependencies
WORKDIR /app/exchange/policy-decision-point/
RUN go mod download

# Build the application with build info
# Copy source code (this layer will be invalidated only on code changes)
COPY exchange/policy-decision-point/ .

# Build the application with build info from policy-decision-point directory
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-w -s -X main.Version=${BUILD_VERSION} -X main.BuildTime=${BUILD_TIME} -X main.GitCommit=${GIT_COMMIT}" \
-o /app/service_binary .
Expand Down
66 changes: 47 additions & 19 deletions exchange/policy-decision-point/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The PDP provides attribute-based access control (ABAC) with field-level permissi

### Prerequisites

- Go 1.21+
- Go 1.24+
- PostgreSQL 13+

### Run the Service
Expand All @@ -31,6 +31,16 @@ The PDP provides attribute-based access control (ABAC) with field-level permissi
# Install dependencies
go mod download

# Copy environment template
cp .env.template .env

# Edit .env with your database configuration
# DB_HOST=localhost
# DB_PORT=5432
# DB_USERNAME=postgres
# DB_PASSWORD=password
# DB_NAME=pdp

# Run locally
go run main.go

Expand All @@ -45,21 +55,26 @@ The service runs on port 8082 by default.

### Environment Variables

All configuration is done via environment variables. See `.env.template` for a complete list.

| Variable | Description | Default |
|----------|-------------|---------|
| `PORT` | Service port | `8082` |
| `ENVIRONMENT` | `production` or `local` | `local` |
| `IDP_ORG_NAME` | IDP organization name | - |
| `IDP_ISSUER` | JWT issuer URL | - |
| `IDP_AUDIENCE` | JWT audience | - |
| `IDP_JWKS_URL` | JWKS endpoint URL | - |
| `DB_HOST` | Database host | `localhost` |
| `DB_PORT` | Database port | `5432` |
| `DB_USERNAME` | Database username | `postgres` |
| `DB_PASSWORD` | Database password | - |
| `DB_NAME` | Database name | `pdp` |
| `DB_SSLMODE` | SSL mode | `require` |

**Optional:**
```bash
# Database Configuration (Choreo)
CHOREO_DB_PDP_HOSTNAME=your-db-host
CHOREO_DB_PDP_PORT=your-db-port
CHOREO_DB_PDP_USERNAME=your-db-username
CHOREO_DB_PDP_PASSWORD=your-db-password
CHOREO_DB_PDP_DATABASENAME=your-db-name

# Or use standard DB variables
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=your_password
DB_NAME=pdp
DB_SSLMODE=disable
RUN_MIGRATION=false # Set to "true" to run migrations on startup
```

## API Endpoints
Expand All @@ -70,6 +85,8 @@ DB_SSLMODE=disable
| `/api/v1/policy/metadata` | POST | Create policy metadata for fields |
| `/api/v1/policy/update-allowlist` | POST | Update allow list for applications |
| `/health` | GET | Health check |
| `/debug` | GET | Debug information |
| `/debug/db` | GET | Database connection status |

### Authorization Request

Expand Down Expand Up @@ -118,7 +135,13 @@ DB_SSLMODE=disable
```json
{
"schema_id": "schema-123",
"sdl": "type Person { fullName: String }"
"records": [
{
"field_name": "person.fullName",
"display_name": "Full Name",
"access_control_type": "public"
}
]
}
```

Expand Down Expand Up @@ -176,9 +199,13 @@ go test ./... -cover
curl -X POST http://localhost:8082/api/v1/policy/decide \
-H "Content-Type: application/json" \
-d '{
"consumer_id": "passport-app",
"app_id": "passport-app",
"required_fields": ["person.fullName"]
"applicationId": "passport-app",
"requiredFields": [
{
"fieldName": "person.fullName",
"schemaId": "schema-123"
}
]
}'
```

Expand All @@ -188,6 +215,7 @@ curl -X POST http://localhost:8082/api/v1/policy/decide \

**`policy_metadata` Table:**
- `id` (UUID) - Primary key
- `schema_id` (TEXT) - Schema identifier
- `field_name` (TEXT) - Data field name
- `display_name` (TEXT) - Human-readable name
- `access_control_type` (ENUM) - public/restricted
Expand Down
9 changes: 2 additions & 7 deletions exchange/policy-decision-point/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ go 1.24.6
require (
github.com/google/uuid v1.6.0
github.com/gov-dx-sandbox/exchange/shared/utils v0.0.0
github.com/joho/godotenv v1.5.1
github.com/stretchr/testify v1.10.0
gorm.io/driver/postgres v1.6.0
gorm.io/driver/sqlite v1.6.0
gorm.io/gorm v1.31.0
)

replace github.com/gov-dx-sandbox/exchange/shared/utils => ../shared/utils

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
Expand All @@ -29,9 +30,3 @@ require (
golang.org/x/text v0.27.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/gov-dx-sandbox/exchange/shared/config => ./shared/config

replace github.com/gov-dx-sandbox/exchange/shared/constants => ./shared/constants

replace github.com/gov-dx-sandbox/exchange/shared/utils => ./shared/utils
2 changes: 0 additions & 2 deletions exchange/policy-decision-point/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand Down
Loading
Loading