srctree

Gregory Mullen parent e9aba6a1 7564fe07
push through frame auth provider

src/frame.zig added: 8, removed: 8, total 0
@@ -8,7 +8,7 @@ downstream: union(Downstream) {
uri: Router.UriIterator,
 
// TODO fix this unstable API
auth: Auth.Provider,
auth_provider: Auth.Provider,
/// user is set to exactly what is provided directly by the active Auth.Provider.
/// It's possible for an Auth.Provider to return a User that is invalid.
/// Depending on the need for any given use, users should always verify the
@@ -70,7 +70,7 @@ pub const RouteData = struct {
}
};
 
pub fn init(a: Allocator, req: *const Request) !Frame {
pub fn init(a: Allocator, req: *const Request, auth: Auth.Provider) !Frame {
return .{
.alloc = a,
.request = req,
@@ -79,7 +79,7 @@ pub fn init(a: Allocator, req: *const Request) !Frame {
.http => .{ .http = req.raw.http.server.connection.stream },
},
.uri = try splitUri(req.uri),
.auth = Auth.InvalidAuth.provider(),
.auth_provider = auth,
.headers = Headers.init(a),
.cookie_jar = try Cookies.Jar.init(a),
.route_data = .{ .items = std.ArrayList(RouteData.Pair).init(a) },
 
src/http.zig added: 8, removed: 8, total 0
@@ -54,7 +54,7 @@ pub fn once(http: *HTTP, srv: *net.Server) !void {
const reqdata = try requestData(a, &hreq);
const req = try Request.initHttp(a, &hreq, reqdata);
 
var frame = try Frame.init(a, &req);
var frame = try Frame.init(a, &req, http.auth);
 
const callable = http.router.routerfn(&frame, http.router.routefn);
http.router.builderfn(&frame, callable);
 
src/zwsgi.zig added: 8, removed: 8, total 0
@@ -83,7 +83,7 @@ pub fn serve(z: *zWSGI) !void {
var zreq = try zWSGIRequest.init(a, &acpt);
const request_data = try requestData(a, &zreq);
const request = try Request.initZWSGI(a, &zreq, request_data);
var frame = try Frame.init(a, &request);
var frame = try Frame.init(a, &request, z.auth);
 
defer {
const vars = frame.request.raw.zwsgi.vars;