update docs
This commit is contained in:
parent
7960814233
commit
4ad1106166
2
.github/workflows/hugo.yml
vendored
2
.github/workflows/hugo.yml
vendored
@ -30,7 +30,7 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
HUGO_VERSION: 0.108.0
|
||||
HUGO_VERSION: 0.110.0
|
||||
steps:
|
||||
- name: Install Hugo CLI
|
||||
run: |
|
||||
|
@ -76,3 +76,18 @@ Views / Models can be grouped in the Navbar by using the following functions ins
|
||||
admin_builder.add_entity::<AppState, Comment>(&comment_view_model);
|
||||
admin_builder.add_entity_to_category::<AppState, Comment>(&comment_view_model, "Group 1");
|
||||
```
|
||||
|
||||
## Additional Model Attributes
|
||||
|
||||
More attributes can be added to the model struct properties:
|
||||
| | | |
|
||||
|----|----|----|
|
||||
| primary_key | required | defines which column is used for the primary key of the model |
|
||||
| html_input_type=<String> | optional | add the defined value such as *email* as input type to the html input field
|
||||
| select_list | optional | Where a dropdown is rendered for the specific entity, needs to match the name of a struct or an enum |
|
||||
| searchable | optional | Adds a search field to the table allowing to search the specific column |
|
||||
| textarea | optional | renders a textarea instead of a text input field
|
||||
| file_upload | optional | renders a file upload field, storing the filename in the column, column must be a string |
|
||||
| not_empty | optional | disallow empty strings such as "" |
|
||||
| list_sort_position=<usize> | optional | orders the column in the list view by ascending position |
|
||||
| list_hide_column<bool> | optional | hides the column in the list view |
|
30
docs/content/docs/authentication.md
Normal file
30
docs/content/docs/authentication.md
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
title: "Authentication & Authorization"
|
||||
date: 2023-01-17T11:44:56+01:00
|
||||
draft: false
|
||||
weight: 4
|
||||
---
|
||||
|
||||
# Authentication & Authorization
|
||||
|
||||
The admin interface can optionally enable authentication and authorization, altough the authorization logic needs to happen outside of the admin interface.
|
||||
|
||||
An example for authenticating against Azure Active Directory can be found in the [examples](https://github.com/mgugger/actix-admin/tree/main/examples).
|
||||
|
||||
## Enabling Authentication
|
||||
|
||||
When creating the configuration, auth can be enabled as in the following code:
|
||||
|
||||
```rust
|
||||
let configuration = ActixAdminConfiguration {
|
||||
enable_auth: true,
|
||||
user_is_logged_in: Some(|session: &Session| -> bool {
|
||||
let user_info = session.get::<UserInfo>("user_info").unwrap();
|
||||
user_info.is_some()
|
||||
}),
|
||||
login_link: Some("/azure-auth/login".to_string()),
|
||||
logout_link: Some("/azure-auth/logout".to_string()),
|
||||
};
|
||||
```
|
||||
|
||||
The configuration expects a function taking a session parameter to return a bool whether the user is logged or not. Additionally, the login or logout links should be provided to redirect the user to the login url of choice.
|
@ -114,9 +114,9 @@ fn create_actix_admin_builder() -> ActixAdminBuilder {
|
||||
};
|
||||
|
||||
let mut admin_builder = ActixAdminBuilder::new(configuration);
|
||||
// admin_builder.add_custom_handler_for_index::<AppState>(
|
||||
// web::get().to(custom_index::<AppState>)
|
||||
// );
|
||||
admin_builder.add_custom_handler_for_index::<AppState>(
|
||||
web::get().to(custom_index::<AppState>)
|
||||
);
|
||||
admin_builder.add_entity::<AppState, Post>(&post_view_model);
|
||||
admin_builder.add_custom_handler("Custom Route in Menu", "/custom_route_in_menu", web::get().to(custom_index::<AppState>), true);
|
||||
admin_builder.add_custom_handler("Custom Route not in Menu", "/custom_route_not_in_menu", web::get().to(custom_index::<AppState>), false);
|
||||
|
@ -23,9 +23,6 @@ impl ActixAdminAppDataTrait for AppState {
|
||||
}
|
||||
|
||||
fn create_actix_admin_builder() -> ActixAdminBuilder {
|
||||
let post_view_model = ActixAdminViewModel::from(Post);
|
||||
let comment_view_model = ActixAdminViewModel::from(Comment);
|
||||
|
||||
let configuration = ActixAdminConfiguration {
|
||||
enable_auth: false,
|
||||
user_is_logged_in: None,
|
||||
@ -36,8 +33,12 @@ fn create_actix_admin_builder() -> ActixAdminBuilder {
|
||||
|
||||
let mut admin_builder = ActixAdminBuilder::new(configuration);
|
||||
|
||||
let some_category = "Groupings";
|
||||
|
||||
let post_view_model = ActixAdminViewModel::from(Post);
|
||||
admin_builder.add_entity::<AppState, Post>(&post_view_model);
|
||||
|
||||
let some_category = "Groupings";
|
||||
let comment_view_model = ActixAdminViewModel::from(Comment);
|
||||
admin_builder.add_entity_to_category::<AppState, Comment>(&comment_view_model, some_category);
|
||||
|
||||
admin_builder
|
||||
|
Loading…
Reference in New Issue
Block a user