Skip to content

Commit 225d4b0

Browse files
authored
refactor: rename implicit_authorization to explicit_authorization (#300)
1 parent e194a08 commit 225d4b0

File tree

2 files changed

+34
-16
lines changed

2 files changed

+34
-16
lines changed

docs/3.0/authorization.md

+18-13
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,13 @@ end
541541
```
542542
</Option>
543543

544-
## Implicit authorization
545-
<Option name="`implicit_authorization`">
544+
## Explicit authorization
545+
546+
<Option name="`explicit_authorization`">
547+
548+
:::warning Option Renamed
549+
In versions between <Version version="3.13.4" /> and <Version version="3.13.6" />, this option is named `implicit_authorization`.
550+
:::
546551

547552
<VersionReq version="3.13.4" />
548553

@@ -558,22 +563,22 @@ end
558563
- If a policy class or method is **missing**, the action will be considered **authorized** by default.
559564

560565
**`Proc`**
561-
- You can also set `implicit_authorization` as a `Proc` to apply custom logic. Within this block, you gain access to all attributes of [`Avo::ExecutionContext`](execution-context)
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)
562567

563568
For example:
564569

565570
```ruby
566-
config.implicit_authorization = -> {
571+
config.explicit_authorization = -> {
567572
current_user.access_to_admin_panel? && !current_user.admin?
568573
}
569574
```
570575

571-
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 `implicit_authorization` will be enabled. This option allows you to customize authorization decisions based on the context of the current user or other factors.
576+
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.
572577
### Default
573578
574-
- For **new applications** (starting from Avo `3.13.4`) the default value for `implicit_authorization` is `true`. This provides a more secure out-of-the-box experience by ensuring actions without explicit authorization are denied.
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.
575580
576-
- For **existing applications** upgrading to `3.13.4` or later the default value for `implicit_authorization` remains `false` to preserve backward compatibility. Existing applications will retain the permissive behavior unless explicitly changed.
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.
577582
578583
### Configuration:
579584
@@ -583,13 +588,13 @@ You can configure this setting in your `config/avo.rb` file:
583588
Avo.configure do |config|
584589
# Set to true to deny access when policies or methods are missing
585590
# Set to false to allow access when policies or methods are missing
586-
config.implicit_authorization = true
591+
config.explicit_authorization = true
587592
end
588593
```
589594
590595
### Examples:
591596
592-
1. **When `implicit_authorization` is `true`**
597+
1. **When `explicit_authorization` is `true`**
593598
- **Scenario**: You have a `Post` resource, but there is no policy class defined for it.
594599
- **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.
595600
@@ -605,7 +610,7 @@ end
605610
```
606611
- **Result**: In this case, since the `PostPolicy` lacks an `index?` method, attempting to access the `index` action will be denied by default.
607612
608-
2. **When `implicit_authorization: false`**
613+
2. **When `explicit_authorization: false`**
609614
- **Scenario**: Same `Post` resource without a policy class.
610615
- **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.
611616
@@ -626,13 +631,13 @@ end
626631
627632
- **For applications after from Avo `3.13.4`**
628633
629-
It is recommended to leave `implicit_authorization` set to `true`, ensuring all actions must be explicitly authorized to prevent unintentional access.
634+
It is recommended to leave `explicit_authorization` set to `true`, ensuring all actions must be explicitly authorized to prevent unintentional access.
630635
631636
- **For applications before from Avo `3.13.4`**
632637
633-
- If upgrading from an earlier version, carefully review your policies before enabling `implicit_authorization`. Missing policy methods that were previously allowing access will now deny access unless explicitly defined.
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.
634639
635-
- 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 `implicit_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.
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.
636641
</Option>
637642

638643
## Rolify integration

docs/3.0/upgrade.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,29 @@
33
We'll update this page when we release new Avo 3 versions.
44

55
If you're looking for the Avo 2 to Avo 3 upgrade guide, please visit [the dedicated page](./avo-2-avo-3-upgrade).
6+
## Upgrade from 3.13.6 to 3.13.7
7+
8+
The `implicit_authorization` option has been renamed to `explicit_authorization` to better align with the feature's functionality. The underlying logic remains unchanged, so you only need to perform a rename if you're already using it.
9+
10+
```ruby
11+
config.implicit_authorization = true # [!code --]
12+
config.explicit_authorization = true # [!code ++]
13+
```
14+
615

716
## Upgrade from 3.13.3 to 3.13.4
817

918
<Option name="`implicit_authorization`">
1019

11-
We’ve introduced the [`implicit_authorization`](authorization.html#implicit_authorization) configuration option to enhance the security of your applications. This option allows you to define how missing policy classes or methods are handled. When set to `true`, any action without an explicitly defined policy will automatically be denied, ensuring that unprotected actions are not unintentionally accessible. This new behavior offers a more secure approach for authorization.
20+
:::warning Option Renamed
21+
<VersionReq version="3.13.7" /> this option was renamed to `explicit_authorization`.
22+
:::
23+
24+
We’ve introduced the [`implicit_authorization`](authorization.html#explicit_authorization) configuration option to enhance the security of your applications. This option allows you to define how missing policy classes or methods are handled. When set to `true`, any action without an explicitly defined policy will automatically be denied, ensuring that unprotected actions are not unintentionally accessible. This new behavior offers a more secure approach for authorization.
1225

13-
For new applications, [`implicit_authorization`](authorization.html#implicit_authorization) is enabled by default, but existing applications will retain the legacy behavior (`false`), allowing missing policies or methods to authorize actions. We encourage you to adopt this new setting by enabling [`implicit_authorization`](authorization.html#implicit_authorization), as it provides greater control over your authorization flow and reduces the risk of unauthorized access due to missing policies. Before enabling it, be sure to review your policy classes to ensure all necessary methods are defined, preventing any unintended access restrictions.
26+
For new applications, [`implicit_authorization`](authorization.html#explicit_authorization) is enabled by default, but existing applications will retain the legacy behavior (`false`), allowing missing policies or methods to authorize actions. We encourage you to adopt this new setting by enabling [`implicit_authorization`](authorization.html#explicit_authorization), as it provides greater control over your authorization flow and reduces the risk of unauthorized access due to missing policies. Before enabling it, be sure to review your policy classes to ensure all necessary methods are defined, preventing any unintended access restrictions.
1427

15-
We highly recommend taking a moment to read through the entire [`implicit_authorization`](authorization.html#implicit_authorization) documentation section before making any changes. Understanding this feature is crucial to ensuring your application's security and functionality, so don’t skip it!
28+
We highly recommend taking a moment to read through the entire [`implicit_authorization`](authorization.html#explicit_authorization) documentation section before making any changes. Understanding this feature is crucial to ensuring your application's security and functionality, so don’t skip it!
1629
</Option>
1730

1831

0 commit comments

Comments
 (0)