Skip to content

Feature: Public routes (auth_required=false) for unauthenticated access #34

@artpar

Description

@artpar

Problem

When using APIGate as a reverse proxy for Hoster, ALL requests require API key authentication. There's no way to configure a route as "public" to allow unauthenticated access.

Use Case

Hoster (deployment marketplace) needs:

  1. Public frontend (/*) - Marketplace browsing without login
  2. Authenticated API (/api/*) - Requires API key with header injection
  3. Authenticated apps (*.apps.domain) - Deployed apps

Currently, even the marketplace landing page requires an API key, which breaks the user experience.

Proposed Solution

Add auth_required field to routes (default: true for backward compatibility):

Database Migration

ALTER TABLE routes ADD COLUMN auth_required INTEGER NOT NULL DEFAULT 1;

Route Domain Model

type Route struct {
    // ... existing fields ...
    AuthRequired bool `json:"auth_required"` // Default: true
}

Proxy Handler Change

Move route matching BEFORE auth check:

  1. Match route first
  2. If route.AuthRequired == false: skip API key validation, forward request
  3. If route.AuthRequired == true: current flow (validate key, inject headers, etc.)

Admin API

Accept auth_required in route create/update:

{
  "name": "hoster-frontend",
  "path_pattern": "/*",
  "upstream_id": "xxx",
  "auth_required": false
}

CLI

apigate routes create --name frontend --path "/*" --upstream hoster --auth=false

Behavior When auth_required=false

  • No API key required
  • No rate limiting applied
  • No quota tracking
  • Anonymous usage still logged for analytics
  • Request/response transforms still work
  • Upstream auth injection still works

Related

This was previously discussed in issue #22 but implementation was not completed.

Environment

  • APIGate: latest
  • Hoster: using APIGate for auth/billing proxy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions