oauth2-server/repository-interface-auth-code.md

38 lines
1.9 KiB
Markdown
Raw Normal View History

2016-03-25 00:56:58 +05:30
---
layout: default
title: AuthCodeRepositoryInterface documentation
permalink: /auth-code-repository-interface/
---
# Auth Code Repository Interface
2016-04-28 01:43:23 +05:30
## getNewAuthCode() : AuthCodeEntityInterface
This method should return an implementation of `\League\OAuth2\Server\Entities\AuthCodeEntityInterface`. You can use the following traits to help you implement the required methods from that interface:
* `League\OAuth2\Server\Entities\Traits\EntityTrait`
* `League\OAuth2\Server\Entities\Traits\TokenEntityTrait`
* `League\OAuth2\Server\Entities\Traits\AuthCodeTrait`
2016-03-25 00:56:58 +05:30
## persistNewAuthCode() : void
2016-10-09 16:18:21 +05:30
When a new auht code is created this method will be called. You don't have to do anything here but for auditing you probably want to.
2016-03-25 00:56:58 +05:30
2016-10-09 16:18:21 +05:30
The auth code entity passed in has a number of methods you can call which contain data worth saving to a database:
2016-03-25 00:56:58 +05:30
2016-10-09 16:18:21 +05:30
* `getIdentifier() : string` this is randomly generated unique identifier (of 80+ characters in length) for the auth code.
* `getExpiryDateTime() : \DateTime` the expiry date and time of the auth code.
* `getUserIdentifier() : string|null` the user identifier represented by the auth code.
2016-03-25 00:56:58 +05:30
* `getScopes() : ScopeEntityInterface[]` an array of scope entities
2016-10-09 16:18:21 +05:30
* `getClient()->getIdentifier() : string` the identifier of the client who requested the auth code.
2016-03-25 00:56:58 +05:30
2016-10-09 16:18:21 +05:30
The auth codes contain an expiry date and so will be rejected automatically if used when expired. You can safely clean up expired auth codes from your database.
2016-03-25 00:56:58 +05:30
## revokeAuthCode() : void
2016-10-09 16:18:21 +05:30
This method is called when an authorization code is exchanged for an access token. You can also use it in your own business logic.
2016-03-25 00:56:58 +05:30
## isAuthCodeRevoked() : boolean
2016-10-09 16:18:21 +05:30
This method is called before an authorization code is exchanged for an access token by the authorization server. Return `true` if the auth code has been manually revoked before it expired. If the auth code is still valid return `false`.