Skip to content

Commit ede6298

Browse files
committed
added special public token
Fixes #5
1 parent 215c791 commit ede6298

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode/copilot-instructions.md

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Patchwork
22

3-
[![CI](https://github.com/tionis/patchwork/workflows/CI/badge.svg)](https://githPatchwork uses a Forgejo-integrated authentication system. Each user maintains a `config.yaml` file in their `.patchwork` repository to define access tokens, permissions, and notification settings.b.com/tionis/patchwork/actions/workflows/ci.yml)
3+
[![CI](https://github.com/tionis/patchwork/workflows/CI/badge.svg)](https://github.com/tionis/patchwork/actions/workflows/ci.yml)
44
[![Test](https://github.com/tionis/patchwork/workflows/Test/badge.svg)](https://github.com/tionis/patchwork/actions/workflows/test.yml)
55
[![codecov](https://codecov.io/gh/tionis/patchwork/branch/main/graph/badge.svg)](https://codecov.io/gh/tionis/patchwork)
66
[![Go Report Card](https://goreportcard.com/badge/github.com/tionis/patchwork)](https://goreportcard.com/report/github.com/tionis/patchwork)
@@ -655,6 +655,8 @@ The server is organized by namespaces with different access patterns:
655655
connections. Uses token-based authentication via `Authorization` header. Tokens are managed through
656656
the `huproxy` field in the user's `config.yaml` file in their `.patchwork` repository.
657657

658+
If a request is made to a user namespace without an `Authorization` header or `toke` query parameter, it is treated as a request with the token `public`. This allows for creating public endpoints within a user's namespace that can be accessed without authentication.
659+
658660
### ACL File Format
659661

660662
For user namespaces, access control is managed through YAML files stored in

TODO.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ The current manual testing approach of using separate curl commands in terminals
103103
- Consider adding debug endpoints to inspect channel states
104104
- Add metrics for request-responder success/failure rates
105105

106-
### 3. Authentication and Access Control
107-
- If a request comes in for the user namespace that does not have a token set, treat it as it had a token with the value "public". This should also be documented. This allows users to selectivly open their namespace to unauthenticated outsiders
106+
108107

109108
---
110109

assets/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ <h3>User Namespaces</h3>
231231
<code>.patchwork</code> repository in your account and add a <code>config.yaml</code>
232232
file to define tokens, permissions, notification settings, and HuProxy access.
233233
</p>
234+
<p>
235+
If a request is made to a user namespace without an <code>Authorization</code> header or <code>token</code> query parameter, it is treated as a request with the token <code>public</code>. This allows for creating public endpoints within a user's namespace that can be accessed without authentication.
236+
</p>
234237

235238
<h4>config.yaml Format</h4>
236239
<p>Create a <code>config.yaml</code> file in your <code>.patchwork</code> repository:</p>

internal/auth/auth.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ func AuthenticateToken(
2525
}
2626

2727
if token == "" {
28-
return false, "no token provided", nil
28+
// If no token is provided for a user namespace, treat it as a "public" token
29+
token = "public"
2930
}
3031

3132
// For HuProxy, pass the path as the operation to check against patterns

0 commit comments

Comments
 (0)