pub struct AdminPlugin { /* private fields */ }Expand description
The admin panel plugin.
Register models via .register() and the plugin will mount a full admin
UI under the configured prefix (default: /admin).
Implementations§
Source§impl AdminPlugin
impl AdminPlugin
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new admin plugin with default settings.
Mounts at /admin and requires the "admin" role in the session.
Links to the actuator UI under /actuator. Reads the user
identifier from session key "user_id" (Autumn’s default
auth.session_key).
Sourcepub fn prefix(self, prefix: impl Into<String>) -> Self
pub fn prefix(self, prefix: impl Into<String>) -> Self
Override the URL prefix (default: /admin).
Sourcepub fn actuator_prefix(self, prefix: impl Into<String>) -> Self
pub fn actuator_prefix(self, prefix: impl Into<String>) -> Self
Override the actuator mount prefix that dashboard links/polling target
(default: /actuator). Must match config.actuator.prefix from your
autumn config — the plugin cannot read it automatically because config
is loaded after Plugin::build runs.
Sourcepub fn auth_session_key(self, key: impl Into<String>) -> Self
pub fn auth_session_key(self, key: impl Into<String>) -> Self
Override the session key the role middleware reads to detect an
authenticated user. Default: "user_id", matching Autumn’s default
auth.session_key. Must match whatever your application populates
after login — e.g. set this to "uid" if you configured
auth.session_key = "uid".
The plugin can’t read config.auth.session_key automatically
because config is loaded after Plugin::build runs.
Sourcepub fn require_role(self, role: impl Into<Option<String>>) -> Self
pub fn require_role(self, role: impl Into<Option<String>>) -> Self
Set the required session role for accessing the admin panel.
Pass None to disable role checks entirely. Authentication
(a populated user_id session key) is always required when a role
is set.
Sourcepub fn register<M: AdminModel>(self, model: M) -> Self
pub fn register<M: AdminModel>(self, model: M) -> Self
Register a model for admin management.
The model must implement AdminModel, which provides field metadata,
CRUD operations, and display configuration.
Sourcepub fn with_runtime_config(self, svc: Arc<RuntimeConfigService>) -> Self
pub fn with_runtime_config(self, svc: Arc<RuntimeConfigService>) -> Self
Enable the runtime config management page.
Mounts GET /config, POST /config/{key}/set, POST /config/{key}/unset,
and GET /config/{key}/history under the admin prefix, and adds a
“Runtime Config” item to the sidebar navigation.
Sourcepub const fn with_step_up_mutations(self) -> Self
pub const fn with_step_up_mutations(self) -> Self
Require step-up (fresh) authentication before any mutating admin action.
When enabled, every POST (create/update) and DELETE (destroy) request
to the admin panel is checked against the session’s last_strong_auth_at
claim using the global step-up max-age configured in [auth.step_up]
(default: 5 minutes). Requests without a valid fresh-auth claim are
redirected to /reauth?return_to=… (HTML clients) or receive a
401 step_up_required problem-details response (JSON clients).
Highly recommended for production admin panels to reduce the blast radius of a hijacked admin session.
§Example
AdminPlugin::new()
.register(UserAdmin::default())
.with_step_up_mutations()Sourcepub const fn with_step_up_max_age(self, secs: u64) -> Self
pub const fn with_step_up_max_age(self, secs: u64) -> Self
Override the step-up freshness window for admin mutations.
Only meaningful when with_step_up_mutations
is also called. Calls with_step_up_mutations implicitly.
§Example
AdminPlugin::new()
.register(UserAdmin::default())
.with_step_up_max_age(600) // 10-minute windowTrait Implementations§
Source§impl Default for AdminPlugin
impl Default for AdminPlugin
Auto Trait Implementations§
impl !RefUnwindSafe for AdminPlugin
impl !UnwindSafe for AdminPlugin
impl Freeze for AdminPlugin
impl Send for AdminPlugin
impl Sync for AdminPlugin
impl Unpin for AdminPlugin
impl UnsafeUnpin for AdminPlugin
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read moreSource§impl<P> Plugins for Pwhere
P: Plugin,
impl<P> Plugins for Pwhere
P: Plugin,
Source§fn apply(self, app: AppBuilder) -> AppBuilder
fn apply(self, app: AppBuilder) -> AppBuilder
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> RepositoryHooksDefault for Twhere
T: Default,
impl<T> RepositoryHooksDefault for Twhere
T: Default,
Source§fn autumn_default() -> T
fn autumn_default() -> T
Source§impl<T, Conn> RunQueryDsl<Conn> for T
impl<T, Conn> RunQueryDsl<Conn> for T
Source§fn execute<'conn, 'query>(
self,
conn: &'conn mut Conn,
) -> <Conn as AsyncConnectionCore>::ExecuteFuture<'conn, 'query>
fn execute<'conn, 'query>( self, conn: &'conn mut Conn, ) -> <Conn as AsyncConnectionCore>::ExecuteFuture<'conn, 'query>
Source§fn load<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
fn load<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
Source§fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnectionCore,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnectionCore,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
Stream] with the returned rows. Read moreSource§fn get_result<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, LoadNext<Pin<Box<Self::Stream<'conn>>>>>
fn get_result<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, LoadNext<Pin<Box<Self::Stream<'conn>>>>>
Source§fn get_results<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
fn get_results<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
Vec with the affected rows. Read moreSource§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.