1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! The condition an application may put on who sees the developer tools.
use Pin;
use Arc;
use Request;
/// Who may see the developer tools, beyond what [`DevtoolsServiceProvider`] already checks, or
/// instead of it.
///
/// The provider asks the gate in the `web` middleware group, after the session has started: a gate
/// may ask who is logged in. A gate that says no, or fails, hides the toolbar and answers the
/// developer tools' own pages with `404`. How the provider sets it decides whom it asks:
///
/// - Set with [`with_gate`], it narrows: it is asked only for those the provider lets in, on the
/// application's machine or with the key. The CSRF check may answer before it with `419`, and the
/// router, for a method a route doesn't have, with `405`, or `200` for `OPTIONS`, and `Allow`: it
/// hides what the developer tools hold, not that they are there.
/// - Set with [`with_admitting_gate`], it also lets in on its own: it is asked for everyone else,
/// such as a browser behind a proxy without the key. Whom it turns away gets what the application
/// answers a path that doesn't exist, as long as its fallback answers with `404` as
/// `laravel::abort(404)` does.
///
/// ```
/// use laravel::http::Request;
/// use laravel_rust_devtools::{DevtoolsGate, DevtoolsServiceProvider};
///
/// /// Only those logged in.
/// struct LoggedIn;
///
/// impl DevtoolsGate for LoggedIn {
/// async fn allows(&self, request: &Request) -> laravel::Result<bool> {
/// request.authenticated().await
/// }
/// }
///
/// laravel::Application::configure().with_providers(|providers| {
/// providers.add(DevtoolsServiceProvider::new().with_gate(LoggedIn));
/// });
/// ```
///
/// [`DevtoolsServiceProvider`]: crate::DevtoolsServiceProvider
/// [`with_gate`]: crate::DevtoolsServiceProvider::with_gate
/// [`with_admitting_gate`]: crate::DevtoolsServiceProvider::with_admitting_gate
/// A [`DevtoolsGate`] behind a pointer, whatever its type.
pub
/// The gate as the application set it, with whom the provider asks it.
pub