class AuthenticationService implements AuthenticationServiceInterface

Service used to authenticate users between Microsoft 365 and Drupal.

Traits

RedirectDestinationTrait
StringTranslationTrait

Properties

protected AuthmapInterface $authmap

The auth map.

protected ConfigFactoryInterface $configFactory

The config factory interface.

protected ConstantsService $constants

The ConstantsService implementation.

protected AccountProxyInterface $currentUser

The current user account.

protected EntityTypeManagerInterface $entityTypeManager

The entity type manager.

protected HelperService $helperService

The o365 helper service.

protected O365LoggerServiceInterface $loggerService

The logger service.

protected Messenger $messenger

The messenger.

protected ImmutableConfig $moduleConfig

The modules base config.

protected GenericProvider $oauthClient

An oauth provider.

protected Request $request

The current request.

protected ImmutableConfig $ssoConfig

The o365_sso config.

protected PrivateTempStoreFactory $tempStore

The private temp store.

Methods

__construct(ConfigFactoryInterface $configFactory, PrivateTempStoreFactory $tempStoreFactory, ConstantsService $constantsService, O365LoggerServiceInterface $loggerService, RequestStack $requestStack, HelperService $helperService, AccountProxyInterface $accountProxy, AuthmapInterface $authmap, Messenger $messenger, EntityTypeManagerInterface $entityTypeManager)

Constructs a new AuthenticationService object.

string|bool
checkForOfficeLogin()

Check if a user is logged in via Office.

string|false
getAccessToken(bool $login = TRUE)

Get the access token for the user.

mixed
getDataFromTempStore(string $name)

Get data from the temp store.

mixed
redirectToAuthorizationUrl(O365ConnectorInterface $o365_connector)

Redirect the user to the correct Microsoft pages for OAuth2.

void
saveAuthDataFromUrl()

Save the auth data from the url parameters in the user session storage.

setAccessToken(string $code, O365ConnectorInterface $o365_connector, string $redirect = '')

Generate and save the access token.

Details

at line 130
__construct(ConfigFactoryInterface $configFactory, PrivateTempStoreFactory $tempStoreFactory, ConstantsService $constantsService, O365LoggerServiceInterface $loggerService, RequestStack $requestStack, HelperService $helperService, AccountProxyInterface $accountProxy, AuthmapInterface $authmap, Messenger $messenger, EntityTypeManagerInterface $entityTypeManager)

Constructs a new AuthenticationService object.

Parameters

ConfigFactoryInterface $configFactory

The config factory interface.

PrivateTempStoreFactory $tempStoreFactory

The private store factory.

ConstantsService $constantsService

The constants service from the o365 module.

O365LoggerServiceInterface $loggerService

The logger service from the o365 module.

RequestStack $requestStack

The request stack.

HelperService $helperService

The helper service used to get the api settings.

AccountProxyInterface $accountProxy

The account proxy for the current user.

AuthmapInterface $authmap

The auth map.

Messenger $messenger

The messenger class.

EntityTypeManagerInterface $entityTypeManager

The entity type manager.

at line 275
string|bool checkForOfficeLogin()

Check if a user is logged in via Office.

Return Value

string|bool

The users ID or FALSE if not logged in via Office.

at line 230
string|false getAccessToken(bool $login = TRUE)

Get the access token for the user.

Parameters

bool $login

If we want to log in the user if there is no token.

Return Value

string|false

The access token or false when no token is provided.

Exceptions

TempStoreException
IdentityProviderException

at line 406
mixed getDataFromTempStore(string $name)

Get data from the temp store.

Parameters

string $name

The name of the temp store value.

Return Value

mixed

The value.

at line 150
mixed redirectToAuthorizationUrl(O365ConnectorInterface $o365_connector)

Redirect the user to the correct Microsoft pages for OAuth2.

Parameters

O365ConnectorInterface $o365_connector

The o365_connector entity type.

Return Value

mixed

The response, probably a redirect.

at line 261
void saveAuthDataFromUrl()

Save the auth data from the url parameters in the user session storage.

Return Value

void

Exceptions

TempStoreException

at line 197
setAccessToken(string $code, O365ConnectorInterface $o365_connector, string $redirect = '')

Generate and save the access token.

Parameters

string $code

The code we got from Microsoft.

O365ConnectorInterface $o365_connector

The o365_connector entity type.

string $redirect

An url where to redirect to.

Exceptions

TempStoreException
IdentityProviderException