Skip to content

Commit

Permalink
Merge pull request #337 from esune/feat/add-debugger
Browse files Browse the repository at this point in the history
Add debugger functionality to vc-authn controller container
  • Loading branch information
esune authored Sep 18, 2023
2 parents 136314c + 6dac23e commit 243f8de
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 21 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,29 @@ curl -X 'POST' \
- Lastly, obtain a valid BCGov Verified Email credential from the [BCGov Email Verification Service](https://email-verification.vonx.io)

After all these steps have been completed, you should be able to authenticate with the demo application using the "Verified Credential Access" option.

## Debugging

To connect a debugger to the `vc-authn` controller service, start the project using `DEBUGGER=true ./manage start` and then launch the debugger, it should connect automatically to the container.

This is a sample debugger launch configuration for VSCode that can be used by adding it to `launch.json`:
```json
{
"version": "0.1.0",
"configurations": [
{
"name": "Python: Debug VC-AuthN Controller",
"type": "python",
"request": "attach",
"port": 5678,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}/oidc-controller",
"remoteRoot": "/app"
}
]
}
]
}
```
18 changes: 12 additions & 6 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ version: "3"
services:
controller:
image: vc-authn-oidc-controller

entrypoint: /bin/bash
command:
[
"-c",
"uvicorn api.main:app --reload --host 0.0.0.0 --port 5000 --log-level info",
]
command: >
-c "
if [ $DEBUGGER ] && [ "$DEBUGGER" == "true" ]; then
echo 'Starting in debug mode...'
pip install debugpy -t /tmp && \
python /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 -m uvicorn api.main:app --reload --host 0.0.0.0 --port 5000;
else
echo 'Starting in production mode...'
uvicorn api.main:app --reload --host 0.0.0.0 --port 5000;
fi"
environment:
- DEBUGGER=${DEBUGGER}
- DB_HOST=${MONGODB_HOST}
- DB_PORT=${MONGODB_PORT}
- DB_NAME=${MONGODB_NAME}
Expand All @@ -28,6 +33,7 @@ services:
- USE_OOB_PRESENT_PROOF=${USE_OOB_PRESENT_PROOF}
ports:
- ${CONTROLLER_SERVICE_PORT}:5000
- 5678:5678
volumes:
- ../oidc-controller:/app:rw
networks:
Expand Down
8 changes: 3 additions & 5 deletions oidc-controller/api/core/config.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import json
import logging
import sys
import logging.config
import structlog
import os
import sys
from enum import Enum
from functools import lru_cache
from pathlib import Path
from typing import Optional, Union

import structlog
from pydantic import BaseSettings

from pathlib import Path


# Use environment variable to determine logging format
# fallback to logconf.json
# finally default to true
Expand Down
16 changes: 6 additions & 10 deletions oidc-controller/api/main.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
# import api.core.logconfig
import logging
import logging.config
import structlog
import os
import time
import uuid
from pathlib import Path

import structlog
import uvicorn
from api.core.config import settings
from api.core.oidc.provider import init_provider
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from starlette.requests import Request
from starlette.responses import Response
from fastapi.responses import HTMLResponse
from fastapi.middleware.cors import CORSMiddleware

from .routers import acapy_handler, oidc, presentation_request, well_known_oid_config
from .verificationConfigs.router import router as ver_configs_router
from .clientConfigurations.router import router as client_config_router
from .db.session import init_db, get_db
from .db.session import get_db, init_db
from .routers import acapy_handler, oidc, presentation_request, well_known_oid_config
from .routers.socketio import sio_app

from api.core.oidc.provider import init_provider
from .verificationConfigs.router import router as ver_configs_router

logger: structlog.typing.FilteringBoundLogger = structlog.getLogger(__name__)

Expand Down

0 comments on commit 243f8de

Please sign in to comment.