8000 Document the roster rule as the token rule it is by ynishi · Pull Request #20 · ynishi/evalhub · GitHub
[go: up one dir, main page]

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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ covers it.
| `DELETE` | `/tokens/{token_id}` | Revoke one of the caller's tokens, effective at once. |
| `GET` | `/namespaces/{ns}` | Kind, creation time, and counts of what the caller may see. |
| `POST` | `/orgs` | Create an organisation; the caller becomes its first `admin`. |
| `GET` | `/orgs/{org}/members` | The roster. Any member may read it. |
| `GET` | `/orgs/{org}/members` | The roster. Any role, with a token that names the organisation. |
| `POST` | `/orgs/{org}/members` | `{ user, role }`; `admin` on the organisation. |
| `DELETE` | `/orgs/{org}/members/{user}` | Remove a member; `admin` on the organisation. |
| `GET` | `/audit?ns&cursor&limit` | The namespace's append-only log, newest first; `admin` on the namespace. |
Expand Down
11 changes: 9 additions & 2 deletions crates/evalhub-server/src/api/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//! | `DELETE /tokens/{token_id}` | the owner of that token |
//! | `GET /namespaces/{ns}` | anyone; private records are not counted for them |
//! | `POST /orgs` | any token; the caller becomes its first `admin` |
//! | `GET /orgs/{org}/members` | a member of the org |
//! | `GET /orgs/{org}/members` | a token that names the org |
//! | `POST,DELETE /orgs/{org}/members` | `admin` on the org |
//!
//! A new token may name the caller's own login and any organisation where
Expand All @@ -20,6 +20,12 @@
//! the presenting token's namespace list, because the token that creates
//! an organisation does not cover it yet — while the scope ceiling keeps a
//! token from being a ladder: none can mint one that may do more than it.
//!
//! Reading a roster is a different question: like every other read, it
//! asks what the *presented token* covers, so a member whose token does
//! not name the organisation is answered `403`. That is why the token
//! that creates an organisation cannot read its members until a second
//! one names it.

use aide::axum::IntoApiResponse;
use axum::Json;
Expand Down Expand Up @@ -304,7 +310,8 @@ pub async fn list_members(
Auth(caller): Auth,
Path(org): Path<String>,
) -> Result<Json<Items<MemberDto>>, ApiError> {
// Membership of any level is enough to see the roster.
// Any role is enough to see the roster, but this is a read like any
// other: the presented token has to name the organisation.
if !caller.allows(&org, Scope::Read) {
return Err(ApiError::Forbidden);
}
Expand Down
4 changes: 3 additions & 1 deletion crates/evalhub-server/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ pub fn router(
get_with(auth::list_members, |op| {
op.id("list_members")
.summary("Members of an organisation")
.description("Any member may read the roster.")
.description(
"Any role is enough; the presented token must name the organisation.",
)
})
.post_with(auth::add_member, |op| {
op.id("add_member")
Expand Down
2 changes: 1 addition & 1 deletion crates/evalhub-server/tests/snapshots/boot__openapi.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4567,7 +4567,7 @@ expression: body
},
"/api/v1/orgs/{org}/members": {
"get": {
"description": "Any member may read the roster.",
"description": "Any role is enough; the presented token must name the organisation.",
"operationId": "list_members",
"responses": {
"200": {
Expand Down
17 changes: 17 additions & 0 deletions docs/hosting.md