Deprecated authRequired in favor of security.authc.enabled (#202414)

## Summary

Deprecated `authRequired` in favor of `security.authc.enabled`.


### Checklist

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

__Closes: https://github.com/elastic/kibana/issues/191711__

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Elena Shostak 2024-12-10 11:24:41 +01:00 committed by GitHub
parent 62c1333303
commit 4feed672e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 7 deletions

View file

@ -368,7 +368,7 @@ export class MyPlugin implements Plugin {
By default, when security is enabled, endpoints require the user to be authenticated to be accessed,
and will return a `401 - Unauthorized` otherwise.
It is possible to disable this requirement using the `authRequired` option of the route.
It is possible to disable this requirement using the `security.authc.enabled` option of the route.
```ts
import type { CoreSetup, Plugin } from '@kbn/core/server';
@ -380,8 +380,11 @@ export class MyPlugin implements Plugin {
{
path: '/api/my_plugin/get_object',
validate: false,
options: {
authRequired: false,
security: {
authc: {
enabled: false,
reason: 'This endpoint does not require authentication',
},
},
},
async (context, request, response) => {
@ -394,7 +397,7 @@ export class MyPlugin implements Plugin {
}
```
Note that in addition to `true` and `false`, `authRequired` accepts a third value, `'optional'`. When used,
Note that in addition to `true` and `false`, `security.authc.enabled` accepts a third value, `'optional'`. When used,
Kibana will try to authenticate the user but will allow access to the endpoint regardless of the result. In that
case, the developer needs to manually checks if the user is authenticated via `request.auth.isAuthenticated`.
@ -416,8 +419,11 @@ export class MyPlugin implements Plugin {
{
path: '/api/my_plugin/get_object',
validate: false,
options: {
authRequired: false,
security: {
authc: {
enabled: false,
reason: 'This endpoint does not require authentication',
},
},
},
async (context, request, response) => {