Skip to content

Commit

Permalink
Rename Authenticators to Authorizers
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkomarev committed May 19, 2017
1 parent e7ae317 commit 5523039
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Laravel wrapper for the [YouTrack REST PHP client library](https://github.com/cy
- [Installation](#installation)
- [Configuration](#configuration)
- [YouTrack URL](#youtrack-url)
- [Authentication methods](#authentication-methods)
- [Authorization methods](#authorization-methods)
- [Usage](#usage)
- [Initialize API client](#initialize-api-client)
- [API requests](#api-requests)
Expand All @@ -38,7 +38,7 @@ Laravel wrapper for the [YouTrack REST PHP client library](https://github.com/cy
## Features

- Using contracts to keep high customization capabilities.
- Multiple authentication strategies: Token, Cookie.
- Multiple authorization strategies: Token, Cookie.
- Utilizes PHP Standard Recommendations:
- [PSR-2 (Coding Style Guide)](http://www.php-fig.org/psr/psr-2/).
- [PSR-4 (Autoloading Standard)](http://www.php-fig.org/psr/psr-4/).
Expand Down Expand Up @@ -89,20 +89,20 @@ YouTrack instance location could be defined in `.env` file:
YOUTRACK_BASE_URI=https://youtrack.custom.domain
```

### Authentication methods
### Authorization methods

Starting with YouTrack 2017.1 release [authorization based on permanent tokens](https://www.jetbrains.com/help/youtrack/standalone/2017.2/Manage-Permanent-Token.html) is recommended as the main approach for the authorization in your REST API calls.

By default Token authorization will be used. You could redefine it in `.env` file:

#### Token authentication
#### Token authorization

```
YOUTRACK_AUTH=token
YOUTRACK_TOKEN=your-permanents-token
```

#### Cookie authentication
#### Cookie authorization

```
YOUTRACK_AUTH=cookie
Expand Down
18 changes: 9 additions & 9 deletions config/youtrack.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,36 @@

/*
|--------------------------------------------------------------------------
| Default YouTrack Authenticator Name
| Default YouTrack Authorizer Name
|--------------------------------------------------------------------------
|
| This option controls the default authenticator that will be used by the
| This option controls the default authorizer that will be used by the
| library when YouTrack authorization is required. You may set this to
| any of the drivers defined in the "authenticators" array below.
| any of the drivers defined in the "authorizers" array below.
|
| Supported: "token" (recommended), "cookie"
|
*/

'authenticator' => env('YOUTRACK_AUTH', 'token'),
'authorizer' => env('YOUTRACK_AUTH', 'token'),

/*
|--------------------------------------------------------------------------
| YouTrack Authenticators
| YouTrack Authorizers
|--------------------------------------------------------------------------
|
| Here are each of the authenticators available in YouTrack REST API.
| Here are each of the authorizers available in YouTrack REST API.
|
*/

'authenticators' => [
'authorizers' => [
'token' => [
'driver' => \Cog\YouTrack\Rest\Authenticator\TokenAuthenticator::class,
'driver' => \Cog\YouTrack\Rest\Authorizer\TokenAuthorizer::class,
'token' => env('YOUTRACK_TOKEN'),
],

'cookie' => [
'driver' => \Cog\YouTrack\Rest\Authenticator\CookieAuthenticator::class,
'driver' => \Cog\YouTrack\Rest\Authorizer\CookieAuthorizer::class,
'username' => env('YOUTRACK_USERNAME'),
'password' => env('YOUTRACK_PASSWORD'),
],
Expand Down
12 changes: 6 additions & 6 deletions src/Providers/YouTrackServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Cog\Laravel\YouTrack\Providers;

use Cog\YouTrack\Rest\Authenticator\Contracts\Authenticator as AuthenticatorContract;
use Cog\YouTrack\Rest\Authorizer\Contracts\Authorizer as AuthorizerContract;
use Cog\YouTrack\Rest\Client\Contracts\Client as ClientContract;
use Cog\YouTrack\Rest\Client\YouTrackClient;
use GuzzleHttp\Client as HttpClient;
Expand Down Expand Up @@ -53,7 +53,7 @@ public function register(): void
'base_uri' => $config->get('youtrack.base_uri'),
]);

return new YouTrackClient($http, $this->resolveAuthenticator($config));
return new YouTrackClient($http, $this->resolveAuthorizer($config));
});
}

Expand All @@ -76,14 +76,14 @@ protected function bootConfig(): void
}

/**
* Resolve Authenticator driver.
* Resolve Authorizer driver.
*
* @param \Illuminate\Contracts\Config\Repository $config
* @return \Cog\YouTrack\Rest\Authenticator\Contracts\Authenticator
* @return \Cog\YouTrack\Rest\Authorizer\Contracts\Authorizer
*/
protected function resolveAuthenticator(ConfigContract $config): AuthenticatorContract
protected function resolveAuthorizer(ConfigContract $config): AuthorizerContract
{
$options = $config->get('youtrack.authenticators.' . $config->get('youtrack.authenticator'));
$options = $config->get('youtrack.authorizers.' . $config->get('youtrack.authorizer'));

return new $options['driver']($options);
}
Expand Down

0 comments on commit 5523039

Please sign in to comment.