oauth2-server/auth-server-events.md

47 lines
1.5 KiB
Markdown
Raw Normal View History

2014-09-30 22:44:18 +01:00
---
layout: default
title: Authorization server events
permalink: /authorization-server/events/
---
# Authorization server events
During the lifecycle of a request passing through the authorization server a number of events may be emitted.
2014-10-01 00:13:19 +01:00
You can subscribe to these events by attaching listeners to the authorization server.
2016-03-23 12:45:00 +00:00
To access the emitter call this method:
2014-10-01 00:13:19 +01:00
2016-03-23 12:45:00 +00:00
{% highlight php %}
$server->getEmitter(); // returns instance of \League\Event\EmitterInterface
{% endhighlight %}
2014-10-01 00:13:19 +01:00
2016-03-23 12:45:00 +00:00
## client.authentication.failed
2014-10-01 00:13:19 +01:00
2016-03-23 12:45:00 +00:00
{% highlight php %}
$server->getEmitter()->addListener(
'client.authentication.failed',
function (\League\OAuth2\Server\RequestEvent $event) {
// do something
}
);
{% endhighlight %}
2014-10-01 00:13:19 +01:00
2016-03-23 12:45:00 +00:00
This event is emitted when a client fails to authenticate. You might wish to listen to this event in order to ban clients that fail to authenticate after `n` number of attempts.
2014-10-01 00:13:19 +01:00
You can retrieve the request object that was used by calling `getRequest()` on the event object passed into your callable.
2016-03-23 12:45:00 +00:00
## user.authentication.failed
2014-10-01 00:13:19 +01:00
2016-03-23 12:45:00 +00:00
{% highlight php %}
$server->getEmitter()->addListener(
'user.authentication.failed',
function (\League\OAuth2\Server\RequestEvent $event) {
// do something
}
);
{% endhighlight %}
2014-10-01 00:13:19 +01:00
2016-03-23 12:45:00 +00:00
This event is emitted when a user fails to authenticate. You might wish to listen to this event in order to reset passwords or ban users that fail to authenticate after `n` number of attempts.
2014-10-01 00:13:19 +01:00
2016-03-23 12:45:00 +00:00
You can retrieve the request object that was used by calling `getRequest()` on the event object passed into your callable.