Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293248

Add authentication support for Views

$
0
0

Problem/Motivation

Currently, the only way to add authentication to a REST View is through RouteSubscriberBase->alterRoutes().

We could add the Authentication setting to REST Views so users could select the supported authentication methods for a particular Views display. It would look like the following screenshot:

views authentication

The above view lists unpublished content in JSON format. Authentication has been set to Basic Auth, so requests to http://mysite.com/unpublished-content will require HTTP Basic authentication headers provided with a valid username and password. Note that Access has been set to Authenticated User role, since the default access requirement is "Access content", which is part of the Anonymous role. Alternatively, we could also set a permission that belongs to the Authenticated User role. I am not sure about how to make this more obvious to the site builder.

How to test

  1. Install Drupal and enable Rest, Hal, Basic Auth
  2. Add a Rest export display on /node
  3. Generate some frontpage nodes
  4. curl --request GET http://drupal.d8/node?_format=hal_json
  5. curl --request GET http://admin:admin@drupal.d8/node?_format=hal_json gives access denied
  6. Apply the patch
  7. Set basic auth as Authentication methods for the Rest Export display
  8. curl --request GET http://admin:admin@drupal.d8/node?_format=hal_json gives result.

Proposed resolution

Remaining tasks

Revert AuthenticationManager ::getSortedProviders to private once #2490228: Add Authentication Collector lands.

User interface changes

API changes


Viewing all articles
Browse latest Browse all 293248

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>