Skip to content

Commit f2b1a5e

Browse files
committed
Merge branch 'main' of https://github.com/pdsinterop/php-solid-auth into main
Conflicts: src/WAC.php
2 parents a60ed60 + a22fb36 commit f2b1a5e

7 files changed

Lines changed: 143 additions & 22 deletions

File tree

CHANGELOG.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Changelog
2+
3+
## [v0.6.3](https://github.com/pdsinterop/php-solid-auth/tree/v0.6.3) (2021-12-08)
4+
5+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/v0.6.2...v0.6.3)
6+
7+
## [v0.6.2](https://github.com/pdsinterop/php-solid-auth/tree/v0.6.2) (2021-11-25)
8+
9+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/v0.6.1...v0.6.2)
10+
11+
**Merged pull requests:**
12+
13+
- Require write on parent for DELETE [\#18](https://github.com/pdsinterop/php-solid-auth/pull/18) ([michielbdejong](https://github.com/michielbdejong))
14+
- Fix for origin grants, allow registered clients [\#16](https://github.com/pdsinterop/php-solid-auth/pull/16) ([ylebre](https://github.com/ylebre))
15+
- replacing codercats jwk converter with web-token to support EC tokens [\#15](https://github.com/pdsinterop/php-solid-auth/pull/15) ([ylebre](https://github.com/ylebre))
16+
- remove debugging [\#14](https://github.com/pdsinterop/php-solid-auth/pull/14) ([ylebre](https://github.com/ylebre))
17+
- Set the base url to the url where the acl file was found [\#13](https://github.com/pdsinterop/php-solid-auth/pull/13) ([ylebre](https://github.com/ylebre))
18+
- add option to check Origin in acl [\#12](https://github.com/pdsinterop/php-solid-auth/pull/12) ([ylebre](https://github.com/ylebre))
19+
- Adding WAC / Dpop [\#11](https://github.com/pdsinterop/php-solid-auth/pull/11) ([ylebre](https://github.com/ylebre))
20+
- WIP: dpop handling [\#10](https://github.com/pdsinterop/php-solid-auth/pull/10) ([ylebre](https://github.com/ylebre))
21+
22+
## [v0.6.1](https://github.com/pdsinterop/php-solid-auth/tree/v0.6.1) (2020-10-19)
23+
24+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/0.6...v0.6.1)
25+
26+
**Merged pull requests:**
27+
28+
- Add function to decrypt 'code' for ID token generation [\#9](https://github.com/pdsinterop/php-solid-auth/pull/9) ([ylebre](https://github.com/ylebre))
29+
30+
## [0.6](https://github.com/pdsinterop/php-solid-auth/tree/0.6) (2020-10-03)
31+
32+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/0.5.1...0.6)
33+
34+
**Merged pull requests:**
35+
36+
- added id\_token option for token endpoint response [\#8](https://github.com/pdsinterop/php-solid-auth/pull/8) ([ylebre](https://github.com/ylebre))
37+
- typofix [\#7](https://github.com/pdsinterop/php-solid-auth/pull/7) ([ylebre](https://github.com/ylebre))
38+
- Added token generation code to support id\_token [\#6](https://github.com/pdsinterop/php-solid-auth/pull/6) ([ylebre](https://github.com/ylebre))
39+
40+
## [0.5.1](https://github.com/pdsinterop/php-solid-auth/tree/0.5.1) (2020-09-21)
41+
42+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/v0.5.0...0.5.1)
43+
44+
## [v0.5.0](https://github.com/pdsinterop/php-solid-auth/tree/v0.5.0) (2020-09-21)
45+
46+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/v0.4.0...v0.5.0)
47+
48+
**Merged pull requests:**
49+
50+
- Change Client config to support Redirect URIs and Name [\#4](https://github.com/pdsinterop/php-solid-auth/pull/4) ([Potherca](https://github.com/Potherca))
51+
52+
## [v0.4.0](https://github.com/pdsinterop/php-solid-auth/tree/v0.4.0) (2020-09-21)
53+
54+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/v0.3.0...v0.4.0)
55+
56+
**Merged pull requests:**
57+
58+
- Rename response methods [\#3](https://github.com/pdsinterop/php-solid-auth/pull/3) ([Potherca](https://github.com/Potherca))
59+
60+
## [v0.3.0](https://github.com/pdsinterop/php-solid-auth/tree/v0.3.0) (2020-09-15)
61+
62+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/v0.2.1...v0.3.0)
63+
64+
**Closed issues:**
65+
66+
- Log in to Slack [\#1](https://github.com/pdsinterop/php-solid-auth/issues/1)
67+
68+
**Merged pull requests:**
69+
70+
- Add JWKs request response. [\#2](https://github.com/pdsinterop/php-solid-auth/pull/2) ([Potherca](https://github.com/Potherca))
71+
72+
## [v0.2.1](https://github.com/pdsinterop/php-solid-auth/tree/v0.2.1) (2020-09-12)
73+
74+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/v0.2.0...v0.2.1)
75+
76+
## [v0.2.0](https://github.com/pdsinterop/php-solid-auth/tree/v0.2.0) (2020-09-12)
77+
78+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/v0.1.2...v0.2.0)
79+
80+
## [v0.1.2](https://github.com/pdsinterop/php-solid-auth/tree/v0.1.2) (2020-09-12)
81+
82+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/v0.1.1...v0.1.2)
83+
84+
## [v0.1.1](https://github.com/pdsinterop/php-solid-auth/tree/v0.1.1) (2020-09-11)
85+
86+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/v0.1.0...v0.1.1)
87+
88+
## [v0.1.0](https://github.com/pdsinterop/php-solid-auth/tree/v0.1.0) (2020-09-10)
89+
90+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/v0.0.0...v0.1.0)
91+
92+
## [v0.0.0](https://github.com/pdsinterop/php-solid-auth/tree/v0.0.0) (2020-08-27)
93+
94+
[Full Changelog](https://github.com/pdsinterop/php-solid-auth/compare/a408a4ae017c0c6aa36306cd98be22ff41805ecb...v0.0.0)
95+
96+
97+
98+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*

Gemfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6+
7+
# gem "rails"
8+
9+
gem "jekyll", "~> 3.8"
10+
gem "github-pages"

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
**@FIXME:**
2-
3-
- [ ] Generate a changelog
4-
`github_changelog_generator -u pdsinterop -p {{project-slug}}`
5-
61
# Solid Auth
72

83
[![Project stage: Development][project-stage-badge: Development]][project-stage-page]
@@ -98,7 +93,7 @@ All code created by PDS Interop is licensed under the [MIT License][license-link
9893
[keep-a-changelog-shield]: https://img.shields.io/badge/Keep%20a%20Changelog-f15d30.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmZmYiIHZpZXdCb3g9IjAgMCAxODcgMTg1Ij48cGF0aCBkPSJNNjIgN2MtMTUgMy0yOCAxMC0zNyAyMmExMjIgMTIyIDAgMDAtMTggOTEgNzQgNzQgMCAwMDE2IDM4YzYgOSAxNCAxNSAyNCAxOGE4OSA4OSAwIDAwMjQgNCA0NSA0NSAwIDAwNiAwbDMtMSAxMy0xYTE1OCAxNTggMCAwMDU1LTE3IDYzIDYzIDAgMDAzNS01MiAzNCAzNCAwIDAwLTEtNWMtMy0xOC05LTMzLTE5LTQ3LTEyLTE3LTI0LTI4LTM4LTM3QTg1IDg1IDAgMDA2MiA3em0zMCA4YzIwIDQgMzggMTQgNTMgMzEgMTcgMTggMjYgMzcgMjkgNTh2MTJjLTMgMTctMTMgMzAtMjggMzhhMTU1IDE1NSAwIDAxLTUzIDE2bC0xMyAyaC0xYTUxIDUxIDAgMDEtMTItMWwtMTctMmMtMTMtNC0yMy0xMi0yOS0yNy01LTEyLTgtMjQtOC0zOWExMzMgMTMzIDAgMDE4LTUwYzUtMTMgMTEtMjYgMjYtMzMgMTQtNyAyOS05IDQ1LTV6TTQwIDQ1YTk0IDk0IDAgMDAtMTcgNTQgNzUgNzUgMCAwMDYgMzJjOCAxOSAyMiAzMSA0MiAzMiAyMSAyIDQxLTIgNjAtMTRhNjAgNjAgMCAwMDIxLTE5IDUzIDUzIDAgMDA5LTI5YzAtMTYtOC0zMy0yMy01MWE0NyA0NyAwIDAwLTUtNWMtMjMtMjAtNDUtMjYtNjctMTgtMTIgNC0yMCA5LTI2IDE4em0xMDggNzZhNTAgNTAgMCAwMS0yMSAyMmMtMTcgOS0zMiAxMy00OCAxMy0xMSAwLTIxLTMtMzAtOS01LTMtOS05LTEzLTE2YTgxIDgxIDAgMDEtNi0zMiA5NCA5NCAwIDAxOC0zNSA5MCA5MCAwIDAxNi0xMmwxLTJjNS05IDEzLTEzIDIzLTE2IDE2LTUgMzItMyA1MCA5IDEzIDggMjMgMjAgMzAgMzYgNyAxNSA3IDI5IDAgNDJ6bS00My03M2MtMTctOC0zMy02LTQ2IDUtMTAgOC0xNiAyMC0xOSAzN2E1NCA1NCAwIDAwNSAzNGM3IDE1IDIwIDIzIDM3IDIyIDIyLTEgMzgtOSA0OC0yNGE0MSA0MSAwIDAwOC0yNCA0MyA0MyAwIDAwLTEtMTJjLTYtMTgtMTYtMzEtMzItMzh6bS0yMyA5MWgtMWMtNyAwLTE0LTItMjEtN2EyNyAyNyAwIDAxLTEwLTEzIDU3IDU3IDAgMDEtNC0yMCA2MyA2MyAwIDAxNi0yNWM1LTEyIDEyLTE5IDI0LTIxIDktMyAxOC0yIDI3IDIgMTQgNiAyMyAxOCAyNyAzM3MtMiAzMS0xNiA0MGMtMTEgOC0yMSAxMS0zMiAxMXptMS0zNHYxNGgtOFY2OGg4djI4bDEwLTEwaDExbC0xNCAxNSAxNyAxOEg5NnoiLz48L3N2Zz4K
9994
[license-link]: ./LICENSE
10095
[license-shield]: https://img.shields.io/github/license/pdsinterop/php-solid-auth.svg
101-
[maintained-shield]: https://img.shields.io/maintenance/yes/2020.svg
96+
[maintained-shield]: https://img.shields.io/maintenance/yes/2022.svg
10297
[pdsinterop-shield]: https://img.shields.io/badge/-PDS%20Interop-gray.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9Ii01IC01IDExMCAxMTAiIGZpbGw9IiNGRkYiIHN0cm9rZS13aWR0aD0iMCI+CiAgICA8cGF0aCBkPSJNLTEgNTJoMTdhMzcuNSAzNC41IDAgMDAyNS41IDMxLjE1di0xMy43NWEyMC43NSAyMSAwIDAxOC41LTQwLjI1IDIwLjc1IDIxIDAgMDE4LjUgNDAuMjV2MTMuNzVhMzcgMzQuNSAwIDAwMjUuNS0zMS4xNWgxN2EyMiAyMS4xNSAwIDAxLTEwMiAweiIvPgogICAgPHBhdGggZD0iTSAxMDEgNDhhMi43NyAyLjY3IDAgMDAtMTAyIDBoIDE3YTIuOTcgMi44IDAgMDE2OCAweiIvPgo8L3N2Zz4K
10398
[pdsinterop-site]: https://pdsinterop.org/
10499
[project-stage-badge: Development]: https://img.shields.io/badge/Project%20Stage-Development-yellowgreen.svg

_config.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ exclude:
1212
- "bin/"
1313
- "src/"
1414
- "tests/"
15+
- "vendor/"
16+
- "Gemfile"
1517
- "*.json"
1618
- "*.lock"
1719

1820
plugins:
1921
- github-pages
22+
- jekyll-github-metadata
23+
- jekyll-remote-theme
24+
- jekyll-seo-tag
2025

2126
# Extend the Docs settings (see https://pother.ca/extend-the-docs/)
2227
nav:
@@ -38,7 +43,7 @@ nav:
3843
aux_links:
3944
"PDS Interop on GitHub":
4045
- https://github.com/pdsinterop
41-
footer_content: Copyright © 2020 PDS Interop. Distributed under a <a href="https://pdsinterop.org/license/">MIT license.</a>
46+
footer_content: '<p xmlns:dct="http://purl.org/dc/terms/" property="dct:rights">Copyright © <span property="dct:dateCopyrighted">2020-2021</span> <span property="dct:publisher">PDS Interop</span>. Distributed under a <a rel="license" href="https://pdsinterop.org/license/">MIT license</a>.</p>'
4247
gh_edit_link: true
4348
gh_edit_repository: https://github.com/pdsinterop/php-solid-auth
4449
logo: https://avatars3.githubusercontent.com/u/65920341

composer.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,25 @@
1414
},
1515
"config": {
1616
"bin-dir": "./bin",
17-
"platform": {
18-
"php": "7.2",
19-
"ext-json": "1",
20-
"ext-mbstring": "1",
21-
"ext-openssl": "1"
22-
},
2317
"sort-packages": true
2418
},
2519
"description": "OAuth2, OpenID and OIDC for Solid Server implementations.",
2620
"license": "MIT",
2721
"name": "pdsinterop/solid-auth",
2822
"require": {
29-
"php": ">=7.2",
23+
"php": "^7.3",
3024
"ext-json": "*",
3125
"ext-mbstring": "*",
3226
"ext-openssl": "*",
27+
"laminas/laminas-diactoros": "^2.8",
28+
"lcobucci/jwt": "3.3.3",
3329
"league/oauth2-server": "^8.1",
3430
"web-token/jwt-core": "^2.2"
3531
},
3632
"require-dev": {
3733
"ext-xdebug": "*",
3834
"ext-xml": "*",
39-
"laminas/laminas-diactoros": "^2.3",
40-
"lcobucci/jwt": "^3.3",
41-
"phpunit/phpunit": "^8.5"
35+
"phpunit/phpunit": "^8.5 | ^9.5"
4236
},
4337
"scripts": {
4438
"tests:example": "php -S localhost:8080 -t ./tests/ ./tests/example.php",

src/Utils/DPop.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ private function validateDpop($dpop, $request) {
162162

163163
//error_log("8");
164164
// 8. the token was issued within an acceptable timeframe (see Section 9.1), and
165-
$validationData = new ValidationData(); // It will use the current time to validate (iat, nbf and exp)
165+
$leeway = 5; // allow 5 seconds clock skew
166+
$validationData = new ValidationData(time() + $leeway); // It will use the current time to validate (iat, nbf and exp)
166167
if (!$dpop->validate($validationData)) {
167168
throw new \Exception("token timing is invalid");
168169
}

src/WAC.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ public function isAllowed($request, $webId, $origin=false, $allowedOrigins=[]) {
5151
$uri = $request->getUri();
5252
$parentUri = $this->getParentUri($uri);
5353

54-
foreach ($requestedGrants as $requestedGrant) {
54+
// @FIXME: $origin can be anything at this point, null, string, array, bool
55+
// This causes trouble downstream where an unchecked `parse_url($origin)['host'];` occurs
56+
57+
foreach ($requestedGrants as $requestedGrant) {
5558
switch ($requestedGrant['type']) {
5659
case "resource":
5760
if ($this->isPublicGranted($requestedGrant['grants'], $uri)) {
@@ -93,9 +96,9 @@ private function checkGrants($requestedGrants, $uri, $grants) {
9396
}
9497
if (is_array($grants)) {
9598
foreach ($requestedGrants as $requestedGrant) {
96-
if ($grants['accessTo'] && $grants['accessTo'][$requestedGrant] && $this->arePathsEqual($grants['accessTo'][$requestedGrant], $uri)) {
99+
if (isset($grants['accessTo']) && isset($grants['accessTo'][$requestedGrant]) && $this->arePathsEqual($grants['accessTo'][$requestedGrant], $uri)) {
97100
return true;
98-
} else if ($grants['default'][$requestedGrant]) {
101+
} else if (isset($grants['default']) && isset($grants['default'][$requestedGrant])) {
99102
if ($this->arePathsEqual($grants['default'][$requestedGrant], $uri)) {
100103
return false; // only use default for children, not for an exact match;
101104
}
@@ -121,9 +124,14 @@ private function isUserGranted($requestedGrants, $uri, $webId) {
121124
}
122125

123126
private function isOriginGranted($requestedGrants, $uri, $origin, $allowedOrigins) {
127+
if (is_array($origin)) {
128+
$origin = reset($origin);
129+
}
130+
124131
if (!$origin) {
125132
return true;
126133
}
134+
127135
$parsedOrigin = parse_url($origin)['host'];
128136
if (
129137
in_array($parsedOrigin, $allowedOrigins, true) ||
@@ -298,6 +306,7 @@ private function getAclPath($path) {
298306
foreach ($aclOptions as $aclPath) {
299307
if (
300308
$this->filesystem->has($aclPath)
309+
&& $this->filesystem->read($aclPath) !== false
301310
) {
302311
return $aclPath;
303312
}
@@ -383,6 +392,10 @@ public function getRequestedGrants($request) {
383392
array(
384393
"type" => "resource",
385394
"grants" => array('http://www.w3.org/ns/auth/acl#Write')
395+
),
396+
array(
397+
"type" => "parent",
398+
"grants" => array('http://www.w3.org/ns/auth/acl#Write')
386399
)
387400
);
388401
break;
@@ -500,7 +513,12 @@ private function getParentUri($uri) {
500513
}
501514
private function getWACGrants($grants, $uri) {
502515
$wacGrants = array();
503-
516+
if (!isset($grants['accessTo'])) {
517+
$grants['accessTo'] = [];
518+
}
519+
if (!isset($grants['default'])) {
520+
$grants['default'] = [];
521+
}
504522
foreach ((array)$grants['accessTo'] as $grant => $grantedUri) {
505523
if ($this->arePathsEqual($grantedUri, $uri)) {
506524
$wacGrants[] = $this->grantToWac($grant);

0 commit comments

Comments
 (0)