{
    admin off
    atproto {
        storage_path ./e2e.db
        cookie_secret "testing-secret-must-be-at-least-32-bytes-long"
    }
}

# --- Scenario 1: Standalone App (Composed) ---
# Acts as its own portal using composition.
http://localhost:8081 {
    route {
        atproto_portal {
            domain localhost:8081
            name "Standalone App 1"
        }
        atproto_gate {
            # Portal is local
            portal_url /
            # Enable refresh by providing client_id
            client_id https://localhost:8081/.well-known/oauth-client-metadata.json
            allow @vvill.dev
        }

        # Protected content
        respond "Welcome to Standalone App! You are authenticated."
    }
}

# --- Scenario 2: Centralized Auth Hub ---

# The Portal (Identity Provider)
http://localhost:8082 {
    route {
        atproto_portal {
            domain localhost:8082
            name "Local E2E Hub"
        }
    }
}

# The Service (Relying Party)
# Redirects users to port 8082 for login
http://localhost:8083 {
    route {
        atproto_gate {
            # Auth Hub mode (no 'domain' set)
            portal_url http://localhost:8082
            allow @vvill.dev
        }

        respond "Welcome to Service App! You authenticated via the Hub."
    }
}

# --- Scenario 3: Standalone app with Custom Paths ---

# Standalone app serves The Portal, gates access, then the App
http://localhost:8084 {
    route {
        # First, auth portal
        atproto_portal {
            domain localhost:8084
            name "Standalone App 3"
            path_prefix /atproto
        }
        # Then, make sure user is authenticated
        atproto_gate {
            # Portal is local but at custom path.
            # Gate appends /login to portal_url.
            # So we set portal_url to /atproto
            portal_url /atproto
            client_id https://localhost:8084/.well-known/oauth-client-metadata.json
            allow @vvill.dev
        }
        # Then, they have access to the App
        respond "Welcome to Standalone App 3! Custom paths working."
    }
}
