You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/3.0/authorization.md
+100-1
Original file line number
Diff line number
Diff line change
@@ -116,7 +116,7 @@ Controls whether the user can see the [records reordering](./records-reordering)
116
116
117
117
<Optionname="`search?`">
118
118
119
-
Controls whether the user can see the global search input or the [resource search input](./search) on top of the <Index /> page.
119
+
Controls whether the user can see the [resource search input](./search) on top of the <Index /> page.
120
120
</Option>
121
121
122
122
## Associations
@@ -541,6 +541,105 @@ end
541
541
```
542
542
</Option>
543
543
544
+
## Explicit authorization
545
+
546
+
<Optionname="`explicit_authorization`">
547
+
548
+
:::warning Option Renamed
549
+
In versions between <Versionversion="3.13.4" /> and <Versionversion="3.13.6" />, this option is named `implicit_authorization`.
550
+
:::
551
+
552
+
<VersionReqversion="3.13.4" />
553
+
554
+
This option gives you control over how missing policy classes or methods are handled during authorization checks in your Avo application.
555
+
556
+
### Possible values
557
+
558
+
**`true`**
559
+
- If a policy class or method is **missing** for a given resource or action, that action will automatically be considered **unauthorized**.
560
+
- This behavior enhances security by ensuring that any unconfigured or unhandled actions are denied by default.
561
+
562
+
**`false`**
563
+
- If a policy class or method is **missing**, the action will be considered **authorized** by default.
564
+
565
+
**`Proc`**
566
+
- You can also set `explicit_authorization` as a `Proc` to apply custom logic. Within this block, you gain access to all attributes of [`Avo::ExecutionContext`](execution-context)
In this case, missing policies will be handled based on the condition:if the user has access to the admin panel but isn't an admin, the `explicit_authorization` will be enabled. This option allows you to customize authorization decisions based on the context of the current user or other factors.
577
+
### Default
578
+
579
+
- For **new applications** (starting from Avo `3.13.4`) the default value for `explicit_authorization` is `true`. This provides a more secure out-of-the-box experience by ensuring actions without explicit authorization are denied.
580
+
581
+
- For **existing applications** upgrading to `3.13.4` or later the default value for `explicit_authorization` remains `false` to preserve backward compatibility. Existing applications will retain the permissive behavior unless explicitly changed.
582
+
583
+
### Configuration:
584
+
585
+
You can configure this setting in your `config/avo.rb` file:
586
+
587
+
```ruby{4}
588
+
Avo.configure do |config|
589
+
# Set to true to deny access when policies or methods are missing
590
+
# Set to false to allow access when policies or methods are missing
591
+
config.explicit_authorization = true
592
+
end
593
+
```
594
+
595
+
### Examples:
596
+
597
+
1. **When `explicit_authorization` is `true`**
598
+
- **Scenario**: You have a `Post` resource, but there is no policy class defined for it.
599
+
- **Result**: All actions for the `Post` resource (index, show, create, etc.) will be **unauthorized** unless you explicitly define a policy class and methods for those actions.
600
+
601
+
---
602
+
- **Scenario**: You have a `Post` resource, and the policy class defined for it only defines the `show?` method.
603
+
604
+
```ruby
605
+
class PostPolicy < ApplicationPolicy
606
+
def show?
607
+
user.admin?
608
+
end
609
+
end
610
+
```
611
+
- **Result**: In this case, since the `PostPolicy` lacks an `index?` method, attempting to access the `index` action will be denied by default.
612
+
613
+
2. **When `explicit_authorization: false`**
614
+
- **Scenario**: Same `Post` resource without a policy class.
615
+
- **Result**: All actions for the `Post` resource will be **authorized** even though there are no explicit policy methods. This could expose unintended behavior, as any unprotected action will be accessible.
616
+
617
+
---
618
+
619
+
- **Scenario**: You have a `Post` resource, and the policy class defined for it only defines the `show?` method.
620
+
```ruby
621
+
class PostPolicy < ApplicationPolicy
622
+
def show?
623
+
user.admin?
624
+
end
625
+
end
626
+
```
627
+
- **Result**: In this case, missing methods like `index?` will allow access to the `index` action by default.
628
+
629
+
630
+
### Migration Recommendations:
631
+
632
+
- **For applications after from Avo `3.13.4`**
633
+
634
+
It is recommended to leave `explicit_authorization` set to `true`, ensuring all actions must be explicitly authorized to prevent unintentional access.
635
+
636
+
- **For applications before from Avo `3.13.4`**
637
+
638
+
- If upgrading from an earlier version, carefully review your policies before enabling `explicit_authorization`. Missing policy methods that were previously allowing access will now deny access unless explicitly defined.
639
+
640
+
- It’s recommended to disable [`raise_error_on_missing_policy`](authorization.html#raise-errors-when-policies-are-missing) in production, though it's not mandatory. When`explicit_authorization` is set to `true`, the default behavior is to deny access for actions without a defined policy. In this case, it’s often better to show an unauthorized message to users rather than raise an error. However, keeping [`raise_error_on_missing_policy`](authorization.html#raise-errors-when-policies-are-missing) enabled in development can be helpful for identifying missing policy classes.
641
+
</Option>
642
+
544
643
## Rolify integration
545
644
546
645
Check out [this guide](guides/rolify-integration.md) to add rolify role management with Avo.
<VersionReqversion="3.13" /> `prefix` and `suffix` became callable options.
205
+
206
+
The blocks are executed using [`Avo::ExecutionContext`](execution-context). Within this blocks, you gain access to all attributes of [`Avo::ExecutionContext`](execution-context) along with the `parent`.
207
+
208
+
```ruby{3,4}
209
+
class Avo::Cards::UsersMetric < Avo::Cards::MetricCard
A picture is worth a thousand words. So maybe a chart a hundred? Who knows? But creating charts in Avo is very easy with the help of the [chartkick](https://github.com/ankane/chartkick) gem.
By default, the resource controls are located on the right side of the record rows, which might be hidden if there are a lot of columns. You might want to move the controls to the left side in that situation using the `resource_controls_placement` option.
@@ -84,9 +84,18 @@ Avo.configure do |config|
84
84
end
85
85
```
86
86
87
-
88
87
<Imagesrc="/assets/img/customization/resource-controls-left.jpg"width="1206"height="920"alt="Resource controls on the left side" />
89
88
89
+
<VersionReqversion="3.13.7"class="mt-2" />
90
+
91
+
You might want to render the controls on both sides
92
+
93
+
```ruby{2}
94
+
Avo.configure do |config|
95
+
config.resource_controls_placement = :both
96
+
end
97
+
```
98
+
90
99
## Container width
91
100
92
101
```ruby{2-3}
@@ -397,6 +406,15 @@ Avo.configure do |config|
397
406
end
398
407
```
399
408
409
+
<VersionReqversion="3.13.5" /> `disabled_features` become callable. Within this block, you gain access to all attributes of [`Avo::ExecutionContext`](execution-context)
Copy file name to clipboardexpand all lines: docs/3.0/dynamic-filters.md
+82
Original file line number
Diff line number
Diff line change
@@ -591,6 +591,88 @@ dynamic_filter :tags,
591
591
592
592
</Option>
593
593
594
+
<Optionname="`fetch_values_from`">
595
+
596
+
<VersionReqversion="3.13" />
597
+
598
+
:::warning
599
+
This option is compatible **only** with `tags` filters.
600
+
:::
601
+
602
+
In some cases, you may need to retrieve values dynamically from an API. The `fetch_values_from` option allows you to provide a URL from which the filter will suggest values, functioning similarly to the `fetch_values_from` option in the tags field.
603
+
604
+
When a user searches for a record, the filter's input will send a request to the server to fetch records that match the query.
605
+
606
+
##### Default value
607
+
608
+
`nil`
609
+
610
+
:::info
611
+
If you're using a `filterable` field the `fetch_values_from` are fetched from the field.
Copy file name to clipboardexpand all lines: docs/3.0/fields/tags.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -242,7 +242,7 @@ When the user searches for a record, the field will perform a request to the ser
242
242
243
243
#### Possible values
244
244
245
-
Valid values are `nil`, a string, or a block that evaluates to a string. The string should resolve to an enddpoint that returns an array of objects with the keys `value` and `label`.
245
+
Valid values are `nil`, a string, or a block that evaluates to a string. The string should resolve to an endpoint that returns an array of objects with the keys `value` and `label`.
Copy file name to clipboardexpand all lines: docs/3.0/fields/trix.md
+15-2
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,6 @@ field :body, as: :trix
12
12
13
13
The `Trix` field renders a [WYSIWYG Editor](https://trix-editor.org/) and can be associated with a `string` or `text` column in the database. The value stored in the database will be the editor's resulting `HTML` content.
`nil`, or a symbol representing the `has_many_attachments` key on the model.
62
61
</Option>
63
62
64
-
65
63
## File attachments
66
64
67
65
<!-- @include: ./../common/files_gem_common.md-->
@@ -105,3 +103,18 @@ Trix integrates seamlessly with Action Text. It will automatically work with Act
105
103
## Demo app
106
104
107
105
We prepared a [demo](https://trix.avodemo.com/) to showcase Trix's abilities to work with Action Text and Active Storage.
106
+
107
+
## Javascript Alert Messages
108
+
109
+
<VersionReqversion="3.13.8" />
110
+
111
+
You can customize the javascript alert messages for various actions in the Trix editor. Below are the default messages that can be translated or modified:
112
+
113
+
```yml
114
+
avo:
115
+
this_field_has_attachments_disabled: This field has attachments disabled.
116
+
you_cant_upload_new_resource: You can't upload files into the Trix editor until you save the resource.
117
+
you_havent_set_attachment_key: You haven't set an `attachment_key` to this Trix field.
118
+
```
119
+
120
+
Refer to the [default](https://github.com/avo-hq/avo/blob/main/lib/generators/avo/templates/locales/avo.en.yml) for more details.
0 commit comments