Skip to content

Latest commit

 

History

History
138 lines (59 loc) · 4.18 KB

NPR-One-Controllers-DeviceCodeController.md

File metadata and controls

138 lines (59 loc) · 4.18 KB

NPR\One\Controllers\DeviceCodeController

Use this controller to power your OAuth2 proxy if you are using the device_code grant.

The consumer of this codebase is responsible for setting up a router which forwards on the relevant requests to the \NPR\One\Controllers\DeviceCodeController::startDeviceCodeGrant() and \NPR\One\Controllers\DeviceCodeController::pollDeviceCodeGrant() public methods in this class.

Methods

startDeviceCodeGrant

\NPR\One\Models\DeviceCodeModel NPR\One\Controllers\DeviceCodeController::startDeviceCodeGrant(array<mixed,string> $scopes)

Kicks off a new device code flow

  • Visibility: public

Arguments

  • $scopes array<mixed,string>

pollDeviceCodeGrant

\NPR\One\Models\AccessTokenModel NPR\One\Controllers\DeviceCodeController::pollDeviceCodeGrant()

Polls the POST /token endpoint as part of the device code flow. It will throw an exception if the user has not yet logged in, and return an access token once the user has successfully logged in.

  • Visibility: public

__construct

mixed NPR\One\Controllers\AbstractOAuth2Controller::__construct()

Performs basic initialization and forwards on lat and lon if found within GEOIP server headers.

getHeaders

array<mixed,string> NPR\One\Controllers\AbstractOAuth2Controller::getHeaders()

Returns the lat and long headers if GeoIP is available. Useful for testing.

setConfigProvider

\NPR\One\Controllers\AbstractOAuth2Controller NPR\One\Controllers\AbstractOAuth2Controller::setConfigProvider(\NPR\One\Interfaces\ConfigInterface $configProvider)

Sets the configuration provider for this class. This is a required step for consumers of this code, as no default config provider is available.

Arguments

setSecureStorageProvider

\NPR\One\Controllers\AbstractOAuth2Controller NPR\One\Controllers\AbstractOAuth2Controller::setSecureStorageProvider(\NPR\One\Interfaces\StorageInterface $storageProvider)

Sets the storage provider to use across PHP sessions for items requiring extra security, such as refresh tokens. By default, the SecureCookieProvider will be used (in tandem with an EncryptionProvider to securely encrypt the cookies), but it can be overridden here.

Arguments

setEncryptionProvider

\NPR\One\Controllers\AbstractOAuth2Controller NPR\One\Controllers\AbstractOAuth2Controller::setEncryptionProvider(\NPR\One\Interfaces\EncryptionInterface $encryptionProvider)

Sets the encryption provider that is used by the SecureCookieProvider class if it is selected as the secure storage provider of choice. If a custom secure storage provider is used, the encryption provider may no longer be needed. By default, an EncryptionProvider class using openssl is used, but it can be overridden here.

Arguments