Skip to content

Commit 367a325

Browse files
Squashed commit of the following:
commit 4a755fb Author: Alex Butler <[email protected]> Date: Mon Jul 11 18:07:53 2022 +0100 C#: Add path arg validation to Signer & Verifier (#73) * C#: Add path arg validation to Signer & Verifier * Update java & php ci rules * Update all ci lang filters * Keep java tags-ignore ci commit bc99945 Author: Marco Tormento <[email protected]> Date: Fri Jul 1 18:52:07 2022 +0200 Removed symlinks for license files (#72) commit 6c9b46c Author: Alessandro Zanin <[email protected]> Date: Thu Jun 30 09:58:42 2022 +0200 Path argument validation (#71) * Add path validation * Update changelog * Bump version commit acbbe1e Author: Alex Butler <[email protected]> Date: Wed Jun 29 13:43:17 2022 +0100 Release nodejs v0.1.3 commit ad8fe1f Author: Alex Butler <[email protected]> Date: Wed Jun 29 12:42:47 2022 +0100 nodejs: Add path validation (#70) commit 64d8701 Author: Alessandro Zanin <[email protected]> Date: Wed Jun 29 11:12:02 2022 +0200 Improve WebhookVerificationHandler (#68) commit eb0e40b Author: Alex Butler <[email protected]> Date: Tue Jun 21 10:48:20 2022 +0100 Update rust example dependencies (#67) commit 707cb79 Author: Stefan Danaita <[email protected]> Date: Thu May 5 09:27:03 2022 +0100 [PHP-32] Add support for signature verification using JWKS json (#58) * [PHP-32] Add support for signature verification using JWKS json * [PHP-32] Formatting * [PHP-32] PHPStan * [PHP-32] Changelog * [PHP-32] Readme * [PHP-32] Backfill changelog with v0.0.2 * [PHP-32] Backfill changelog with v0.0.1
1 parent ca946a6 commit 367a325

File tree

35 files changed

+533
-72
lines changed

35 files changed

+533
-72
lines changed

.github/workflows/csharp.yml

+2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ on:
55
branches: [ main ]
66
paths:
77
- 'csharp/**'
8+
- 'test-resources/**'
89
pull_request:
910
branches: [ main ]
1011
paths:
1112
- 'csharp/**'
13+
- 'test-resources/**'
1214

1315
jobs:
1416
test:

.github/workflows/go.yml

+2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ on:
55
branches: [ main ]
66
paths:
77
- 'go/**'
8+
- 'test-resources/**'
89
pull_request:
910
branches: [ main ]
1011
paths:
1112
- 'go/**'
13+
- 'test-resources/**'
1214

1315
jobs:
1416
lint:

.github/workflows/java.yml

+4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ on:
55
branches: [ main ]
66
paths:
77
- 'java/**'
8+
- 'test-resources/**'
9+
tags-ignore:
10+
- '**'
811
pull_request:
912
branches: [ main ]
1013
paths:
1114
- 'java/**'
15+
- 'test-resources/**'
1216

1317
jobs:
1418
build-and-test:

.github/workflows/node.yml

+2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ on:
55
branches: [ main ]
66
paths:
77
- 'nodejs/**'
8+
- 'test-resources/**'
89
pull_request:
910
branches: [ main ]
1011
paths:
1112
- 'nodejs/**'
13+
- 'test-resources/**'
1214

1315
jobs:
1416
test:

.github/workflows/php.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ name: PHP
33
on:
44
push:
55
branches: [ main ]
6+
tags:
7+
- "php/v**"
68
paths:
79
- 'php/**'
10+
- 'test-resources/**'
811
pull_request:
912
branches: [ main ]
1013
paths:
1114
- 'php/**'
15+
- 'test-resources/**'
1216

1317
jobs:
1418
test:
@@ -74,4 +78,4 @@ jobs:
7478
path: "php"
7579
deploy_key: ${{ secrets.DOWNSTREAM_GITHUB_DEPLOY_KEY }}
7680
branch: ${{ steps.tag-replacer.outputs.NEW_TAG }}
77-
force: true
81+
force: true

.github/workflows/rust.yml

+2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ on:
55
branches: [ main ]
66
paths:
77
- 'rust/**'
8+
- 'test-resources/**'
89
pull_request:
910
branches: [ main ]
1011
paths:
1112
- 'rust/**'
13+
- 'test-resources/**'
1214

1315
jobs:
1416
test:

csharp/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## 0.1.10
8+
* Add `path` arg validation to `Signer` & `Verifier` for more informative errors.
9+
710
## 0.1.9
811
* Fix key-dependant parameter length error for .NET Standard 2.0.
912

csharp/src/Signer.cs

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ public Signer Method(string method)
6060
/// </summary>
6161
public Signer Path(string path)
6262
{
63+
if (!path.StartsWith("/"))
64+
{
65+
throw new ArgumentException($"Invalid path \"{path}\" must start with '/'");
66+
}
6367
this.path = path;
6468
return this;
6569
}

csharp/src/Verifier.cs

+4
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ public Verifier Method(string method)
112112
/// </summary>
113113
public Verifier Path(string path)
114114
{
115+
if (!path.StartsWith("/"))
116+
{
117+
throw new ArgumentException($"Invalid path \"{path}\" must start with '/'");
118+
}
115119
this.path = path;
116120
return this;
117121
}

csharp/src/truelayer-signing.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<PackageVersion>0.1.9</PackageVersion>
3+
<PackageVersion>0.1.10</PackageVersion>
44
<TargetFrameworks>net5.0;netstandard2.0;netstandard2.1</TargetFrameworks>
55
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
66
<Nullable>enable</Nullable>

csharp/test/ErrorTest.cs

+20
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,25 @@ string CreateSignature(Dictionary<string, string> jwsHeaderMap)
129129

130130
verify.Should().Throw<SignatureException>();
131131
}
132+
133+
[Fact]
134+
public void InvalidSignerPath()
135+
{
136+
Action sign = () => Signer.SignWithPem(Kid, PrivateKey)
137+
.Path("https://example.com/the-path");
138+
139+
sign.Should().Throw<ArgumentException>()
140+
.WithMessage("Invalid path \"https://example.com/the-path\" must start with '/'");
141+
}
142+
143+
[Fact]
144+
public void InvalidVerifierPath()
145+
{
146+
Action verify = () => Verifier.VerifyWithPem(PublicKey)
147+
.Path("https://example.com/the-path");
148+
149+
verify.Should().Throw<ArgumentException>()
150+
.WithMessage("Invalid path \"https://example.com/the-path\" must start with '/'");
151+
}
132152
}
133153
}

go/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## Unreleased
88
* Fixed README example
9+
* Removed license symlinks
910

1011
## 0.1.4
1112
* Added `Headers` method to `Signer` and `Verifier`

go/LICENSE-APACHE

-1
This file was deleted.

go/LICENSE-APACHE

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
Apache License
2+
Version 2.0, January 2004
3+
http://www.apache.org/licenses/
4+
5+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6+
7+
1. Definitions.
8+
9+
"License" shall mean the terms and conditions for use, reproduction,
10+
and distribution as defined by Sections 1 through 9 of this document.
11+
12+
"Licensor" shall mean the copyright owner or entity authorized by
13+
the copyright owner that is granting the License.
14+
15+
"Legal Entity" shall mean the union of the acting entity and all
16+
other entities that control, are controlled by, or are under common
17+
control with that entity. For the purposes of this definition,
18+
"control" means (i) the power, direct or indirect, to cause the
19+
direction or management of such entity, whether by contract or
20+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
21+
outstanding shares, or (iii) beneficial ownership of such entity.
22+
23+
"You" (or "Your") shall mean an individual or Legal Entity
24+
exercising permissions granted by this License.
25+
26+
"Source" form shall mean the preferred form for making modifications,
27+
including but not limited to software source code, documentation
28+
source, and configuration files.
29+
30+
"Object" form shall mean any form resulting from mechanical
31+
transformation or translation of a Source form, including but
32+
not limited to compiled object code, generated documentation,
33+
and conversions to other media types.
34+
35+
"Work" shall mean the work of authorship, whether in Source or
36+
Object form, made available under the License, as indicated by a
37+
copyright notice that is included in or attached to the work
38+
(an example is provided in the Appendix below).
39+
40+
"Derivative Works" shall mean any work, whether in Source or Object
41+
form, that is based on (or derived from) the Work and for which the
42+
editorial revisions, annotations, elaborations, or other modifications
43+
represent, as a whole, an original work of authorship. For the purposes
44+
of this License, Derivative Works shall not include works that remain
45+
separable from, or merely link (or bind by name) to the interfaces of,
46+
the Work and Derivative Works thereof.
47+
48+
"Contribution" shall mean any work of authorship, including
49+
the original version of the Work and any modifications or additions
50+
to that Work or Derivative Works thereof, that is intentionally
51+
submitted to Licensor for inclusion in the Work by the copyright owner
52+
or by an individual or Legal Entity authorized to submit on behalf of
53+
the copyright owner. For the purposes of this definition, "submitted"
54+
means any form of electronic, verbal, or written communication sent
55+
to the Licensor or its representatives, including but not limited to
56+
communication on electronic mailing lists, source code control systems,
57+
and issue tracking systems that are managed by, or on behalf of, the
58+
Licensor for the purpose of discussing and improving the Work, but
59+
excluding communication that is conspicuously marked or otherwise
60+
designated in writing by the copyright owner as "Not a Contribution."
61+
62+
"Contributor" shall mean Licensor and any individual or Legal Entity
63+
on behalf of whom a Contribution has been received by Licensor and
64+
subsequently incorporated within the Work.
65+
66+
2. Grant of Copyright License. Subject to the terms and conditions of
67+
this License, each Contributor hereby grants to You a perpetual,
68+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69+
copyright license to reproduce, prepare Derivative Works of,
70+
publicly display, publicly perform, sublicense, and distribute the
71+
Work and such Derivative Works in Source or Object form.
72+
73+
3. Grant of Patent License. Subject to the terms and conditions of
74+
this License, each Contributor hereby grants to You a perpetual,
75+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76+
(except as stated in this section) patent license to make, have made,
77+
use, offer to sell, sell, import, and otherwise transfer the Work,
78+
where such license applies only to those patent claims licensable
79+
by such Contributor that are necessarily infringed by their
80+
Contribution(s) alone or by combination of their Contribution(s)
81+
with the Work to which such Contribution(s) was submitted. If You
82+
institute patent litigation against any entity (including a
83+
cross-claim or counterclaim in a lawsuit) alleging that the Work
84+
or a Contribution incorporated within the Work constitutes direct
85+
or contributory patent infringement, then any patent licenses
86+
granted to You under this License for that Work shall terminate
87+
as of the date such litigation is filed.
88+
89+
4. Redistribution. You may reproduce and distribute copies of the
90+
Work or Derivative Works thereof in any medium, with or without
91+
modifications, and in Source or Object form, provided that You
92+
meet the following conditions:
93+
94+
(a) You must give any other recipients of the Work or
95+
Derivative Works a copy of this License; and
96+
97+
(b) You must cause any modified files to carry prominent notices
98+
stating that You changed the files; and
99+
100+
(c) You must retain, in the Source form of any Derivative Works
101+
that You distribute, all copyright, patent, trademark, and
102+
attribution notices from the Source form of the Work,
103+
excluding those notices that do not pertain to any part of
104+
the Derivative Works; and
105+
106+
(d) If the Work includes a "NOTICE" text file as part of its
107+
distribution, then any Derivative Works that You distribute must
108+
include a readable copy of the attribution notices contained
109+
within such NOTICE file, excluding those notices that do not
110+
pertain to any part of the Derivative Works, in at least one
111+
of the following places: within a NOTICE text file distributed
112+
as part of the Derivative Works; within the Source form or
113+
documentation, if provided along with the Derivative Works; or,
114+
within a display generated by the Derivative Works, if and
115+
wherever such third-party notices normally appear. The contents
116+
of the NOTICE file are for informational purposes only and
117+
do not modify the License. You may add Your own attribution
118+
notices within Derivative Works that You distribute, alongside
119+
or as an addendum to the NOTICE text from the Work, provided
120+
that such additional attribution notices cannot be construed
121+
as modifying the License.
122+
123+
You may add Your own copyright statement to Your modifications and
124+
may provide additional or different license terms and conditions
125+
for use, reproduction, or distribution of Your modifications, or
126+
for any such Derivative Works as a whole, provided Your use,
127+
reproduction, and distribution of the Work otherwise complies with
128+
the conditions stated in this License.
129+
130+
5. Submission of Contributions. Unless You explicitly state otherwise,
131+
any Contribution intentionally submitted for inclusion in the Work
132+
by You to the Licensor shall be under the terms and conditions of
133+
this License, without any additional terms or conditions.
134+
Notwithstanding the above, nothing herein shall supersede or modify
135+
the terms of any separate license agreement you may have executed
136+
with Licensor regarding such Contributions.
137+
138+
6. Trademarks. This License does not grant permission to use the trade
139+
names, trademarks, service marks, or product names of the Licensor,
140+
except as required for reasonable and customary use in describing the
141+
origin of the Work and reproducing the content of the NOTICE file.
142+
143+
7. Disclaimer of Warranty. Unless required by applicable law or
144+
agreed to in writing, Licensor provides the Work (and each
145+
Contributor provides its Contributions) on an "AS IS" BASIS,
146+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147+
implied, including, without limitation, any warranties or conditions
148+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149+
PARTICULAR PURPOSE. You are solely responsible for determining the
150+
appropriateness of using or redistributing the Work and assume any
151+
risks associated with Your exercise of permissions under this License.
152+
153+
8. Limitation of Liability. In no event and under no legal theory,
154+
whether in tort (including negligence), contract, or otherwise,
155+
unless required by applicable law (such as deliberate and grossly
156+
negligent acts) or agreed to in writing, shall any Contributor be
157+
liable to You for damages, including any direct, indirect, special,
158+
incidental, or consequential damages of any character arising as a
159+
result of this License or out of the use or inability to use the
160+
Work (including but not limited to damages for loss of goodwill,
161+
work stoppage, computer failure or malfunction, or any and all
162+
other commercial damages or losses), even if such Contributor
163+
has been advised of the possibility of such damages.
164+
165+
9. Accepting Warranty or Additional Liability. While redistributing
166+
the Work or Derivative Works thereof, You may choose to offer,
167+
and charge a fee for, acceptance of support, warranty, indemnity,
168+
or other liability obligations and/or rights consistent with this
169+
License. However, in accepting such obligations, You may act only
170+
on Your own behalf and on Your sole responsibility, not on behalf
171+
of any other Contributor, and only if You agree to indemnify,
172+
defend, and hold each Contributor harmless for any liability
173+
incurred by, or claims asserted against, such Contributor by reason
174+
of your accepting any such warranty or additional liability.
175+
176+
END OF TERMS AND CONDITIONS

go/LICENSE-MIT

-1
This file was deleted.

go/LICENSE-MIT

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 TrueLayer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

java/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## 0.2.1
8+
* Add `path` arg validation to `Signer.sign` & `Verifier.verify` for more informative errors.
9+
710
## 0.2.0
811
* Move code under `com.truelayer.signing`.
912
* Publish artifacts to maven central

java/examples/webhook-server/src/main/java/com/truelayer/signing/examples/webhook_server/WebhookVerificationHandler.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public void handle(@NotNull Context ctx) throws Exception {
3636
}
3737

3838
// fetch jwks (should cache this according to headers)
39+
// http GET request to jku url
3940
try (Response response = httpClient.newCall(new Request.Builder().url(jku).build()).execute()) {
4041
if (response.code() == 200) {
4142
ResponseBody body = response.body();
@@ -52,9 +53,10 @@ public void handle(@NotNull Context ctx) throws Exception {
5253
.path(ctx.path())
5354
.method("POST")
5455
.verify(tlSignature);
56+
57+
ctx.status(202);
5558
} else
5659
ctx.status(401);
5760
}
58-
ctx.status(202);
5961
}
6062
}

0 commit comments

Comments
 (0)