Skip to content

0.14.0

Choose a tag to compare

@zaiev zaiev released this 27 Oct 15:58
· 24 commits to main since this release

Access control with Spindle.Access, a route's own limits and policies under the app's names, and a time limit on handlers.

Upgrading

  • ~meta:Meta.(empty |> add Meta.access Logs.Debug) → ~access_log:Logs.Debug: Spindle.Meta is gone, and a route's settings are labels.
  • ~meta:Meta.(empty |> add Compress.never ()) → ~compress:Compress.none.
  • Meta.find Meta.summary info.meta → info.summary, and doc, tags and access_log alike.
  • A key of your own read by middleware → a dependency of the route, as Spindle.add_header for a header one route needs.
  • App.answered's access → access_log.
  • ~cors:(Cors.origins ~routes:api_only [ site ]) on the application → ~cors:(Cors.origins [ site ]) on each API route, through a shared maker: let api_get = Spindle.get ~cors:site.
  • Spindle.body_stream ~max:n () → Spindle.body_stream () on a route with ~limits:(Route.Limits.make ~max_body:n ()), and Spindle.multipart alike.
  • A handler that runs longer than a minute → its own ~limits:(Route.Limits.make ~handler_timeout:...), or it is answered 503 timed_out.
  • A server whose max_body is above its body_budget → a max_body the budget can hold, or a stream: a body read whole there is 500, since none between the two could ever be held.
  • A connection loop of your own: Body.source's whole and part take the route's limits as optional arguments, part losing ~max.
  • A test that sends a body read whole past max_body is now 413, as on a server.

New

  • Spindle.Access: a policy is a function of the caller, an action and the object; Access.can action resource hands a route the object only once its policy allows the action, answering someone else's as a missing one.
  • Access.require and Access.check refuse 403 forbidden; every denial is one warn line naming the policy, the action, the caller's id and the reason; Access.decide answers what a policy decides, for a test.
  • Route.info lists who may call a route, the OpenAPI document prints it as x-spindle-access, and Access.unguarded routes names the routes that read no check.
  • Dep.attempt d hands over d's refusal as a value, so an MCP tool's dependency may refuse and its refusal is the tool's isError.
  • handler_timeout, 60 s unless given in Server.Limits.make or a route's Route.Limits.make: past it the handler is cancelled with everything it started and answered 503 timed_out; time spent waiting on its body is not counted.
  • A route's ~limits give its own max_body, body_timeout, min_body_rate and handler_timeout in place of the server's, by the same names.
  • A route's ~compress and ~cors are its policies in place of the application's: one route can compress, or allow a site, under an application that does not. Compress.none and Cors.none turn either off.
  • Spindle.Test.app ~limits reads every body as the server does.
  • App.handle ?within is how a connection loop of its own bounds a handler's time.

Fixed

  • A route under Compress.none no longer says Vary: Accept-Encoding, since its answers do not vary by it.
  • A preflight is answered under the policy of the route that answers the method it asks for, so two routes at one path may allow different sites.