Skip to content

Commit e2a0b14

Browse files
authored
Merge pull request #99 from Automattic/prevent_userinfo_endpoint_caching
Prevent userinfo endpoint from being cached
2 parents ee0646c + 2858017 commit e2a0b14

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Http/Handlers/UserInfoHandler.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ public function __construct( OAuth2Server $server ) {
1515
}
1616

1717
public function handle( Request $request, Response $response ): Response {
18-
return $this->server->handleUserInfoRequest( $request );
18+
// prevent caching plugins from caching this page.
19+
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
20+
define( 'DONOTCACHEPAGE', true );
21+
}
22+
23+
$response = $this->server->handleUserInfoRequest( $request, $response );
24+
$response->addHttpHeaders(
25+
array(
26+
'Cache-Control' => 'no-store',
27+
'Pragma' => 'no-cache',
28+
)
29+
);
30+
31+
return $response;
1932
}
2033
}

0 commit comments

Comments
 (0)