Skip to content

Commit

Permalink
Merge pull request #39 from spatie/v2
Browse files Browse the repository at this point in the history
v2
  • Loading branch information
freekmurze authored Nov 12, 2022
2 parents 8cb9019 + 0d45f5c commit 372f144
Show file tree
Hide file tree
Showing 23 changed files with 416 additions and 420 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: spatie
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
blank_issues_enabled: false
contact_links:
- name: Ask a question
url: https://github.com/spatie/lighthouse-php/discussions/new?category=q-a
about: Ask the community for help
- name: Request a feature
url: https://github.com/spatie/lighthouse-php/discussions/new?category=ideas
about: Share ideas for new features
- name: Report a security issue
url: https://github.com/spatie/lighthouse-php/security/policy
about: Learn how to notify us for sensitive bugs
- name: Report a bug
url: https://github.com/spatie/lighthouse-php/issues/new
about: Report a reproducable bug
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels:
- "dependencies"
32 changes: 32 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: dependabot-auto-merge
on: pull_request_target

permissions:
pull-requests: write
contents: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:

- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.3.5
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Auto-merge Dependabot PRs for semver-minor updates
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Auto-merge Dependabot PRs for semver-patch updates
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
name: Check & fix styling
name: Fix PHP code style issues

on: [push]
on:
push:
paths:
- '**.php'

jobs:
php-cs-fixer:
php-code-styling:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php-cs-fixer.php --allow-risky=yes
- name: Fix PHP code style issues
uses: aglipanci/laravel-pint-action@1.0.0

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,32 @@ jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.1, 8.0, 7.4]
stability: [prefer-lowest, prefer-stable]
os: [ubuntu-latest]
php: [8.2, 8.1]
stability: [prefer-stable]

name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Execute tests
run: vendor/bin/phpunit
run: composer test
35 changes: 0 additions & 35 deletions .php-cs-fixer.php

This file was deleted.

20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/support-ukraine.svg?t=1" />](https://supportukrainenow.org)

# Create secured URLs with a limited lifetime

[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/url-signer.svg?style=flat-square)](https://packagist.org/packages/spatie/url-signer)
Expand All @@ -16,7 +13,7 @@ $urlSigner = new MD5UrlSigner('randomkey');

$urlSigner->sign('https://myapp.com', 30);

// => The generated url will be valid for 30 days
// => The generated url will be valid for 30 seconds
```

This will output an URL that looks like `https://myapp.com/?expires=xxxx&signature=xxxx`.
Expand All @@ -28,8 +25,6 @@ your application can validate it with:
$urlSigner->validate('https://myapp.com/?expires=xxxx&signature=xxxx');
```

Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

## Support us

[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/url-signer.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/url-signer)
Expand Down Expand Up @@ -58,9 +53,9 @@ composer require spatie/url-signer
A signer-object can sign URLs and validate signed URLs. A secret key is used to generate signatures.

```php
use Spatie\UrlSigner\MD5UrlSigner;
use Spatie\UrlSigner\Md5UrlSigner;

$urlSigner = new MD5UrlSigner('mysecretkey');
$urlSigner = new Md5UrlSigner('mysecretkey');
```

### Generating URLs
Expand All @@ -75,12 +70,12 @@ $urlSigner->sign('https://myapp.com', $expirationDate);
// => The generated url will be valid for 10 days
```

If an integer is provided as expiration date, the url will be valid for that amount of days.
If an integer is provided as expiration date, the url will be valid for that amount of seconds.

```php
$urlSigner->sign('https://myapp.com', 30);

// => The generated url will be valid for 30 days
// => The generated url will be valid for 30 seconds
```

### Validating URLs
Expand All @@ -98,6 +93,7 @@ $urlSigner->validate('https://myapp.com/?expires=1439223344&signature=2d42f65bd0
```

## Writing custom signers

This packages provides a signer that uses md5 to generate signature. You can create your own
signer by implementing the `Spatie\UrlSigner\UrlSigner`-interface. If you let your signer extend
`Spatie\UrlSigner\BaseUrlSigner` you'll only need to provide the `createSignature`-method.
Expand All @@ -107,10 +103,11 @@ signer by implementing the `Spatie\UrlSigner\UrlSigner`-interface. If you let yo
The tests can be run with:

```
$ vendor/bin/phpspec run
composer test
```

## Integrations

To get started quickly in Laravel you can use the [spatie/laravel-url-signer](https://github.com/spatie/laravel-url-signer) package.

## Changelog
Expand All @@ -127,6 +124,7 @@ If you've found a bug regarding security please mail [security@spatie.be](mailto

## Credits

- [Freek Van der Herten](https://github.com/freekmurze)
- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)

Expand Down
4 changes: 4 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## From v1 to v2

- the expiration passed to `sign` and `validate` is now in seconds instead of days
- all the rest of the API has stayed the same 👍
33 changes: 24 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"homepage": "https://github.com/spatie/url-signer",
"license": "MIT",
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://github.com/freekmurze",
"role": "Developer"
},
{
"name": "Sebastian De Deyne",
"email": "sebastian@spatie.be",
Expand All @@ -19,24 +25,33 @@
}
],
"require": {
"php": "^7.4|^8.0",
"league/uri": "^6.0",
"league/uri-components": "^2.2"
"php": "^8.1"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
"pestphp/pest": "^1.22"
},
"autoload": {
"psr-4": {
"Spatie\\UrlSigner\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Spatie\\UrlSigner\\Tests\\": "tests"
}
},
"scripts": {
"test": "phpunit"
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"config": {
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true,
"pestphp/pest-plugin": true
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
5 changes: 0 additions & 5 deletions phpspec.yml

This file was deleted.

Loading

0 comments on commit 372f144

Please sign in to comment.