From 3cf082d6b9fabdd1fd10c6373bc5affba400bac2 Mon Sep 17 00:00:00 2001 From: Milan Sulc Date: Thu, 4 Jun 2026 20:30:50 +0000 Subject: [PATCH 1/2] Docs: move documentation to README --- .docs/README.md | 149 --------------------------------------------- README.md | 156 +++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 147 insertions(+), 158 deletions(-) delete mode 100644 .docs/README.md diff --git a/.docs/README.md b/.docs/README.md deleted file mode 100644 index 575f7e1..0000000 --- a/.docs/README.md +++ /dev/null @@ -1,149 +0,0 @@ -# Contributte OAuth2 Server - -## Content - -- [Setup](#setup) -- [Configuration](#configuration) -- [Example](#example) - -## Prologue - -`Contributte/OAuth2Server` brings `League/OAuth2Server` to your Nette applications. - -Please take a look at official documentation: [https://oauth2.thephpleague.com/](https://oauth2.thephpleague.com/) - -## Setup - -```bash -composer require contributte/oauth2-server -``` - -You also need to generate public and private key and an encryption key, for more information how to do it check -out `League/OAuth2Server` documentation: https://oauth2.thephpleague.com/installation/. - -```neon -extensions: - oauth2.server: Contributte\OAuth2Server\DI\OAuth2ServerExtension -``` - -## Configuration - -Do not forget to change the permissions on your public and private key (`chmod 0600 public.key private.key`) -Or you can turn off the permission check in configuration (`permissionCheck`) - **not recommended**. - -```neon -oauth2.server: - encryptionKey: "encryption key" - privateKey: - path: "/path/to/private.key" - passPhrase: "foo" - permissionCheck: true - publicKey: - path: "/path/to/public.key" - permissionCheck: true - grants: - authCode: - ttl: PT1H - clientCredentials: - ttl: PT1H - implicit: - ttl: PT1H - password: - ttl: PT1H - refreshToken: - ttl: P7D -``` - -### Grant Configuration - -Each grant type accepts an object with options. Use empty object `[]` to enable with defaults, or `false` to disable. - -**Common option:** -- `ttl` - Access token lifetime (ISO 8601 duration) - -**authCode grant:** -- `authCodeTTL` - Authorization code lifetime (default: `PT10M`) -- `codeExchangeProof` - Enable PKCE (default: `false`) - -```neon -grants: - authCode: - ttl: PT1H - authCodeTTL: PT5M - codeExchangeProof: true -``` - -**implicit grant:** -- `accessTokenTTL` - Access token TTL for grant construction (default: `PT10M`) - -```neon -grants: - implicit: - ttl: PT2H - accessTokenTTL: PT15M -``` - -**TTL format** uses [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations): `PT10M` (10 min), `PT1H` (1 hour), `P1D` (1 day), `P7D` (7 days) - -For encryption key, you can use `Defuse\Crypt\Key::loadFromAsciiSafeString($string)` or key in a string form. - -```neon -oauth2.server: - encryptionKey: Defuse\Crypto\Key::loadFromAsciiSafeString('keyInStringForm') - # ... -``` - -Do not forget to register repositories as a services! - -For more information about The PHP League's OAuth2 server, check out -it's [documentation](https://oauth2.thephpleague.com/). This package provides tiny wrappaper and integration into Nette -framework. - -## Example - -```php -getHttpRequest(); - $psr7Request = Psr7ServerRequestFactory::fromNette($request); - /** @var IResponse $response */ - $response = $this->gethttpResponse(); - $psr7Response = Psr7ResponseFactory::fromNette($response); - - try { - $reply = $this->authorizationServer->respondToAccessTokenRequest($psr7Request, $psr7Response); - } catch (OAuthServerException $exception) { - $reply = $exception->generateHttpResponse($psr7Response); - } catch (Throwable $exception) { - $body = Utils::streamFor('php://temp'); - $body->write($exception->getMessage()); - $reply = $psr7Response->withStatus(500)->withBody($body); - } - - $this->sendResponse(new Oauth2Response($reply)); - } - -} -``` diff --git a/README.md b/README.md index 8892c41..4ffad28 100644 --- a/README.md +++ b/README.md @@ -18,24 +18,162 @@ Website 🚀 contributte.org | Contact 👨🏻‍💻 f3l1x.io | Twitter 🐦 @contributte

-## Usage +An integration of League\OAuth2Server into Nette framework. -To install latest version of `contributte/oauth2-server` use [Composer](https://getcomposer.org). +## Versions + +| State | Version | Branch | Nette | PHP | +|-------------|---------|----------|-------|---------| +| dev | `^0.5` | `master` | 3.0+ | `>=8.1` | +| dev | `^0.4` | `master` | 3.0+ | `>=8.0` | + +## Contents + +- [Installation](#installation) +- [Configuration](#configuration) +- [Example](#example) + +## Prologue + +`Contributte/OAuth2Server` brings `League/OAuth2Server` to your Nette applications. + +Please take a look at official documentation: [https://oauth2.thephpleague.com/](https://oauth2.thephpleague.com/) + +## Installation ```bash composer require contributte/oauth2-server ``` -## Documentation +You also need to generate public and private key and an encryption key, for more information how to do it check +out `League/OAuth2Server` documentation: https://oauth2.thephpleague.com/installation/. -For details on how to use this package, check out our [documentation](.docs). +```neon +extensions: + oauth2.server: Contributte\OAuth2Server\DI\OAuth2ServerExtension +``` -## Versions +## Configuration -| State | Version | Branch | Nette | PHP | -|-------------|---------|----------|-------|---------| -| dev | `^0.5` | `master` | 3.0+ | `>=8.1` | -| dev | `^0.4` | `master` | 3.0+ | `>=8.0` | +Do not forget to change the permissions on your public and private key (`chmod 0600 public.key private.key`) +Or you can turn off the permission check in configuration (`permissionCheck`) - **not recommended**. + +```neon +oauth2.server: + encryptionKey: "encryption key" + privateKey: + path: "/path/to/private.key" + passPhrase: "foo" + permissionCheck: true + publicKey: + path: "/path/to/public.key" + permissionCheck: true + grants: + authCode: + ttl: PT1H + clientCredentials: + ttl: PT1H + implicit: + ttl: PT1H + password: + ttl: PT1H + refreshToken: + ttl: P7D +``` + +### Grant Configuration + +Each grant type accepts an object with options. Use empty object `[]` to enable with defaults, or `false` to disable. + +**Common option:** +- `ttl` - Access token lifetime (ISO 8601 duration) + +**authCode grant:** +- `authCodeTTL` - Authorization code lifetime (default: `PT10M`) +- `codeExchangeProof` - Enable PKCE (default: `false`) + +```neon +grants: + authCode: + ttl: PT1H + authCodeTTL: PT5M + codeExchangeProof: true +``` + +**implicit grant:** +- `accessTokenTTL` - Access token TTL for grant construction (default: `PT10M`) + +```neon +grants: + implicit: + ttl: PT2H + accessTokenTTL: PT15M +``` + +**TTL format** uses [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations): `PT10M` (10 min), `PT1H` (1 hour), `P1D` (1 day), `P7D` (7 days) + +For encryption key, you can use `Defuse\Crypt\Key::loadFromAsciiSafeString($string)` or key in a string form. + +```neon +oauth2.server: + encryptionKey: Defuse\Crypto\Key::loadFromAsciiSafeString('keyInStringForm') + # ... +``` + +Do not forget to register repositories as a services! + +For more information about The PHP League's OAuth2 server, check out +it's [documentation](https://oauth2.thephpleague.com/). This package provides tiny wrappaper and integration into Nette +framework. + +## Example + +```php +getHttpRequest(); + $psr7Request = Psr7ServerRequestFactory::fromNette($request); + /** @var IResponse $response */ + $response = $this->gethttpResponse(); + $psr7Response = Psr7ResponseFactory::fromNette($response); + + try { + $reply = $this->authorizationServer->respondToAccessTokenRequest($psr7Request, $psr7Response); + } catch (OAuthServerException $exception) { + $reply = $exception->generateHttpResponse($psr7Response); + } catch (Throwable $exception) { + $body = Utils::streamFor('php://temp'); + $body->write($exception->getMessage()); + $reply = $psr7Response->withStatus(500)->withBody($body); + } + + $this->sendResponse(new Oauth2Response($reply)); + } + +} +``` ## Development From efb0a7dd49db9ebc2526bd5f92e6304f762a384f Mon Sep 17 00:00:00 2001 From: Oh My Felix Date: Tue, 7 Jul 2026 17:04:40 +0000 Subject: [PATCH 2/2] Docs: polish README migration --- README.md | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4ffad28..7d2b699 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,14 @@ Website 🚀 contributte.org | Contact 👨🏻‍💻 f3l1x.io | Twitter 🐦 @contributte

-An integration of League\OAuth2Server into Nette framework. +An integration of League\OAuth2Server into Nette framework. See the official [League OAuth2 Server documentation](https://oauth2.thephpleague.com/) for details about OAuth server concepts. ## Versions | State | Version | Branch | Nette | PHP | |-------------|---------|----------|-------|---------| -| dev | `^0.5` | `master` | 3.0+ | `>=8.1` | -| dev | `^0.4` | `master` | 3.0+ | `>=8.0` | +| dev | `^0.6` | `master` | 3.2+ | `>=8.2` | +| stable | `^0.5` | `master` | 3.2+ | `>=8.2` | ## Contents @@ -33,12 +33,6 @@ An integration of League\OAuth2Server into Nette framework. - [Configuration](#configuration) - [Example](#example) -## Prologue - -`Contributte/OAuth2Server` brings `League/OAuth2Server` to your Nette applications. - -Please take a look at official documentation: [https://oauth2.thephpleague.com/](https://oauth2.thephpleague.com/) - ## Installation ```bash @@ -123,7 +117,7 @@ oauth2.server: Do not forget to register repositories as a services! For more information about The PHP League's OAuth2 server, check out -it's [documentation](https://oauth2.thephpleague.com/). This package provides tiny wrappaper and integration into Nette +its [documentation](https://oauth2.thephpleague.com/). This package provides a tiny wrapper and integration into Nette framework. ## Example