class DisallowSimpleOauthRequests in Simple OAuth (OAuth2) & OpenID Connect 8.4
Same name and namespace in other branches
- 8 src/PageCache/DisallowSimpleOauthRequests.php \Drupal\simple_oauth\PageCache\DisallowSimpleOauthRequests
- 8.2 src/PageCache/DisallowSimpleOauthRequests.php \Drupal\simple_oauth\PageCache\DisallowSimpleOauthRequests
- 8.3 src/PageCache/DisallowSimpleOauthRequests.php \Drupal\simple_oauth\PageCache\DisallowSimpleOauthRequests
- 5.x src/PageCache/DisallowSimpleOauthRequests.php \Drupal\simple_oauth\PageCache\DisallowSimpleOauthRequests
Do not serve a page from cache if OAuth2 authentication is applicable.
@internal
Hierarchy
- class \Drupal\simple_oauth\PageCache\DisallowSimpleOauthRequests implements SimpleOauthRequestPolicyInterface
Expanded class hierarchy of DisallowSimpleOauthRequests
1 file declares its use of DisallowSimpleOauthRequests
- SimpleOauthAuthenticationTest.php in tests/
src/ Unit/ Authentication/ Provider/ SimpleOauthAuthenticationTest.php
1 string reference to 'DisallowSimpleOauthRequests'
1 service uses DisallowSimpleOauthRequests
File
- src/
PageCache/ DisallowSimpleOauthRequests.php, line 12
Namespace
Drupal\simple_oauth\PageCacheView source
class DisallowSimpleOauthRequests implements SimpleOauthRequestPolicyInterface {
/**
* {@inheritdoc}
*/
public function isOauth2Request(Request $request) {
// Check the header. See: http://tools.ietf.org/html/rfc6750#section-2.1
// We have to perform also an exact match, as if no token is provided then
// the LWS might be stripped, but we still have to detect this as OAuth2
// authentication. See: https://www.ietf.org/rfc/rfc2616.txt
$auth_header = trim($request->headers
->get('Authorization', '', TRUE));
return strpos($auth_header, 'Bearer ') !== FALSE || $auth_header === 'Bearer';
}
/**
* {@inheritdoc}
*/
public function check(Request $request) {
return $this
->isOauth2Request($request) ? static::DENY : NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DisallowSimpleOauthRequests:: |
public | function |
Determines whether delivery of a cached page should be attempted. Overrides RequestPolicyInterface:: |
|
DisallowSimpleOauthRequests:: |
public | function |
Returns a state whether the request has an OAuth2 access token. Overrides SimpleOauthRequestPolicyInterface:: |
|
RequestPolicyInterface:: |
constant | Allow delivery of cached pages. | ||
RequestPolicyInterface:: |
constant | Deny delivery of cached pages. |