AuthenticationService
in package
implements
AuthenticationServiceInterface
Service used to authenticate users between Office 365 and Drupal.
Interfaces, Classes, Traits and Enums
- AuthenticationServiceInterface
- The interface for the AuthenticationService.
Table of Contents
- $apiConfig : ImmutableConfig
- The modules API config.
- $apiSettings : array<string|int, mixed>
- The modules API settings like the client ID.
- $authmap : Authmap
- The auth map.
- $configFactory : ConfigFactoryInterface
- The config factory interface.
- $constants : ConstantsService
- The ConstantsService implementation.
- $currentUser : AccountProxyInterface
- The current user account.
- $helperService : HelperService
- The o365 helper service.
- $loggerService : O365LoggerServiceInterface
- The logger service.
- $messenger : Messenger
- The messenger.
- $moduleConfig : ImmutableConfig
- The modules base config.
- $oauthClient : GenericProvider
- A oauth provider.
- $request : Request
- The current request.
- $tempStore : PrivateTempStoreFactory
- The private temp store.
- $authValues : array<string|int, mixed>
- The auth data.
- $debug : bool
- If we want to add debug messages.
- __construct() : mixed
- Constructs a new AuthenticationService object.
- checkForOfficeLogin() : string|bool
- Check if a user is logged in via Office.
- getAccessToken() : string
- Get the access token for the user.
- redirectToAuthorizationUrl() : mixed
- Redirect the user to the correct Microsoft pages for oAuth2.
- saveAuthDataFromUrl() : mixed
- Save the auth data from the url parameters in the user session storage.
- setAccessToken() : mixed
- Generate and save the accessToken.
- generateProvider() : mixed
- Generate a basic oAuth2 provider.
- getAuthData() : array<string|int, mixed>
- Get the auth data from temp store or cookie.
- refreshToken() : string
- Generate a new access token based on the refresh token.
- saveAuthData() : mixed
- Save the auth data to the temp store.
- saveDataToTempStore() : mixed
- Save data to the tempstore.
Properties
$apiConfig
The modules API config.
protected
ImmutableConfig
$apiConfig
$apiSettings
The modules API settings like the client ID.
protected
array<string|int, mixed>
$apiSettings
$authmap
The auth map.
protected
Authmap
$authmap
$configFactory
The config factory interface.
protected
ConfigFactoryInterface
$configFactory
$constants
The ConstantsService implementation.
protected
ConstantsService
$constants
$currentUser
The current user account.
protected
AccountProxyInterface
$currentUser
$helperService
The o365 helper service.
protected
HelperService
$helperService
$loggerService
The logger service.
protected
O365LoggerServiceInterface
$loggerService
$messenger
The messenger.
protected
Messenger
$messenger
$moduleConfig
The modules base config.
protected
ImmutableConfig
$moduleConfig
$oauthClient
A oauth provider.
protected
GenericProvider
$oauthClient
$request
The current request.
protected
Request
$request
$tempStore
The private temp store.
protected
PrivateTempStoreFactory
$tempStore
$authValues
The auth data.
private
array<string|int, mixed>
$authValues
= []
$debug
If we want to add debug messages.
private
bool
$debug
Methods
__construct()
Constructs a new AuthenticationService object.
public
__construct(ConfigFactoryInterface $configFactory, PrivateTempStoreFactory $tempStoreFactory, ConstantsService $constantsService, O365LoggerServiceInterface $loggerService, RequestStack $requestStack, HelperService $helperService, AccountProxyInterface $accountProxy, Authmap $authmap, Messenger $messenger) : mixed
Parameters
- $configFactory : ConfigFactoryInterface
-
The config factory interface.
- $tempStoreFactory : PrivateTempStoreFactory
-
The private store factory.
- $constantsService : ConstantsService
-
The constants service from the o365 module.
- $loggerService : O365LoggerServiceInterface
-
The logger service from the o365 module.
- $requestStack : RequestStack
-
The request stack.
- $helperService : HelperService
-
The helper service used to get the api settings.
- $accountProxy : AccountProxyInterface
-
The account proxy for the current user.
- $authmap : Authmap
-
The auth map.
- $messenger : Messenger
-
The messenger class.
Return values
mixed —checkForOfficeLogin()
Check if a user is logged in via Office.
public
checkForOfficeLogin() : string|bool
Return values
string|bool —The users ID or FALSE if not logged in via Office.
getAccessToken()
Get the access token for the user.
public
getAccessToken([mixed $login = TRUE ]) : string
Parameters
- $login : mixed = TRUE
-
If we want to login the user if there is no token.
Return values
string —The access token.
redirectToAuthorizationUrl()
Redirect the user to the correct Microsoft pages for oAuth2.
public
redirectToAuthorizationUrl() : mixed
Return values
mixed —saveAuthDataFromUrl()
Save the auth data from the url parameters in the user session storage.
public
saveAuthDataFromUrl() : mixed
Return values
mixed —setAccessToken()
Generate and save the accessToken.
public
setAccessToken(mixed $code[, mixed $redirect = FALSE ]) : mixed
Parameters
- $code : mixed
-
The code we got from Microsoft.
- $redirect : mixed = FALSE
-
Either FALSE or an url where to redirect to.
Return values
mixed —generateProvider()
Generate a basic oAuth2 provider.
private
generateProvider() : mixed
Return values
mixed —getAuthData()
Get the auth data from temp store or cookie.
private
getAuthData() : array<string|int, mixed>
Return values
array<string|int, mixed> —The saved auth data.
refreshToken()
Generate a new access token based on the refresh token.
private
refreshToken(string $refreshToken) : string
Parameters
- $refreshToken : string
-
The refresh token.
Tags
Return values
string —The new access token.
saveAuthData()
Save the auth data to the temp store.
private
saveAuthData(AccessTokenInterface $accessToken) : mixed
Parameters
- $accessToken : AccessTokenInterface
-
The access token object.
Tags
Return values
mixed —saveDataToTempStore()
Save data to the tempstore.
private
saveDataToTempStore(string $name, mixed $value) : mixed
Parameters
- $name : string
-
The name of the store.
- $value : mixed
-
The value.