Skip to content

Commit 258df22

Browse files
author
Daniel Sentker
committed
1.0.2 version bump
1 parent a1f019b commit 258df22

File tree

4 files changed

+41
-43
lines changed

4 files changed

+41
-43
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG #
22

3+
## 1.0.2
4+
**2019-10-28**
5+
* Added Return type declarations
6+
* Updated README
7+
* Honor url-signature v1.0.9 / Version bump
8+
39
## 1.0.1
410
**2019-09-06**
511
* Code cleanup

README.md

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@ Symfony operations: 1 recipe
2424
Executing script cache:clear [OK]
2525
Executing script assets:install public [OK]
2626
```
27+
If you use Symfony Flex, you do not have to do anything anymore. Otherwise you have to include the bundle in your `<root>/config/bundles.php` like this:
2728

28-
As you can see, Symfony flex is able to install this bundle automatically, so there is nothing more to do for you :-)
29-
Looking for setup instructions without Symfony Flex? Look at the bottom of this file.
29+
```php
30+
<?php
31+
return [
32+
// ...
33+
Shift\UrlSignatureBundle\ShiftUrlSignatureBundle::class => ['all' => true],
34+
];
35+
```
3036

3137
## Usage
32-
### Sign URLs in your template / twig files
38+
### Sign URLs in your Twig Template
3339
This bundle comes with a twig function to create an url from any route name: `signed_url()` (and, as alias, `signed_path()`) works just like the symfony / twig function `path()` which you have certainly used a hundredfold. signed_path expects a route name and, optionally, query data as array:
3440
```twig
3541
<!-- Generating a regular link -->
@@ -56,7 +62,6 @@ use Shift\UrlSignatureBundle\Utils\UrlSignatureBuilder;
5662

5763
class ExampleController extends AbstractController
5864
{
59-
6065
/**
6166
* @Route("/member/detail/{id}", name="member_detail")
6267
*/
@@ -75,37 +80,14 @@ class ExampleController extends AbstractController
7580
### Verify URLs
7681
This bundle offers several ways to check the signature of the URL in your controller.
7782

78-
#### Verify a signature with an Annotation
79-
Annotate your controller action like the following example:
80-
81-
```php
82-
use Shift\UrlSignatureBundle\Annotation\RequiresSignatureVerification;
83-
84-
class ExampleController extends AbstractController
85-
{
86-
87-
/**
88-
* @RequiresSignatureVerification()
89-
*
90-
* @Route("/member/detail/{id}", name="member_detail")
91-
*/
92-
public function index(User $user) {
93-
// ...
94-
}
95-
}
96-
```
97-
98-
If the annotation is present, an Event Listener checks the incoming request URL. If the signature is missing (or invalid), an `\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException` is thrown **before** your action is called. Make sure to give the user an useful response if an AccessDeniedException is thrown (This applies regardless of the use of this bundle, of course).
99-
100-
#### Verify a signature with dependency injection
83+
#### Verify a signature with dependency injection (recommended)
10184
Inject an `Shift\UrlSignatureBundle\Utils\RequestValidator` instance to your action:
10285

10386
```php
10487
use Shift\UrlSignatureBundle\Utils\RequestValidator;
10588

10689
class ExampleController extends AbstractController
10790
{
108-
10991
/**
11092
* @Route("/member/detail/{id}", name="member_detail")
11193
*/
@@ -126,6 +108,27 @@ class ExampleController extends AbstractController
126108
}
127109
```
128110

111+
#### Verify a signature with an Annotation
112+
Annotate your controller action like the following example:
113+
114+
```php
115+
use Shift\UrlSignatureBundle\Annotation\RequiresSignatureVerification;
116+
117+
class ExampleController extends AbstractController
118+
{
119+
/**
120+
* @RequiresSignatureVerification()
121+
*
122+
* @Route("/member/detail/{id}", name="member_detail")
123+
*/
124+
public function index(User $user) {
125+
// ...
126+
}
127+
}
128+
```
129+
130+
If the annotation is present, an Event Listener checks the incoming request URL. If the signature is missing (or invalid), an `\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException` is thrown **before** your action is called. Make sure to give the user an useful response if an AccessDeniedException is thrown (This applies regardless of the use of this bundle, of course).
131+
129132
### Build hashed URLs and verify signatures with a trait
130133
This bundle comes with a trait to make the access to the Builder and RequestValidator easier::
131134

@@ -152,7 +155,7 @@ class SingleActionController extends AbstractController
152155
}
153156
```
154157

155-
_**Note:** The trait has a constructor. If your controller already has a constructor, you should not use this trait. Read more [at SO about "constructor in traits"](https://stackoverflow.com/questions/12478124/how-to-overload-class-constructor-within-traits-in-php-5-4)._
158+
_**Note:** The trait has its own constructor. If your controller already has a constructor, you should not use this trait. Read more [at StackOverflow about "constructor in traits"](https://stackoverflow.com/questions/12478124/how-to-overload-class-constructor-within-traits-in-php-5-4)._
156159

157160
## Advanced Usage
158161

@@ -193,17 +196,6 @@ shift_url_signature.configuration.default:
193196
```
194197
Do not be surprised at the weird looking arguments for the `setHashMask` method - I did not find a better solution to set a bitmask in a services.yaml.
195198

196-
### Manual Installation
197-
Download this repository, wire it with your autoloading mechanism and include the bundle in your `<root>/config/bundles.php` like this:
198-
199-
```php
200-
<?php
201-
return [
202-
// ...
203-
Shift\UrlSignatureBundle\ShiftUrlSignatureBundle::class => ['all' => true],
204-
];
205-
```
206-
207199
## Credits
208200
Based on the ideas by [psecio](https://github.com/psecio), the project was forked by [dsentker](https://github.com/dsentker) (thats me 😁) to upgrade the code for PHP 7.x applications. The adjustments then resulted in a separate library and, additionally, in this symfony 4 bundle.
209201

Shift/UrlSignatureBundle/ShiftUrlSignatureBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class ShiftUrlSignatureBundle extends Bundle
99
{
10-
public function getContainerExtension()
10+
public function getContainerExtension(): UrlSignatureExtension
1111
{
1212
return new UrlSignatureExtension();
1313
}

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"symfony/css-selector": "^4.2"
3535
},
3636
"require": {
37-
"php": "^7.1",
38-
"dsentker/url-signature": "^1.0.8",
37+
"php": "^7.2",
38+
"dsentker/url-signature": "^1.0.9",
3939
"symfony/http-kernel": "~4.0",
4040
"symfony/http-foundation": "~4.0",
4141
"symfony/twig-bridge": "~4.0",

0 commit comments

Comments
 (0)