├── .github
└── ISSUE_TEMPLATE
│ └── feature_request.md
├── .gitignore
├── .vscode
├── settings.json
└── tasks.json
├── CODE_OF_CONDUCT.md
├── LICENSE
├── PSJwt.build.ps1
├── PSJwt.psd1
├── PSJwt.psm1
├── README.md
├── RequiredModules.psd1
├── azure-pipelines.yml
├── bootstrap.ps1
├── docs
├── ConvertFrom-JWT.md
└── ConvertTo-JWT.md
├── en-US
└── PSJwt-help.xml
├── lib
├── Newtonsoft
│ ├── net45
│ │ ├── Newtonsoft.Json.dll
│ │ └── Newtonsoft.Json.xml
│ └── netstandard1.0
│ │ ├── Newtonsoft.Json.dll
│ │ └── Newtonsoft.Json.xml
└── jwt
│ ├── net46
│ ├── JWT.dll
│ ├── JWT.pdb
│ └── JWT.xml
│ └── netstandard2.0
│ ├── JWT.dll
│ ├── JWT.pdb
│ └── JWT.xml
├── public
├── ConvertFrom-JWT.ps1
└── ConvertTo-JWT.ps1
└── tests
└── PSJwt.tests.ps1
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: stefanstranger
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | output/*
2 | .vscode/settings.json
3 | test.ps1
4 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "workbench.colorTheme": "Visual Studio Dark",
3 | "editor.formatOnSave": true,
4 | "editor.formatOnType": true,
5 | "extensions.ignoreRecommendations": false,
6 | "terminal.integrated.shell.windows": "C:\\WINDOWS\\Sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
7 | // The default language mode that is assigned to new files.
8 | "files.defaultLanguage": "powershell",
9 | "[shellscript]": {},
10 | "explorer.confirmDelete": false,
11 | "git.autofetch": true,
12 | "window.zoomLevel": -1,
13 | // Define paired characters and their shared color group
14 | "bracketPairColorizer.consecutivePairColors": [
15 | "()",
16 | "[]",
17 | "{}",
18 | [
19 | "Orange",
20 | "Orchid",
21 | "LightSkyBlue"
22 | ],
23 | "Red"
24 | ],
25 | "git.enableSmartCommit": true,
26 | "workbench.sideBar.location": "right",
27 | "explorer.confirmDragAndDrop": false,
28 | "files.associations": {
29 | "*.sh": "shellscript"
30 | },
31 | "powershell.powerShellExePath": "C:\\WINDOWS\\Sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
32 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | // Do not edit! This file is generated by New-VSCodeTask.ps1
2 | // Modify the build script instead and regenerate this file.
3 | {
4 | "version": "2.0.0",
5 | "windows": {
6 | "options": {
7 | "shell": {
8 | "executable": "powershell.exe",
9 | "args": [ "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command" ]
10 | }
11 | }
12 | },
13 | "linux": {
14 | "options": {
15 | "shell": {
16 | "executable": "/usr/bin/pwsh",
17 | "args": [ "-NoProfile", "-Command" ]
18 | }
19 | }
20 | },
21 | "osx": {
22 | "options": {
23 | "shell": {
24 | "executable": "/usr/local/bin/pwsh",
25 | "args": [ "-NoProfile", "-Command" ]
26 | }
27 | }
28 | },
29 | "tasks": [
30 | {
31 | "label": "UpdateHelp",
32 | "type": "shell",
33 | "problemMatcher": [ "$msCompile" ],
34 | "command": "Invoke-Build -Task UpdateHelp"
35 | },
36 | {
37 | "label": "GetLatestJWTPackage",
38 | "type": "shell",
39 | "problemMatcher": [ "$msCompile" ],
40 | "command": "Invoke-Build -Task GetLatestJWTPackage"
41 | },
42 | {
43 | "label": "UpdateJWTPackage",
44 | "type": "shell",
45 | "problemMatcher": [ "$msCompile" ],
46 | "command": "Invoke-Build -Task UpdateJWTPackage"
47 | },
48 | {
49 | "label": "CopyModuleFiles",
50 | "type": "shell",
51 | "problemMatcher": [ "$msCompile" ],
52 | "command": "Invoke-Build -Task CopyModuleFiles"
53 | },
54 | {
55 | "label": "Test",
56 | "type": "shell",
57 | "problemMatcher": [ "$msCompile" ],
58 | "command": "Invoke-Build -Task Test"
59 | },
60 | {
61 | "label": "UpdateManifest",
62 | "type": "shell",
63 | "problemMatcher": [ "$msCompile" ],
64 | "command": "Invoke-Build -Task UpdateManifest"
65 | },
66 | {
67 | "label": "PublishModule",
68 | "type": "shell",
69 | "problemMatcher": [ "$msCompile" ],
70 | "command": "Invoke-Build -Task PublishModule"
71 | },
72 | {
73 | "label": "Clean",
74 | "type": "shell",
75 | "problemMatcher": [ "$msCompile" ],
76 | "command": "Invoke-Build -Task Clean"
77 | },
78 | {
79 | "label": ".",
80 | "type": "shell",
81 | "problemMatcher": [ "$msCompile" ],
82 | "group": {
83 | "kind": "build",
84 | "isDefault": true
85 | },
86 | "command": "Invoke-Build -Task ."
87 | },
88 | {
89 | "label": "?",
90 | "type": "shell",
91 | "problemMatcher": [],
92 | "command": "Invoke-Build -Task ?"
93 | }
94 | ]
95 | }
96 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at stefan@stranger.nl. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
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
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/PSJwt.build.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .Synopsis
3 | Build script (https://github.com/nightroman/Invoke-Build)
4 | #>
5 |
6 | param ($Configuration = 'Development')
7 |
8 | #region use the most strict mode
9 | Set-StrictMode -Version Latest
10 | #endregion
11 |
12 | #region Task to Update the PowerShell Module Help Files.
13 | # Pre-requisites: PowerShell Module PlatyPS.
14 | task UpdateHelp {
15 | Import-Module .\PSJwt.psd1 -Force
16 | Update-MarkdownHelp .\docs
17 | New-ExternalHelp -Path .\docs -OutputPath .\en-US -Force
18 | }
19 | #endregion
20 |
21 | #region Task to retrieve latest version of JWT Packages
22 | # More info: https://www.nuget.org/packages/JWT
23 | task GetLatestJWTPackage {
24 | & nuget list JWT | Where-Object { $_ -match '^JWT.\d.\d.\d' }
25 | }
26 | #endregion
27 |
28 | #region Task to Update JWT Package if newer version is released
29 | task UpdateJWTPackage {
30 | # Check current JWT Package version
31 | # Get jwt.dll file properties
32 | $File = Get-ChildItem -Path .\lib\ -Filter jwt.dll -Recurse | Select-Object -First 1
33 | [Version]$ProductVersion = $File.VersionInfo.ProductVersionRaw
34 | Write-Output -InputObject ('ProductVersion for jwt {0}' -f $ProductVersion)
35 |
36 | # Check latest version JWTPackage
37 | [Version]$LatestVersion = ((& nuget list JWT | Where-Object { $_ -match '^JWT.\d.\d.\d' }).split(' '))[1]
38 | Write-Output -InputObject ('Latest Version for jwt {0}' -f $LatestVersion)
39 |
40 | #Download latest version when newer
41 | If ($LatestVersion -gt $ProductVersion) {
42 | Write-Output -InputObject ('Newer version {0} available' -f $LatestVersion)
43 | #Install jwt package to temp folder
44 | nuget install JWT -OutputDirectory ([IO.Path]::GetTempPath())
45 |
46 | Write-Output -InputObject ('Copy JWT binaries to PSJwt Module')
47 | $libpath = Resolve-Path -Path ("$([IO.Path]::GetTempPath())" + ('*jwt.{0}\lib*' -f $($LatestVersion.ToString())))
48 | Copy-Item -Path ($($libpath.path) + '\*') -Destination .\lib\jwt -Recurse -Force
49 |
50 | Write-Output -InputObject ('Copy Newtonsoft binaries to PSJwt Module')
51 | $libpath = Resolve-Path -Path ("$([IO.Path]::GetTempPath())" + "*newtonsoft*\lib*")
52 | $libpathnewtonsoftstandard = $libpath | Get-ChildItem -Filter netstandard* | Sort-Object -Property Name -Descending | Select-Object -First 1
53 | Copy-Item -Path ($($libpathnewtonsoftstandard.FullName) + '\*') -include *.xml, *.dll -Destination (".\lib\Newtonsoft\$($libpathnewtonsoftstandard.name)") -Force
54 |
55 | $libpathnewtonsoftnet = $libpath | Get-ChildItem -Filter net* | Sort-Object -Property Name -Descending | Select-Object -First 1
56 | Copy-Item -Path ($($libpathnewtonsoftnet.FullName) + '\*') -include *.xml, *.dll -Destination (".\lib\Newtonsoft\$($libpathnewtonsoftnet.name)") -Force
57 |
58 | #remove older version of dot net
59 | $jwtdotnetfolders = ((Get-ChildItem -Path .\lib\jwt) -match 'net[0-9][0-9]*')
60 | $jwtdotnetfolders[0.. ($jwtdotnetfolders.Length - 2)].FullName | Remove-item -Recurse -Force
61 |
62 | #remove older version of dot net standard
63 | $jwtdotnetstandardfolders = ((Get-ChildItem -Path .\lib\jwt) -match 'netstandard[0-9].[0-9]*')
64 | $jwtdotnetstandardfolders[0.. ($jwtdotnetstandardfolders.Length - 2)].FullName | Remove-item -Recurse
65 | }
66 | else {
67 | Write-Output -InputObject ('Current local version {0}. Latest version {1}. No need to update JWT Library.' -f $ProductVersion, $LatestVersion)
68 | }
69 | }
70 | #endregion
71 |
72 | #region Task to Copy PowerShell Module files to output folder for release as Module
73 | task CopyModuleFiles {
74 |
75 | # Copy Module Files to Output Folder
76 | if (-not (Test-Path .\output\PSJwt)) {
77 |
78 | $null = New-Item -Path .\output\PSJwt -ItemType Directory
79 |
80 | }
81 |
82 | Copy-Item -Path '.\en-US\' -Filter *.* -Recurse -Destination .\output\PSJwt -Force
83 | Copy-Item -Path '.\lib\' -Filter *.* -Recurse -Destination .\output\PSJwt -Force
84 | Copy-Item -Path '.\public\' -Filter *.* -Recurse -Destination .\output\PSJwt -Force
85 | Copy-Item -Path '.\tests\' -Filter *.* -Recurse -Destination .\output\PSJwt -Force
86 |
87 | #Copy Module Manifest files
88 | Copy-Item -Path @(
89 | '.\README.md'
90 | '.\PSJwt.psd1'
91 | '.\PSJwt.psm1'
92 | ) -Destination .\output\PSJwt -Force
93 | }
94 | #endregion
95 |
96 | #region Task to run all Pester tests in folder .\tests
97 | task Test {
98 | $Result = Invoke-Pester .\tests -PassThru
99 | if ($Result.FailedCount -gt 0) {
100 | throw 'Pester tests failed'
101 | }
102 |
103 | }
104 | #endregion
105 |
106 | #region Task to update the Module Manifest file with info from the Changelog in Readme.
107 | task UpdateManifest {
108 | # Import PlatyPS. Needed for parsing README for Change Log versions
109 | Import-Module -Name PlatyPS
110 |
111 | # Find Latest Version in README file from Change log.
112 | $README = Get-Content -Path .\README.md
113 | $MarkdownObject = [Markdown.MAML.Parser.MarkdownParser]::new()
114 | [regex]$regex = '\d\.\d\.\d'
115 | $Versions = $regex.Matches($MarkdownObject.ParseString($README).Children.Spans.Text) | foreach-object { $_.value }
116 | ($Versions | Measure-Object -Maximum).Maximum
117 |
118 | $manifestPath = '.\PSJwt.psd1'
119 |
120 | # Start by importing the manifest to determine the version, then add 1 to the Build
121 | $manifest = Test-ModuleManifest -Path $manifestPath
122 | [System.Version]$version = $manifest.Version
123 | [String]$newVersion = New-Object -TypeName System.Version -ArgumentList ($version.Major, $version.Minor, ($version.Build + 1))
124 | Write-Output -InputObject ('New Module version: {0}' -f $newVersion)
125 |
126 | # Update Manifest file with Release Notes
127 | $README = Get-Content -Path .\README.md
128 | $MarkdownObject = [Markdown.MAML.Parser.MarkdownParser]::new()
129 | $ReleaseNotes = ((($MarkdownObject.ParseString($README).Children.Spans.Text) -match '\d\.\d\.\d') -split ' - ')[1]
130 |
131 | #Update Module with new version
132 | Update-ModuleManifest -ModuleVersion $newVersion -Path .\PSJwt.psd1 -ReleaseNotes $ReleaseNotes
133 | }
134 | #endregion
135 |
136 | #region Task to Publish Module to PowerShell Gallery
137 | task PublishModule -If ($Configuration -eq 'Production') {
138 | Try {
139 | # Build a splat containing the required details and make sure to Stop for errors which will trigger the catch
140 | $params = @{
141 | Path = ('{0}\Output\PSJwt' -f $PSScriptRoot )
142 | NuGetApiKey = $env:psgallery
143 | ErrorAction = 'Stop'
144 | }
145 | Publish-Module @params
146 | Write-Output -InputObject ('PSJwt PowerShell Module version published to the PowerShell Gallery')
147 | }
148 | Catch {
149 | throw $_
150 | }
151 | }
152 | #endregion
153 |
154 | #region Task clean up Output folder
155 | task Clean {
156 | # Clean output folder
157 | if ((Test-Path .\output)) {
158 |
159 | Remove-Item -Path .\Output -Recurse -Force
160 |
161 | }
162 | }
163 | #endregion
164 |
165 | #region Default Task. Runs Clean, Test, CopyModuleFiles Tasks
166 | task . Clean, Test, CopyModuleFiles, PublishModule
167 | #endregion
--------------------------------------------------------------------------------
/PSJwt.psd1:
--------------------------------------------------------------------------------
1 | #
2 | # Module manifest for module 'PSGet_PSJwt'
3 | #
4 | # Generated by: Stefan Stranger
5 | #
6 | # Generated on: 31-12-2018
7 | #
8 |
9 | @{
10 |
11 | # Script module or binary module file associated with this manifest.
12 | RootModule = 'PSJwt.psm1'
13 |
14 | # Version number of this module.
15 | ModuleVersion = '1.0.5'
16 |
17 | # Supported PSEditions
18 | # CompatiblePSEditions = @()
19 |
20 | # ID used to uniquely identify this module
21 | GUID = '6934ef7a-f360-4d10-8e61-471823ec44c1'
22 |
23 | # Author of this module
24 | Author = 'Stefan Stranger'
25 |
26 | # Company or vendor of this module
27 | CompanyName = 'Stefan Stranger'
28 |
29 | # Copyright statement for this module
30 | Copyright = '(c) 2018 Stefan Stranger. All rights reserved.'
31 |
32 | # Description of the functionality provided by this module
33 | Description = 'JWT (JSON Web Token) PowerShell Module'
34 |
35 | # Minimum version of the Windows PowerShell engine required by this module
36 | # PowerShellVersion = ''
37 |
38 | # Name of the Windows PowerShell host required by this module
39 | # PowerShellHostName = ''
40 |
41 | # Minimum version of the Windows PowerShell host required by this module
42 | # PowerShellHostVersion = ''
43 |
44 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45 | # DotNetFrameworkVersion = ''
46 |
47 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48 | # CLRVersion = ''
49 |
50 | # Processor architecture (None, X86, Amd64) required by this module
51 | # ProcessorArchitecture = ''
52 |
53 | # Modules that must be imported into the global environment prior to importing this module
54 | # RequiredModules = @()
55 |
56 | # Assemblies that must be loaded prior to importing this module
57 | # RequiredAssemblies = @()
58 |
59 | # Script files (.ps1) that are run in the caller's environment prior to importing this module.
60 | # ScriptsToProcess = @()
61 |
62 | # Type files (.ps1xml) to be loaded when importing this module
63 | # TypesToProcess = @()
64 |
65 | # Format files (.ps1xml) to be loaded when importing this module
66 | # FormatsToProcess = @()
67 |
68 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
69 | # NestedModules = @()
70 |
71 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
72 | FunctionsToExport = 'ConvertFrom-JWT', 'ConvertTo-JWT'
73 |
74 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
75 | CmdletsToExport = '*'
76 |
77 | # Variables to export from this module
78 | VariablesToExport = '*'
79 |
80 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
81 | AliasesToExport = '*'
82 |
83 | # DSC resources to export from this module
84 | # DscResourcesToExport = @()
85 |
86 | # List of all modules packaged with this module
87 | # ModuleList = @()
88 |
89 | # List of all files packaged with this module
90 | # FileList = @()
91 |
92 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
93 | PrivateData = @{
94 |
95 | PSData = @{
96 |
97 | # Tags applied to this module. These help with module discovery in online galleries.
98 | Tags = 'JWT', 'JSON', 'Decode', 'Encode'
99 |
100 | # A URL to the license for this module.
101 | LicenseUri = 'http://opensource.org/licenses/MIT'
102 |
103 | # A URL to the main website for this project.
104 | ProjectUri = 'https://github.com/stefanstranger/PSJwt'
105 |
106 | # A URL to an icon representing this module.
107 | # IconUri = ''
108 |
109 | # ReleaseNotes of this module
110 | ReleaseNotes = 'Fixed typo for extra help info added in version 1.0.4'
111 |
112 | # Prerelease string of this module
113 | # Prerelease = 'alpha'
114 |
115 | # Flag to indicate whether the module requires explicit user acceptance for install/update
116 | # RequireLicenseAcceptance = $false
117 |
118 | # External dependent modules of this module
119 | # ExternalModuleDependencies = @()
120 |
121 | } # End of PSData hashtable
122 |
123 | } # End of PrivateData hashtable
124 |
125 | # HelpInfo URI of this module
126 | # HelpInfoURI = ''
127 |
128 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
129 | # DefaultCommandPrefix = ''
130 |
131 | }
132 |
133 |
--------------------------------------------------------------------------------
/PSJwt.psm1:
--------------------------------------------------------------------------------
1 | if ($PSEdition -eq "Core") {
2 | Import-Module -Name "$PSScriptRoot/lib/jwt/netstandard2.0/JWT.dll" | Out-Null
3 | Import-Module -Name "$PSScriptRoot/lib/Newtonsoft/netstandard1.0/Newtonsoft.Json.dll" | Out-Null
4 | }
5 | else {
6 | Import-Module -Name "$PSScriptRoot/lib/jwt/net46/JWT.dll" | Out-Null
7 | Import-Module -Name "$PSScriptRoot/lib/Newtonsoft/net45/Newtonsoft.Json.dll" | Out-Null
8 | }
9 |
10 | #Get public and private function definition files.
11 | $Public = @( Get-ChildItem -Path $PSScriptRoot\public\*.ps1 -ErrorAction SilentlyContinue )
12 | $Private = @( Get-ChildItem -Path $PSScriptRoot\private\*.ps1 -ErrorAction SilentlyContinue )
13 |
14 | #Dot source the files
15 | Foreach ($import in @($Public + $Private)) {
16 | Try {
17 | . $import.fullname
18 | }
19 | Catch {
20 | Write-Error -Message "Failed to import function $($import.fullname): $_"
21 | }
22 | }
23 |
24 |
25 | Export-ModuleMember -Function $Public.Basename
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # psjwt
2 |
3 | PowerShell Module for JWT (JSON Web Tokens)
4 |
5 | # Installation
6 |
7 | You can install the PowerShell module using the PowerShell Gallery.
8 |
9 | ```PowerShell
10 | Install-Module -Name psjwt
11 | ```
12 |
13 | # Library
14 |
15 | The PowerShell Module is using the Jwt.Net library.
16 |
17 | This library supports generating and decoding JSON Web Tokens.
19 |
20 | # JSON Web Tokens
21 |
22 | From Wikipedia:
23 |
24 | JSON Web Token (JWT) is a JSON-based open standard (RFC 7519) for creating access tokens that assert some number of claims. For example, a server could generate a token that has the claim "logged in as admin" and provide that to a client. The client could then use that token to prove that it is logged in as admin. The tokens are signed by one party's private key (usually the server's), so that both parties (the other already being, by some suitable and trustworthy means, in possession of the corresponding public key) are able to verify that the token is legitimate. The tokens are designed to be compact, URL-safe, and usable especially in a web-browser single-sign-on (SSO) context. JWT claims can be typically used to pass identity of authenticated users between an identity provider and a service provider, or any other type of claims as required by business processes.
25 | JWT relies on other JSON-based standards: JWS (JSON Web Signature) RFC 7515 and JWE (JSON Web Encryption) RFC 7516
26 |
27 | # Change log
28 |
29 | * 16-05-2020
30 |
31 | Version 1.0.5 - Fixed typo for extra help info added in version 1.0.4
32 |
33 | * 16-05-2020
34 |
35 | Version 1.0.4 - Updated JWT Library to version 7.2.0
36 | - Extra help info added for ConvertFrom-JWT function
37 |
38 | * 10-05-2020
39 |
40 | Version 1.0.3 - Updated help files
41 |
42 | * 10-05-2020
43 |
44 | Version 1.0.2 - Updated JWT library to 7.1.0
45 | - Added support for extra header info
46 |
47 | * 05-05-2020:
48 |
49 | Version 1.0.1 - Updated JWT package to latest version.
50 |
51 | * 31-12-2018:
52 |
53 | Version 1.0.0 - Changed from Pre-release version to Release version.
54 |
55 | * 27-12-2018:
56 |
57 | Version 0.0.4 - Updated Build tasks
58 |
59 | * 25-12-2018:
60 |
61 | Version 0.0.3 - Created Alpha version
62 |
63 | * 25-11-2018:
64 |
65 | Version 0.0.2 - Function ConvertTo-JWT added
66 |
67 | * 24-11-2018:
68 |
69 | Version 0.0.1 - Function ConvertFrom-JWT added
70 |
--------------------------------------------------------------------------------
/RequiredModules.psd1:
--------------------------------------------------------------------------------
1 | @(
2 | @{ ModuleName = "InvokeBuild"; RequiredVersion = "5.5.11" }
3 | @{ ModuleName = "Pester"; RequiredVersion = "4.10.1" }
4 | @{ ModuleName = "PlatyPS"; RequiredVersion = "0.14.0" }
5 | )
--------------------------------------------------------------------------------
/azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | # Docs: https://aka.ms/yaml
2 | name: $(Build.DefinitionName)_$(Date:yyyyMMdd))
3 | pr:
4 | - master
5 |
6 | queue:
7 | name: Hosted VS2017
8 |
9 | steps:
10 | - powershell: .\bootstrap.ps1
11 | displayName: 'Install pre-requisites'
12 |
13 | - task: richardfennellBM.BM-VSTS-PesterRunner-Task.Pester-Task.Pester@8
14 | displayName: 'Pester Test Runner'
15 | inputs:
16 | scriptFolder: '$(System.DefaultWorkingDirectory)\tests\*'
17 | additionalModulePath: '$(Build.ArtifactStagingDirectory)'
18 | resultsFile: '$(Common.TestResultsDirectory)\Test-$(Build.DefinitionName)_$(Build.BuildNumber).xml'
19 |
20 |
21 | - task: PublishTestResults@2
22 | displayName: 'Publish Test Results'
23 | condition: always()
24 | inputs:
25 | testRunner: NUnit
26 | searchFolder: '$(Common.TestResultsDirectory)'
27 |
28 | - powershell: Invoke-Build -Configuration 'Production' -Task Clean, CopyModuleFiles, PublishModule
29 | displayName: 'Publish PowerShell Module'
30 | env:
31 | psgallery: $(NugetAPIKey)
--------------------------------------------------------------------------------
/bootstrap.ps1:
--------------------------------------------------------------------------------
1 | using namespace Microsoft.PowerShell.Commands
2 | [CmdletBinding()]
3 | param(
4 | #
5 | [ValidateSet("CurrentUser", "AllUsers")]
6 | $Scope = "CurrentUser"
7 | )
8 | [ModuleSpecification[]]$RequiredModules = Import-LocalizedData -BaseDirectory $PSScriptRoot -FileName RequiredModules
9 | $Policy = (Get-PSRepository PSGallery).InstallationPolicy
10 | Set-PSRepository PSGallery -InstallationPolicy Trusted
11 | try {
12 | $RequiredModules | Install-Module -Scope $Scope -Repository PSGallery -SkipPublisherCheck -Verbose
13 | }
14 | finally {
15 | Set-PSRepository PSGallery -InstallationPolicy $Policy
16 | }
17 | $RequiredModules | Import-Module
--------------------------------------------------------------------------------
/docs/ConvertFrom-JWT.md:
--------------------------------------------------------------------------------
1 | ---
2 | external help file: PSJwt-help.xml
3 | Module Name: PSJwt
4 | online version:
5 | schema: 2.0.0
6 | ---
7 |
8 | # ConvertFrom-JWT
9 |
10 | ## SYNOPSIS
11 | Parsing (decoding) and verifying JSON Web Token
12 |
13 | ## SYNTAX
14 |
15 | ```
16 | ConvertFrom-JWT [-Token] []
17 | ```
18 |
19 | ## DESCRIPTION
20 | Decodes JSON Web Token.
21 |
22 | ## EXAMPLES
23 |
24 | ### Example 1
25 | ```powershell
26 | PS C:\> $Token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJGaXJzdE5hbWUiOiJTdGVmYW4iLCJMYXN0TmFtZSI6IlN0cmFuZ2VyIiwiRGVtbyI6IkVuY29kZSBBY2Nlc3MgVG9rZW4iLCJleHAiOjEzOTMyODY4OTMsImlhdCI6MTM5MzI2ODg5M30.8-YqAPPth3o-C_xO9WFjW5RViAnDe2WrmVyqLRnNEV0'
27 | ConvertFrom-JWT -Token $Token
28 | Header Payload
29 | ------ -------
30 | @{typ=JWT; alg=HS256} @{FirstName=Stefan; LastName=Stranger; Demo=Encode Access Token; exp=1393286893; iat=1393268893}
31 | ```
32 |
33 | Decoded JSON Web Token.
34 |
35 | ### Example 2
36 | ```powershell
37 | PS C:\> $Token = 'eyJFbnYiOiJEZW1vIiwidHlwIjoiSldUIiwiYWxnIjoiSFMyNTYifQ.eyJpYXQiOiIxMzkzMjY4ODkzIiwiRGVtbyI6IkVuY29kZSBBY2Nlc3MgVG9rZW4iLCJGaXJzdE5hbWUiOiJTdGVmYW4iLCJleHAiOiIxMzkzMjg2ODkzIiwiTGFzdE5hbWUiOiJTdHJhbmdlciJ9.JFJVUaBIUJmHQUawkK1dH5Iie8tSTTXKFbZZka3_k7Y'
38 | ConvertFrom-JWT -Token $Token
39 | Header Payload
40 | ------ -------
41 | @{Env=Demo; typ=JWT; alg=HS256} @{iat=1393268893; Demo=Encode Access Token; FirstName=Stefan; exp=1393286893; LastName=Stranger}
42 | ```
43 |
44 | Decoded JSON Web Token with extra header info.
45 |
46 | ### Example 3
47 | ```powershell
48 | PS C:\> $Token = 'eyJFbnYiOiJEZW1vIiwidHlwIjoiSldUIiwiYWxnIjoiSFMyNTYifQ.eyJpYXQiOiIxMzkzMjY4ODkzIiwiRGVtbyI6IkVuY29kZSBBY2Nlc3MgVG9rZW4iLCJGaXJzdE5hbWUiOiJTdGVmYW4iLCJleHAiOiIxMzkzMjg2ODkzIiwiTGFzdE5hbWUiOiJTdHJhbmdlciJ9.JFJVUaBIUJmHQUawkK1dH5Iie8tSTTXKFbZZka3_k7Y'
49 | ConvertFrom-JWT -Token $Token | Select-Object -Expand Payload | Select-Object @{'Name' = 'iatutc'; E= {[system.dateTimeOffset]::FromUnixTimeSeconds($_.iat).datetime}},@{'Name' = 'exptutc'; E= {[system.dateTimeOffset]::FromUnixTimeSeconds($_.exp).datetime}}
50 | iatutc exptutc
51 | ------ -------
52 | 24-2-2014 19:08:13 25-2-2014 00:08:13
53 | ```
54 |
55 | Decoded JSON Web Token with conversation of Unix Time.
56 |
57 | ## PARAMETERS
58 |
59 | ### -Token
60 | JSON Web Token
61 |
62 | ```yaml
63 | Type: String
64 | Parameter Sets: (All)
65 | Aliases:
66 |
67 | Required: True
68 | Position: 0
69 | Default value: None
70 | Accept pipeline input: False
71 | Accept wildcard characters: False
72 | ```
73 |
74 | ### CommonParameters
75 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
76 |
77 | ## INPUTS
78 |
79 | ### None
80 |
81 | ## OUTPUTS
82 |
83 | ### System.String
84 |
85 | ## NOTES
86 |
87 | ## RELATED LINKS
88 |
--------------------------------------------------------------------------------
/docs/ConvertTo-JWT.md:
--------------------------------------------------------------------------------
1 | ---
2 | external help file: PSJwt-help.xml
3 | Module Name: PSJwt
4 | online version:
5 | schema: 2.0.0
6 | ---
7 |
8 | # ConvertTo-JWT
9 |
10 | ## SYNOPSIS
11 | Creating (encoding) JSON Web Token
12 |
13 | ## SYNTAX
14 |
15 | ```
16 | ConvertTo-JWT [-PayLoad] [-Header ] [-Secret] []
17 | ```
18 |
19 | ## DESCRIPTION
20 | Encodes payload to encoded JSON Web Token.
21 |
22 | ## EXAMPLES
23 |
24 | ### Example 1
25 | ```powershell
26 | PS C:\> @{'FirstName' = 'Stefan'; 'LastName' = 'Stranger'; 'Demo' = 'Encode Access Token'; 'exp' = '1393286893'; 'iat' = '1393268893'} | ConvertTo-Jwt -secret 'qwerty'
27 | ```
28 |
29 | Encodes Dictionary (Hashtable) payload to encoded JSON Web Token.
30 |
31 | ### Example 2
32 | ```powershell
33 | PS C:\> $Payload = @{'FirstName' = 'Stefan'; 'LastName' = 'Stranger'; 'Demo' = 'Encode Access Token'; 'exp' = '1393286893'; 'iat' = '1393268893'}
34 | PS C:\> $Header = @{'Env' = 'Demo'}
35 | PS C:\> $Secret = 'qwerty'
36 | PS C:\>ConvertTo-Jwt -Payload $Payload -Header $Header -Secret $Secret
37 | ```
38 |
39 | Encodes Dictionary (Hashtable) payload with extra header info to encoded JSON Web Token.
40 |
41 | ## PARAMETERS
42 |
43 | ### -PayLoad
44 | Payload, which contains the claims. Claims are statements about an entity (typically, the user) and additional data. There are three types of claims: registered, public, and private claims.
45 | The payload needs to be dictionary (HashTable) object.
46 |
47 | ```yaml
48 | Type: Hashtable
49 | Parameter Sets: (All)
50 | Aliases:
51 |
52 | Required: True
53 | Position: 0
54 | Default value: None
55 | Accept pipeline input: True (ByValue)
56 | Accept wildcard characters: False
57 | ```
58 |
59 | ### -Secret
60 | JWTs can be signed using a secret (with the HMAC algorithm).
61 |
62 | ```yaml
63 | Type: String
64 | Parameter Sets: (All)
65 | Aliases:
66 |
67 | Required: True
68 | Position: 1
69 | Default value: None
70 | Accept pipeline input: False
71 | Accept wildcard characters: False
72 | ```
73 |
74 | ### -Header
75 | The header typically consists of two parts: the type of the token, which is JWT, and the signing algorithm being used, such as HMAC SHA256 or RSA. With the Header parameter you can add extra header information.
76 | The header needs to be dictionary (HashTable) object.
77 |
78 | ```yaml
79 | Type: Hashtable
80 | Parameter Sets: (All)
81 | Aliases:
82 |
83 | Required: False
84 | Position: Named
85 | Default value: None
86 | Accept pipeline input: False
87 | Accept wildcard characters: False
88 | ```
89 |
90 | ### CommonParameters
91 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
92 |
93 | ## INPUTS
94 |
95 | ### System.Collections.Hashtable
96 |
97 | ## OUTPUTS
98 |
99 | ### System.String
100 |
101 | ## NOTES
102 |
103 | ## RELATED LINKS
104 |
--------------------------------------------------------------------------------
/en-US/PSJwt-help.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ConvertFrom-JWT
6 | ConvertFrom
7 | JWT
8 |
9 | Parsing (decoding) and verifying JSON Web Token
10 |
11 |
12 |
13 | Decodes JSON Web Token.
14 |
15 |
16 |
17 | ConvertFrom-JWT
18 |
19 | Token
20 |
21 | JSON Web Token
22 |
23 | String
24 |
25 | String
26 |
27 |
28 | None
29 |
30 |
31 |
32 |
33 |
34 | Token
35 |
36 | JSON Web Token
37 |
38 | String
39 |
40 | String
41 |
42 |
43 | None
44 |
45 |
46 |
47 |
48 |
49 | None
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | System.String
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | -------------------------- Example 1 --------------------------
74 | PS C:\> $Token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJGaXJzdE5hbWUiOiJTdGVmYW4iLCJMYXN0TmFtZSI6IlN0cmFuZ2VyIiwiRGVtbyI6IkVuY29kZSBBY2Nlc3MgVG9rZW4iLCJleHAiOjEzOTMyODY4OTMsImlhdCI6MTM5MzI2ODg5M30.8-YqAPPth3o-C_xO9WFjW5RViAnDe2WrmVyqLRnNEV0'
75 | ConvertFrom-JWT -Token $Token
76 | Header Payload
77 | ------ -------
78 | @{typ=JWT; alg=HS256} @{FirstName=Stefan; LastName=Stranger; Demo=Encode Access Token; exp=1393286893; iat=1393268893}
79 |
80 | Decoded JSON Web Token.
81 |
82 |
83 |
84 | -------------------------- Example 2 --------------------------
85 | PS C:\> $Token = 'eyJFbnYiOiJEZW1vIiwidHlwIjoiSldUIiwiYWxnIjoiSFMyNTYifQ.eyJpYXQiOiIxMzkzMjY4ODkzIiwiRGVtbyI6IkVuY29kZSBBY2Nlc3MgVG9rZW4iLCJGaXJzdE5hbWUiOiJTdGVmYW4iLCJleHAiOiIxMzkzMjg2ODkzIiwiTGFzdE5hbWUiOiJTdHJhbmdlciJ9.JFJVUaBIUJmHQUawkK1dH5Iie8tSTTXKFbZZka3_k7Y'
86 | ConvertFrom-JWT -Token $Token
87 | Header Payload
88 | ------ -------
89 | @{Env=Demo; typ=JWT; alg=HS256} @{iat=1393268893; Demo=Encode Access Token; FirstName=Stefan; exp=1393286893; LastName=Stranger}
90 |
91 | Decoded JSON Web Token with extra header info.
92 |
93 |
94 |
95 | -------------------------- Example 3 --------------------------
96 | PS C:\> $Token = 'eyJFbnYiOiJEZW1vIiwidHlwIjoiSldUIiwiYWxnIjoiSFMyNTYifQ.eyJpYXQiOiIxMzkzMjY4ODkzIiwiRGVtbyI6IkVuY29kZSBBY2Nlc3MgVG9rZW4iLCJGaXJzdE5hbWUiOiJTdGVmYW4iLCJleHAiOiIxMzkzMjg2ODkzIiwiTGFzdE5hbWUiOiJTdHJhbmdlciJ9.JFJVUaBIUJmHQUawkK1dH5Iie8tSTTXKFbZZka3_k7Y'
97 | ConvertFrom-JWT -Token $Token | Select-Object -Expand Payload | Select-Object @{'Name' = 'iatutc'; E= {[system.dateTimeOffset]::FromUnixTimeSeconds($_.iat).datetime}},@{'Name' = 'exptutc'; E= {[system.dateTimeOffset]::FromUnixTimeSeconds($_.exp).datetime}}
98 | iatutc exptutc
99 | ------ -------
100 | 24-2-2014 19:08:13 25-2-2014 00:08:13
101 |
102 | Decoded JSON Web Token with conversation of Unix Time.
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 | ConvertTo-JWT
111 | ConvertTo
112 | JWT
113 |
114 | Creating (encoding) JSON Web Token
115 |
116 |
117 |
118 | Encodes payload to encoded JSON Web Token.
119 |
120 |
121 |
122 | ConvertTo-JWT
123 |
124 | PayLoad
125 |
126 | Payload, which contains the claims. Claims are statements about an entity (typically, the user) and additional data. There are three types of claims: registered, public, and private claims. The payload needs to be dictionary (HashTable) object.
127 |
128 | Hashtable
129 |
130 | Hashtable
131 |
132 |
133 | None
134 |
135 |
136 | Secret
137 |
138 | JWTs can be signed using a secret (with the HMAC algorithm).
139 |
140 | String
141 |
142 | String
143 |
144 |
145 | None
146 |
147 |
148 | Header
149 |
150 | The header typically consists of two parts: the type of the token, which is JWT, and the signing algorithm being used, such as HMAC SHA256 or RSA. With the Header parameter you can add extra header information. The header needs to be dictionary (HashTable) object.
151 |
152 | Hashtable
153 |
154 | Hashtable
155 |
156 |
157 | None
158 |
159 |
160 |
161 |
162 |
163 | PayLoad
164 |
165 | Payload, which contains the claims. Claims are statements about an entity (typically, the user) and additional data. There are three types of claims: registered, public, and private claims. The payload needs to be dictionary (HashTable) object.
166 |
167 | Hashtable
168 |
169 | Hashtable
170 |
171 |
172 | None
173 |
174 |
175 | Secret
176 |
177 | JWTs can be signed using a secret (with the HMAC algorithm).
178 |
179 | String
180 |
181 | String
182 |
183 |
184 | None
185 |
186 |
187 | Header
188 |
189 | The header typically consists of two parts: the type of the token, which is JWT, and the signing algorithm being used, such as HMAC SHA256 or RSA. With the Header parameter you can add extra header information. The header needs to be dictionary (HashTable) object.
190 |
191 | Hashtable
192 |
193 | Hashtable
194 |
195 |
196 | None
197 |
198 |
199 |
200 |
201 |
202 | System.Collections.Hashtable
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 | System.String
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 | -------------------------- Example 1 --------------------------
227 | PS C:\> @{'FirstName' = 'Stefan'; 'LastName' = 'Stranger'; 'Demo' = 'Encode Access Token'; 'exp' = '1393286893'; 'iat' = '1393268893'} | ConvertTo-Jwt -secret 'qwerty'
228 |
229 | Encodes Dictionary (Hashtable) payload to encoded JSON Web Token.
230 |
231 |
232 |
233 | -------------------------- Example 2 --------------------------
234 | PS C:\> $Payload = @{'FirstName' = 'Stefan'; 'LastName' = 'Stranger'; 'Demo' = 'Encode Access Token'; 'exp' = '1393286893'; 'iat' = '1393268893'}
235 | PS C:\> $Header = @{'Env' = 'Demo'}
236 | PS C:\> $Secret = 'qwerty'
237 | PS C:\>ConvertTo-Jwt -Payload $Payload -Header $Header -Secret $Secret
238 |
239 | Encodes Dictionary (Hashtable) payload with extra header info to encoded JSON Web Token.
240 |
241 |
242 |
243 |
244 |
245 |
--------------------------------------------------------------------------------
/lib/Newtonsoft/net45/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stefanstranger/psjwt/bb3336e9679416e20fd0cbe2b42c567775a9ebd6/lib/Newtonsoft/net45/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/lib/Newtonsoft/netstandard1.0/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stefanstranger/psjwt/bb3336e9679416e20fd0cbe2b42c567775a9ebd6/lib/Newtonsoft/netstandard1.0/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/lib/jwt/net46/JWT.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stefanstranger/psjwt/bb3336e9679416e20fd0cbe2b42c567775a9ebd6/lib/jwt/net46/JWT.dll
--------------------------------------------------------------------------------
/lib/jwt/net46/JWT.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stefanstranger/psjwt/bb3336e9679416e20fd0cbe2b42c567775a9ebd6/lib/jwt/net46/JWT.pdb
--------------------------------------------------------------------------------
/lib/jwt/net46/JWT.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | JWT
5 |
6 |
7 |
8 |
9 | Implements by returning the supplied while ignoring parameters.
10 |
11 |
12 |
13 |
14 | Creates an instance of with supplied delegate to an algorithm.
15 |
16 |
17 |
18 |
19 |
20 | Creates an instance of with supplied algorithm.
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | HMAC using SHA-256
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | HMAC using SHA-384
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | HMAC using SHA-512
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | Provides IJwtAlgorithms.
69 |
70 |
71 |
72 |
73 | Creates an AlgorithmFactory using the provided algorithm enum.
74 |
75 | The captured context during validation of JWT inside
76 |
77 |
78 |
79 | Represents an asymmetric algorithm to generate or validate JWT signature.
80 |
81 |
82 |
83 |
84 | Verifies provided byte array with provided signature.
85 |
86 | The data to verify
87 | The signature to verify with
88 |
89 |
90 |
91 | Represents an algorithm to generate JWT signature.
92 |
93 |
94 |
95 |
96 | Signs provided byte array with provided key.
97 |
98 | The key used to sign the data
99 | The data to sign
100 |
101 |
102 |
103 | Gets algorithm name.
104 |
105 |
106 |
107 |
108 | Extension methods for
109 |
110 |
111 |
112 |
113 | Returns whether or not the algorithm is asymmetric.
114 |
115 | The algorithm instance.
116 |
117 |
118 |
119 | Enum representing the various Jwt Hash Algorithms.
120 |
121 |
122 |
123 |
124 | HMAC using SHA-256
125 |
126 |
127 |
128 |
129 | HMAC using SHA-384
130 |
131 |
132 |
133 |
134 | HMAC using SHA-512
135 |
136 |
137 |
138 |
139 | RSASSA-PKCS1-v1_5 using SHA-256
140 |
141 |
142 |
143 |
144 | RSASSA-PKCS1-v1_5 using SHA-256
145 |
146 |
147 |
148 |
149 | Creates an instance of using the provided pair of public and private keys.
150 |
151 | The public key for verifying the data.
152 | The private key for signing the data.
153 |
154 |
155 |
156 | Creates an instance of using the provided public key only.
157 |
158 |
159 | An instance created using this constructor can only be used for verifying the data, not for signing it.
160 |
161 | The public key for verifying the data.
162 |
163 |
164 |
165 | Creates an instance using the provided certificate.
166 |
167 | The certificate having a public key and an optional private key.
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 | Signs the provided bytes.
178 |
179 | The bytes to sign.
180 | The signed bytes.
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 | Creates an instance of the class using the provided .
191 |
192 | Func that returns which will be used to instantiate
193 |
194 |
195 |
196 | Creates an instance of using the provided public key only.
197 |
198 | The public key for verifying the data.
199 |
200 |
201 |
202 | Creates an instance of using the provided pair of public and private keys.
203 |
204 | The public key for verifying the data.
205 | The private key for signing the data.
206 |
207 |
208 |
209 | All public claims of a JWT specified by IANA, see https://www.iana.org/assignments/jwt/jwt.xhtml
210 |
211 |
212 |
213 |
214 | Gets the string representation of a well-known header name enum
215 |
216 |
217 |
218 |
219 | Gets the string representation of a well-known claim name enum
220 |
221 |
222 |
223 |
224 | Gets the value of the from the object.
225 |
226 |
227 |
228 |
229 | All predefined parameter names specified by RFC 7515, see https://tools.ietf.org/html/rfc7515
230 |
231 |
232 |
233 |
234 | Encode and decode JWT with Fluent API.
235 |
236 |
237 |
238 |
239 | Add header to the JWT.
240 |
241 | Well-known header name
242 | The value you want give to the header
243 | Current builder instance
244 |
245 |
246 |
247 | Adds claim to the JWT.
248 |
249 | Claim name
250 | Claim value
251 | Current builder instance
252 |
253 |
254 |
255 | Sets JWT serializer.
256 |
257 |
258 | If not set then default will be used.
259 |
260 | Current builder instance
261 |
262 |
263 |
264 | Sets custom datetime provider.
265 |
266 |
267 | If not set then default will be used.
268 |
269 | Current builder instance
270 |
271 |
272 |
273 | Sets JWT encoder.
274 |
275 | Current builder instance
276 |
277 |
278 |
279 | Sets JWT decoder.
280 |
281 | Current builder instance
282 |
283 |
284 |
285 | Sets JWT validator.
286 |
287 |
288 | Required to decode with verification.
289 |
290 | Current builder instance
291 |
292 |
293 |
294 | Sets custom URL encoder.
295 |
296 |
297 | If not set then default will be used.
298 |
299 | Current builder instance
300 |
301 |
302 |
303 | Sets JWT algorithm factory.
304 |
305 | Current builder instance.
306 |
307 |
308 |
309 | Sets JWT algorithm.
310 |
311 | Current builder instance.
312 |
313 |
314 |
315 | Sets certificate secret.
316 |
317 |
318 | Required to create new token that uses an symmetric algorithm such as
319 |
320 | Current builder instance
321 |
322 |
323 |
324 | Sets certificate secret.
325 |
326 |
327 | Required to create new token that uses an symmetric algorithm such as
328 |
329 | Current builder instance
330 |
331 |
332 |
333 | Instructs to do verify the JWT signature.
334 |
335 | Current builder instance
336 |
337 |
338 |
339 | Instructs to do not verify the JWT signature.
340 |
341 | Current builder instance
342 |
343 |
344 |
345 | Instructs whether to verify the JWT signature.
346 |
347 | Current builder instance
348 |
349 |
350 |
351 | Encodes a token using the supplied dependencies.
352 |
353 | The generated JWT
354 | Thrown if either algorithm, serializer, encoder or secret is null
355 |
356 |
357 |
358 | Decodes a token using the supplied dependencies.
359 |
360 | The JWT
361 | The JSON payload
362 |
363 |
364 |
365 | Given a JWT, decodes it and return the header.
366 |
367 | The JWT
368 |
369 |
370 |
371 | Given a JWT, decodes it and return the header.
372 |
373 | The JWT
374 |
375 |
376 |
377 | Decodes a token using the supplied dependencies.
378 |
379 | The JWT
380 | The payload converted to
381 |
382 |
383 |
384 | Checks whether enough dependencies were supplied to encode a new token.
385 |
386 |
387 |
388 |
389 | Checks whether enough dependencies were supplied to decode a token.
390 |
391 |
392 |
393 |
394 | Adds well-known claim to the JWT.
395 |
396 |
397 |
398 |
399 | Adds well-known claim to the JWT.
400 |
401 |
402 |
403 |
404 | Adds well-known claim to the JWT.
405 |
406 |
407 |
408 |
409 | Adds several claims to the JWT
410 |
411 |
412 |
413 |
414 | Represents the Data that will store in a JWT.
415 |
416 |
417 |
418 |
419 | Creates a new instance of with empty Header and Payload.
420 |
421 |
422 |
423 |
424 | Creates a new instance of
425 |
426 | Dictionary that contans the payload
427 |
428 |
429 |
430 | Creates a new instance of
431 |
432 | Dictionary that contains the headers
433 | Dictionary that contans the payload
434 |
435 |
436 |
437 | Creates a new instance of
438 |
439 | The JWT token
440 |
441 |
442 |
443 | The header information as a key-value store of the JWT
444 |
445 |
446 |
447 |
448 | The payload of the JWT as a key-value store
449 |
450 |
451 |
452 |
453 | JSON header model with predefined parameter names specified by RFC 7515, see https://tools.ietf.org/html/rfc7515
454 |
455 |
456 |
457 |
458 | Represents an exception thrown when when a token doesn't consist of 3 delimited by dot parts.
459 |
460 |
461 |
462 |
463 | Creates an instance of
464 |
465 | The name of the parameter that caused the exception
466 |
467 |
468 |
469 | Represents an exception thrown when a signature validation fails.
470 |
471 |
472 |
473 |
474 | Creates an instance of
475 |
476 | The error message
477 |
478 |
479 |
480 | Expected key.
481 |
482 |
483 |
484 |
485 | Received key.
486 |
487 |
488 |
489 |
490 | Retrieves the value for the provided key, or default.
491 |
492 |
493 | The key
494 |
495 |
496 |
497 |
498 | Represents an exception thrown when when a token is expired.
499 |
500 |
501 |
502 |
503 | Creates an instance of
504 |
505 | The error message
506 |
507 |
508 |
509 | The payload.
510 |
511 |
512 |
513 |
514 | The expiration DateTime of the token.
515 |
516 |
517 |
518 |
519 | Represents a base64 encoder/decoder.
520 |
521 |
522 |
523 |
524 | Encodes the byte array to a Base64 string.
525 |
526 |
527 |
528 |
529 | Decodes the Base64 string to a byte array.
530 |
531 |
532 |
533 |
534 | Represents a DateTime provider.
535 |
536 |
537 |
538 |
539 | Gets the current DateTime.
540 |
541 |
542 |
543 |
544 | Provides JSON Serialize and Deserialize. Allows custom serializers used.
545 |
546 |
547 |
548 |
549 | Serialize an object to JSON string
550 |
551 | object
552 | JSON string
553 |
554 |
555 |
556 | Deserialize a JSON string to typed object.
557 |
558 | type of object
559 | JSON string
560 | Strongly-typed object
561 |
562 |
563 |
564 | Represents a JWT decoder.
565 |
566 |
567 |
568 |
569 | Given a JWT, decodes it and return the header.
570 |
571 | The JWT
572 |
573 |
574 |
575 | Given a JWT, decodes it and return the header as an object.
576 |
577 | The JWT
578 |
579 |
580 |
581 | Given a JWT, decodes it and return the payload.
582 |
583 | The JWT
584 | A string containing the JSON payload
585 |
586 |
587 |
588 | Given a JWT, decodes it and return the payload.
589 |
590 | The JWT
591 | The key that were used to sign the JWT
592 | Whether to verify the signature (default is true)
593 | A string containing the JSON payload
594 |
595 |
596 |
597 | Given a JWT, decodes it and return the payload.
598 |
599 | The JWT
600 | The keys provided which one of them was used to sign the JWT
601 | Whether to verify the signature (default is true)
602 | A string containing the JSON payload
603 |
604 |
605 |
606 | Given a JWT, decodes it and return the payload as an object.
607 |
608 | The type to return
609 | The JWT
610 | An object representing the payload
611 |
612 |
613 |
614 | Given a JWT, decodes it and return the payload as an object.
615 |
616 | The type to return
617 | The JWT
618 | The key that was used to sign the JWT
619 | Whether to verify the signature (default is true)
620 | An object representing the payload
621 |
622 |
623 |
624 | Given a JWT, decodes it and return the payload as an object.
625 |
626 | The type to return
627 | The JWT
628 | The keys which one of them was used to sign the JWT
629 | Whether to verify the signature (default is true)
630 | An object representing the payload
631 |
632 |
633 |
634 | Extension methods for
635 |
636 |
637 |
638 |
639 | Given a JWT, decodes it and return the payload.
640 |
641 | The decoder instance
642 | The JWT
643 | A string containing the JSON payload
644 |
645 |
646 |
647 |
648 |
649 |
650 | Given a JWT, decodes it and return the payload.
651 |
652 | The decoder instance
653 | The JWT
654 | A string containing the JSON payload
655 |
656 |
657 |
658 | Given a JWT, decodes it and return the payload.
659 |
660 | The decoder instance
661 | The JWT
662 | The key that was used to sign the JWT
663 | Whether to verify the signature (default is true)
664 | A string containing the JSON payload
665 |
666 |
667 |
668 |
669 |
670 |
671 | Given a JWT, decodes it and return the payload.
672 |
673 | The decoder instance
674 | The JWT
675 | The keys that were used to sign the JWT
676 | Whether to verify the signature (default is true)
677 | A string containing the JSON payload
678 |
679 |
680 |
681 |
682 |
683 |
684 | Given a JWT, decodes it and return the payload as an dictionary.
685 |
686 | The decoder instance
687 | The JWT
688 | The key that was used to sign the JWT
689 | Whether to verify the signature (default is true)
690 | An object representing the payload
691 |
692 |
693 |
694 |
695 |
696 | Given a JWT, decodes it and return the payload as an dictionary.
697 |
698 | The decoder instance
699 | The JWT
700 | The key which one of them was used to sign the JWT
701 | Whether to verify the signature (default is true)
702 | An object representing the payload
703 |
704 |
705 |
706 |
707 |
708 | Given a JWT, decodes it and return the payload as an object.
709 |
710 | The type to return
711 | The decoder instance
712 | The JWT
713 | An object representing the payload
714 |
715 |
716 |
717 | Given a JWT, decodes it and return the payload as a dictionary.
718 |
719 | The decoder instance
720 | The JWT
721 | An object representing the payload
722 |
723 |
724 |
725 | Given a JWT, decodes it and return the payload as a dictionary.
726 |
727 | The decoder instance
728 | The JWT
729 | The key that was used to sign the JWT
730 | Whether to verify the signature (default is true)
731 | An object representing the payload
732 |
733 |
734 |
735 |
736 |
737 |
738 | Given a JWT, decodes it and return the payload as a dictionary.
739 |
740 | The decoder instance
741 | The JWT
742 | The keys that were used to sign the JWT
743 | Whether to verify the signature (default is true)
744 | A string containing the JSON payload
745 |
746 |
747 |
748 |
749 |
750 |
751 | Given a JWT, decodes it and return the payload as an object.
752 |
753 | The type to return
754 | The decoder instance
755 | The JWT
756 | The key that was used to sign the JWT
757 | Whether to verify the signature (default is true)
758 | An object representing the payload
759 |
760 |
761 |
762 | Given a JWT, decodes it and return the payload as an object.
763 |
764 | The type to return
765 | The decoder instance
766 | The JWT
767 | The key that was used to sign the JWT
768 | Whether to verify the signature (default is true)
769 | An object representing the payload
770 |
771 |
772 |
773 | Given a JWT, decodes it and return the payload as an object.
774 |
775 | The type to return
776 | The decoder instance
777 | The JWT
778 | The keys provided which one of them was used to sign the JWT
779 | Whether to verify the signature (default is true)
780 | An object representing the payload
781 |
782 |
783 |
784 | Given a JWT, decodes it and return the payload as an object.
785 |
786 | The type to return
787 | The decoder instance
788 | The JWT
789 | The keys provided which one of them was used to sign the JWT
790 | Whether to verify the signature (default is true)
791 | An object representing the payload
792 |
793 |
794 |
795 | Represents a JWT encoder.
796 |
797 |
798 |
799 |
800 | Creates a JWT given a header, a payload, the signing key, and the algorithm to use.
801 |
802 | An arbitrary set of extra headers. Will be augmented with the standard "typ" and "alg" headers
803 | An arbitrary payload (must be serializable to JSON)
804 | The key bytes used to sign the token
805 | The generated JWT
806 |
807 |
808 |
809 | Extension methods for
810 |
811 |
812 |
813 |
814 | Creates a JWT given a payload, the signing key, and the algorithm to use.
815 |
816 | The encoder instance
817 | An arbitrary payload (must be serializable to JSON)
818 | The key used to sign the token
819 | The generated JWT
820 |
821 |
822 |
823 |
824 | Creates a JWT given a payload, the signing key, and the algorithm to use.
825 |
826 | The encoder instance
827 | An arbitrary payload (must be serializable to JSON)
828 | The key used to sign the token
829 | The generated JWT
830 |
831 |
832 |
833 |
834 | Creates a JWT given a set of arbitrary extra headers, a payload, the signing key, and the algorithm to use.
835 |
836 | The encoder instance
837 | An arbitrary set of extra headers. Will be augmented with the standard "typ" and "alg" headers
838 | An arbitrary payload (must be serializable to JSON)
839 | The key bytes used to sign the token
840 | The generated JWT
841 |
842 |
843 |
844 |
845 | Represents a JWT validator.
846 |
847 |
848 |
849 |
850 | Given the JWT, verifies its signature correctness.
851 |
852 | >An arbitrary payload (already serialized to JSON)
853 | Decoded body
854 | The signatures to validate with
855 |
856 |
857 |
858 | Given the JWT, verifies its signature correctness.
859 |
860 |
861 | Used by the asymmetric algorithms only.
862 |
863 | >An arbitrary payload (already serialized to JSON)
864 | The asymmetric algorithm to validate with
865 | The header and payload bytes to validate
866 | The signature to validate with
867 |
868 |
869 |
870 | Given the JWT, verifies its signature correctness without throwing an exception but returning it instead.
871 |
872 | >An arbitrary payload (already serialized to JSON)
873 | Decoded body
874 | The signature to validate with
875 | The resulting validation exception, if any
876 | Returns true if exception is JWT is valid and exception is null, otherwise false
877 |
878 |
879 |
880 | Given the JWT, verifies its signature correctness without throwing an exception but returning it instead.
881 |
882 | >An arbitrary payload (already serialized to JSON)
883 | Decoded body
884 | The signatures to validate with
885 | The resulting validation exception, if any
886 | Returns true if exception is JWT is valid and exception is null, otherwise false
887 |
888 |
889 |
890 | Given the JWT, verifies its signatures correctness without throwing an exception but returning it instead.
891 |
892 | >An arbitrary payload (already serialized to JSON)
893 | The asymmetric algorithm to validate with
894 | The header and payload bytes to validate
895 | The decodedSignatures to validate with
896 | Validation exception, if any
897 | True if exception is JWT is valid and exception is null, otherwise false
898 |
899 |
900 |
901 | Base64 encoding/decoding implementation according to the JWT spec
902 |
903 |
904 |
905 |
906 |
907 |
908 |
909 |
910 |
911 |
912 |
913 |
914 |
915 |
916 | Decodes JWT.
917 |
918 |
919 |
920 |
921 | Creates an instance of
922 |
923 |
924 | This overload supplies no and no so the resulting decoder cannot be used for signature validation.
925 |
926 | The Json Serializer
927 | The Base64 URL Encoder
928 |
929 |
930 |
931 |
932 | Creates an instance of
933 |
934 | The Json Serializer
935 | The Jwt validator
936 | The Base64 URL Encoder
937 | The Algorithm Factory
938 |
939 |
940 |
941 |
942 | Creates an instance of
943 |
944 | The Json Serializer
945 | The Jwt validator
946 | The Base64 URL Encoder
947 | The Algorithm
948 |
949 |
950 |
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
962 |
963 |
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 |
973 |
974 |
975 |
976 |
977 |
978 |
979 |
980 |
981 |
982 |
983 |
984 |
985 |
986 |
987 |
988 |
989 |
990 |
991 |
992 |
993 |
994 |
995 |
996 |
997 |
998 |
999 |
1000 |
1001 |
1002 |
1003 |
1004 |
1005 |
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 | Prepares data before calling
1013 |
1014 | The array representation of a JWT
1015 | The key that was used to sign the JWT
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 | Prepares data before calling
1025 |
1026 | The array representation of a JWT
1027 | The keys provided which one of them was used to sign the JWT
1028 |
1029 |
1030 |
1031 |
1032 |
1033 |
1034 |
1035 |
1036 | Prepares data before calling
1037 |
1038 | The JWT parts
1039 | The keys provided which one of them was used to sign the JWT
1040 |
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1047 |
1048 |
1049 | Unmodified JWT.
1050 |
1051 |
1052 |
1053 |
1054 | Deserialized JWT header.
1055 |
1056 |
1057 |
1058 |
1059 | Decoded JWT payload.
1060 |
1061 |
1062 |
1063 |
1064 | Encodes Jwt.
1065 |
1066 |
1067 |
1068 |
1069 | Creates an instance of
1070 |
1071 | The Json Serializer
1072 | The Jwt Algorithm
1073 | The Base64 URL Encoder
1074 |
1075 |
1076 |
1077 |
1078 |
1079 |
1080 |
1081 | Represent the parts of a JWT
1082 |
1083 |
1084 |
1085 |
1086 | Creates a new instance of from the string representation of a JWT
1087 |
1088 | The string representation of a JWT
1089 |
1090 |
1091 |
1092 |
1093 |
1094 | Creates a new instance of from the array representation of a JWT
1095 |
1096 | The array representation of a JWT
1097 |
1098 |
1099 |
1100 |
1101 |
1102 | Gets the Header part of a JWT
1103 |
1104 |
1105 |
1106 |
1107 | Gets the Payload part of a JWT
1108 |
1109 |
1110 |
1111 |
1112 | Gets the Signature part of a JWT
1113 |
1114 |
1115 |
1116 |
1117 | Gets the parts of a JWT
1118 |
1119 |
1120 |
1121 |
1122 | Helper enum to get the correct part from the array representation of a JWT parts
1123 |
1124 |
1125 |
1126 |
1127 | Jwt validator.
1128 |
1129 |
1130 |
1131 |
1132 | Creates an instance of
1133 |
1134 | The Json Serializer
1135 | The DateTime Provider
1136 |
1137 |
1138 |
1139 |
1140 |
1141 |
1142 |
1143 |
1144 |
1145 |
1146 |
1147 |
1148 |
1149 |
1150 |
1151 |
1152 |
1153 |
1154 |
1155 |
1156 |
1157 |
1158 |
1159 |
1160 | In the future this method can be opened for extension hence made protected virtual
1161 |
1162 |
1163 |
1164 | Verifies the 'exp' claim.
1165 |
1166 | See https://tools.ietf.org/html/rfc7515#section-4.1.4
1167 |
1168 |
1169 |
1170 |
1171 |
1172 | Verifies the 'nbf' claim.
1173 |
1174 | See https://tools.ietf.org/html/rfc7515#section-4.1.5
1175 |
1176 |
1177 |
1178 |
1179 | JSON serializer using Newtonsoft.Json implementation.
1180 |
1181 |
1182 |
1183 |
1184 | Creates a new instance of
1185 |
1186 | Uses as internal serializer
1187 |
1188 |
1189 |
1190 | Creates a new instance of
1191 |
1192 | Internal to use for serialization
1193 |
1194 |
1195 |
1196 |
1197 |
1198 |
1199 |
1200 |
1201 |
1202 | Describes a point in time, defined as the number of seconds that have elapsed since 00:00:00 UTC, Thursday, 1 January 1970, not counting leap seconds.
1203 | See https://en.wikipedia.org/wiki/Unix_time />
1204 |
1205 |
1206 |
1207 |
1208 | Provider for UTC DateTime.
1209 |
1210 |
1211 |
1212 |
1213 | Retuns the current time (UTC).
1214 |
1215 |
1216 |
1217 |
1218 |
1219 |
--------------------------------------------------------------------------------
/lib/jwt/netstandard2.0/JWT.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stefanstranger/psjwt/bb3336e9679416e20fd0cbe2b42c567775a9ebd6/lib/jwt/netstandard2.0/JWT.dll
--------------------------------------------------------------------------------
/lib/jwt/netstandard2.0/JWT.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stefanstranger/psjwt/bb3336e9679416e20fd0cbe2b42c567775a9ebd6/lib/jwt/netstandard2.0/JWT.pdb
--------------------------------------------------------------------------------
/lib/jwt/netstandard2.0/JWT.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | JWT
5 |
6 |
7 |
8 |
9 | Implements by returning the supplied while ignoring parameters.
10 |
11 |
12 |
13 |
14 | Creates an instance of with supplied delegate to an algorithm.
15 |
16 |
17 |
18 |
19 |
20 | Creates an instance of with supplied algorithm.
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | HMAC using SHA-256
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | HMAC using SHA-384
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | HMAC using SHA-512
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | Provides IJwtAlgorithms.
69 |
70 |
71 |
72 |
73 | Creates an AlgorithmFactory using the provided algorithm enum.
74 |
75 | The captured context during validation of JWT inside
76 |
77 |
78 |
79 | Represents an asymmetric algorithm to generate or validate JWT signature.
80 |
81 |
82 |
83 |
84 | Verifies provided byte array with provided signature.
85 |
86 | The data to verify
87 | The signature to verify with
88 |
89 |
90 |
91 | Represents an algorithm to generate JWT signature.
92 |
93 |
94 |
95 |
96 | Signs provided byte array with provided key.
97 |
98 | The key used to sign the data
99 | The data to sign
100 |
101 |
102 |
103 | Gets algorithm name.
104 |
105 |
106 |
107 |
108 | Extension methods for
109 |
110 |
111 |
112 |
113 | Returns whether or not the algorithm is asymmetric.
114 |
115 | The algorithm instance.
116 |
117 |
118 |
119 | Enum representing the various Jwt Hash Algorithms.
120 |
121 |
122 |
123 |
124 | HMAC using SHA-256
125 |
126 |
127 |
128 |
129 | HMAC using SHA-384
130 |
131 |
132 |
133 |
134 | HMAC using SHA-512
135 |
136 |
137 |
138 |
139 | RSASSA-PKCS1-v1_5 using SHA-256
140 |
141 |
142 |
143 |
144 | RSASSA-PKCS1-v1_5 using SHA-256
145 |
146 |
147 |
148 |
149 | Creates an instance of using the provided pair of public and private keys.
150 |
151 | The public key for verifying the data.
152 | The private key for signing the data.
153 |
154 |
155 |
156 | Creates an instance of using the provided public key only.
157 |
158 |
159 | An instance created using this constructor can only be used for verifying the data, not for signing it.
160 |
161 | The public key for verifying the data.
162 |
163 |
164 |
165 | Creates an instance using the provided certificate.
166 |
167 | The certificate having a public key and an optional private key.
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 | Signs the provided bytes.
178 |
179 | The bytes to sign.
180 | The signed bytes.
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 | Creates an instance of the class using the provided .
191 |
192 | Func that returns which will be used to instantiate
193 |
194 |
195 |
196 | Creates an instance of using the provided public key only.
197 |
198 | The public key for verifying the data.
199 |
200 |
201 |
202 | Creates an instance of using the provided pair of public and private keys.
203 |
204 | The public key for verifying the data.
205 | The private key for signing the data.
206 |
207 |
208 |
209 | All public claims of a JWT specified by IANA, see https://www.iana.org/assignments/jwt/jwt.xhtml
210 |
211 |
212 |
213 |
214 | Gets the string representation of a well-known header name enum
215 |
216 |
217 |
218 |
219 | Gets the string representation of a well-known claim name enum
220 |
221 |
222 |
223 |
224 | Gets the value of the from the object.
225 |
226 |
227 |
228 |
229 | All predefined parameter names specified by RFC 7515, see https://tools.ietf.org/html/rfc7515
230 |
231 |
232 |
233 |
234 | Encode and decode JWT with Fluent API.
235 |
236 |
237 |
238 |
239 | Add header to the JWT.
240 |
241 | Well-known header name
242 | The value you want give to the header
243 | Current builder instance
244 |
245 |
246 |
247 | Adds claim to the JWT.
248 |
249 | Claim name
250 | Claim value
251 | Current builder instance
252 |
253 |
254 |
255 | Sets JWT serializer.
256 |
257 |
258 | If not set then default will be used.
259 |
260 | Current builder instance
261 |
262 |
263 |
264 | Sets custom datetime provider.
265 |
266 |
267 | If not set then default will be used.
268 |
269 | Current builder instance
270 |
271 |
272 |
273 | Sets JWT encoder.
274 |
275 | Current builder instance
276 |
277 |
278 |
279 | Sets JWT decoder.
280 |
281 | Current builder instance
282 |
283 |
284 |
285 | Sets JWT validator.
286 |
287 |
288 | Required to decode with verification.
289 |
290 | Current builder instance
291 |
292 |
293 |
294 | Sets custom URL encoder.
295 |
296 |
297 | If not set then default will be used.
298 |
299 | Current builder instance
300 |
301 |
302 |
303 | Sets JWT algorithm factory.
304 |
305 | Current builder instance.
306 |
307 |
308 |
309 | Sets JWT algorithm.
310 |
311 | Current builder instance.
312 |
313 |
314 |
315 | Sets certificate secret.
316 |
317 |
318 | Required to create new token that uses an symmetric algorithm such as
319 |
320 | Current builder instance
321 |
322 |
323 |
324 | Sets certificate secret.
325 |
326 |
327 | Required to create new token that uses an symmetric algorithm such as
328 |
329 | Current builder instance
330 |
331 |
332 |
333 | Instructs to do verify the JWT signature.
334 |
335 | Current builder instance
336 |
337 |
338 |
339 | Instructs to do not verify the JWT signature.
340 |
341 | Current builder instance
342 |
343 |
344 |
345 | Instructs whether to verify the JWT signature.
346 |
347 | Current builder instance
348 |
349 |
350 |
351 | Encodes a token using the supplied dependencies.
352 |
353 | The generated JWT
354 | Thrown if either algorithm, serializer, encoder or secret is null
355 |
356 |
357 |
358 | Decodes a token using the supplied dependencies.
359 |
360 | The JWT
361 | The JSON payload
362 |
363 |
364 |
365 | Given a JWT, decodes it and return the header.
366 |
367 | The JWT
368 |
369 |
370 |
371 | Given a JWT, decodes it and return the header.
372 |
373 | The JWT
374 |
375 |
376 |
377 | Decodes a token using the supplied dependencies.
378 |
379 | The JWT
380 | The payload converted to
381 |
382 |
383 |
384 | Checks whether enough dependencies were supplied to encode a new token.
385 |
386 |
387 |
388 |
389 | Checks whether enough dependencies were supplied to decode a token.
390 |
391 |
392 |
393 |
394 | Adds well-known claim to the JWT.
395 |
396 |
397 |
398 |
399 | Adds well-known claim to the JWT.
400 |
401 |
402 |
403 |
404 | Adds well-known claim to the JWT.
405 |
406 |
407 |
408 |
409 | Adds several claims to the JWT
410 |
411 |
412 |
413 |
414 | Represents the Data that will store in a JWT.
415 |
416 |
417 |
418 |
419 | Creates a new instance of with empty Header and Payload.
420 |
421 |
422 |
423 |
424 | Creates a new instance of
425 |
426 | Dictionary that contans the payload
427 |
428 |
429 |
430 | Creates a new instance of
431 |
432 | Dictionary that contains the headers
433 | Dictionary that contans the payload
434 |
435 |
436 |
437 | Creates a new instance of
438 |
439 | The JWT token
440 |
441 |
442 |
443 | The header information as a key-value store of the JWT
444 |
445 |
446 |
447 |
448 | The payload of the JWT as a key-value store
449 |
450 |
451 |
452 |
453 | JSON header model with predefined parameter names specified by RFC 7515, see https://tools.ietf.org/html/rfc7515
454 |
455 |
456 |
457 |
458 | Represents an exception thrown when when a token doesn't consist of 3 delimited by dot parts.
459 |
460 |
461 |
462 |
463 | Creates an instance of
464 |
465 | The name of the parameter that caused the exception
466 |
467 |
468 |
469 | Represents an exception thrown when a signature validation fails.
470 |
471 |
472 |
473 |
474 | Creates an instance of
475 |
476 | The error message
477 |
478 |
479 |
480 | Expected key.
481 |
482 |
483 |
484 |
485 | Received key.
486 |
487 |
488 |
489 |
490 | Retrieves the value for the provided key, or default.
491 |
492 |
493 | The key
494 |
495 |
496 |
497 |
498 | Represents an exception thrown when when a token is expired.
499 |
500 |
501 |
502 |
503 | Creates an instance of
504 |
505 | The error message
506 |
507 |
508 |
509 | The payload.
510 |
511 |
512 |
513 |
514 | The expiration DateTime of the token.
515 |
516 |
517 |
518 |
519 | Represents a base64 encoder/decoder.
520 |
521 |
522 |
523 |
524 | Encodes the byte array to a Base64 string.
525 |
526 |
527 |
528 |
529 | Decodes the Base64 string to a byte array.
530 |
531 |
532 |
533 |
534 | Represents a DateTime provider.
535 |
536 |
537 |
538 |
539 | Gets the current DateTime.
540 |
541 |
542 |
543 |
544 | Provides JSON Serialize and Deserialize. Allows custom serializers used.
545 |
546 |
547 |
548 |
549 | Serialize an object to JSON string
550 |
551 | object
552 | JSON string
553 |
554 |
555 |
556 | Deserialize a JSON string to typed object.
557 |
558 | type of object
559 | JSON string
560 | Strongly-typed object
561 |
562 |
563 |
564 | Represents a JWT decoder.
565 |
566 |
567 |
568 |
569 | Given a JWT, decodes it and return the header.
570 |
571 | The JWT
572 |
573 |
574 |
575 | Given a JWT, decodes it and return the header as an object.
576 |
577 | The JWT
578 |
579 |
580 |
581 | Given a JWT, decodes it and return the payload.
582 |
583 | The JWT
584 | A string containing the JSON payload
585 |
586 |
587 |
588 | Given a JWT, decodes it and return the payload.
589 |
590 | The JWT
591 | The key that were used to sign the JWT
592 | Whether to verify the signature (default is true)
593 | A string containing the JSON payload
594 |
595 |
596 |
597 | Given a JWT, decodes it and return the payload.
598 |
599 | The JWT
600 | The keys provided which one of them was used to sign the JWT
601 | Whether to verify the signature (default is true)
602 | A string containing the JSON payload
603 |
604 |
605 |
606 | Given a JWT, decodes it and return the payload as an object.
607 |
608 | The type to return
609 | The JWT
610 | An object representing the payload
611 |
612 |
613 |
614 | Given a JWT, decodes it and return the payload as an object.
615 |
616 | The type to return
617 | The JWT
618 | The key that was used to sign the JWT
619 | Whether to verify the signature (default is true)
620 | An object representing the payload
621 |
622 |
623 |
624 | Given a JWT, decodes it and return the payload as an object.
625 |
626 | The type to return
627 | The JWT
628 | The keys which one of them was used to sign the JWT
629 | Whether to verify the signature (default is true)
630 | An object representing the payload
631 |
632 |
633 |
634 | Extension methods for
635 |
636 |
637 |
638 |
639 | Given a JWT, decodes it and return the payload.
640 |
641 | The decoder instance
642 | The JWT
643 | A string containing the JSON payload
644 |
645 |
646 |
647 |
648 |
649 |
650 | Given a JWT, decodes it and return the payload.
651 |
652 | The decoder instance
653 | The JWT
654 | A string containing the JSON payload
655 |
656 |
657 |
658 | Given a JWT, decodes it and return the payload.
659 |
660 | The decoder instance
661 | The JWT
662 | The key that was used to sign the JWT
663 | Whether to verify the signature (default is true)
664 | A string containing the JSON payload
665 |
666 |
667 |
668 |
669 |
670 |
671 | Given a JWT, decodes it and return the payload.
672 |
673 | The decoder instance
674 | The JWT
675 | The keys that were used to sign the JWT
676 | Whether to verify the signature (default is true)
677 | A string containing the JSON payload
678 |
679 |
680 |
681 |
682 |
683 |
684 | Given a JWT, decodes it and return the payload as an dictionary.
685 |
686 | The decoder instance
687 | The JWT
688 | The key that was used to sign the JWT
689 | Whether to verify the signature (default is true)
690 | An object representing the payload
691 |
692 |
693 |
694 |
695 |
696 | Given a JWT, decodes it and return the payload as an dictionary.
697 |
698 | The decoder instance
699 | The JWT
700 | The key which one of them was used to sign the JWT
701 | Whether to verify the signature (default is true)
702 | An object representing the payload
703 |
704 |
705 |
706 |
707 |
708 | Given a JWT, decodes it and return the payload as an object.
709 |
710 | The type to return
711 | The decoder instance
712 | The JWT
713 | An object representing the payload
714 |
715 |
716 |
717 | Given a JWT, decodes it and return the payload as a dictionary.
718 |
719 | The decoder instance
720 | The JWT
721 | An object representing the payload
722 |
723 |
724 |
725 | Given a JWT, decodes it and return the payload as a dictionary.
726 |
727 | The decoder instance
728 | The JWT
729 | The key that was used to sign the JWT
730 | Whether to verify the signature (default is true)
731 | An object representing the payload
732 |
733 |
734 |
735 |
736 |
737 |
738 | Given a JWT, decodes it and return the payload as a dictionary.
739 |
740 | The decoder instance
741 | The JWT
742 | The keys that were used to sign the JWT
743 | Whether to verify the signature (default is true)
744 | A string containing the JSON payload
745 |
746 |
747 |
748 |
749 |
750 |
751 | Given a JWT, decodes it and return the payload as an object.
752 |
753 | The type to return
754 | The decoder instance
755 | The JWT
756 | The key that was used to sign the JWT
757 | Whether to verify the signature (default is true)
758 | An object representing the payload
759 |
760 |
761 |
762 | Given a JWT, decodes it and return the payload as an object.
763 |
764 | The type to return
765 | The decoder instance
766 | The JWT
767 | The key that was used to sign the JWT
768 | Whether to verify the signature (default is true)
769 | An object representing the payload
770 |
771 |
772 |
773 | Given a JWT, decodes it and return the payload as an object.
774 |
775 | The type to return
776 | The decoder instance
777 | The JWT
778 | The keys provided which one of them was used to sign the JWT
779 | Whether to verify the signature (default is true)
780 | An object representing the payload
781 |
782 |
783 |
784 | Given a JWT, decodes it and return the payload as an object.
785 |
786 | The type to return
787 | The decoder instance
788 | The JWT
789 | The keys provided which one of them was used to sign the JWT
790 | Whether to verify the signature (default is true)
791 | An object representing the payload
792 |
793 |
794 |
795 | Represents a JWT encoder.
796 |
797 |
798 |
799 |
800 | Creates a JWT given a header, a payload, the signing key, and the algorithm to use.
801 |
802 | An arbitrary set of extra headers. Will be augmented with the standard "typ" and "alg" headers
803 | An arbitrary payload (must be serializable to JSON)
804 | The key bytes used to sign the token
805 | The generated JWT
806 |
807 |
808 |
809 | Extension methods for
810 |
811 |
812 |
813 |
814 | Creates a JWT given a payload, the signing key, and the algorithm to use.
815 |
816 | The encoder instance
817 | An arbitrary payload (must be serializable to JSON)
818 | The key used to sign the token
819 | The generated JWT
820 |
821 |
822 |
823 |
824 | Creates a JWT given a payload, the signing key, and the algorithm to use.
825 |
826 | The encoder instance
827 | An arbitrary payload (must be serializable to JSON)
828 | The key used to sign the token
829 | The generated JWT
830 |
831 |
832 |
833 |
834 | Creates a JWT given a set of arbitrary extra headers, a payload, the signing key, and the algorithm to use.
835 |
836 | The encoder instance
837 | An arbitrary set of extra headers. Will be augmented with the standard "typ" and "alg" headers
838 | An arbitrary payload (must be serializable to JSON)
839 | The key bytes used to sign the token
840 | The generated JWT
841 |
842 |
843 |
844 |
845 | Represents a JWT validator.
846 |
847 |
848 |
849 |
850 | Given the JWT, verifies its signature correctness.
851 |
852 | >An arbitrary payload (already serialized to JSON)
853 | Decoded body
854 | The signatures to validate with
855 |
856 |
857 |
858 | Given the JWT, verifies its signature correctness.
859 |
860 |
861 | Used by the asymmetric algorithms only.
862 |
863 | >An arbitrary payload (already serialized to JSON)
864 | The asymmetric algorithm to validate with
865 | The header and payload bytes to validate
866 | The signature to validate with
867 |
868 |
869 |
870 | Given the JWT, verifies its signature correctness without throwing an exception but returning it instead.
871 |
872 | >An arbitrary payload (already serialized to JSON)
873 | Decoded body
874 | The signature to validate with
875 | The resulting validation exception, if any
876 | Returns true if exception is JWT is valid and exception is null, otherwise false
877 |
878 |
879 |
880 | Given the JWT, verifies its signature correctness without throwing an exception but returning it instead.
881 |
882 | >An arbitrary payload (already serialized to JSON)
883 | Decoded body
884 | The signatures to validate with
885 | The resulting validation exception, if any
886 | Returns true if exception is JWT is valid and exception is null, otherwise false
887 |
888 |
889 |
890 | Given the JWT, verifies its signatures correctness without throwing an exception but returning it instead.
891 |
892 | >An arbitrary payload (already serialized to JSON)
893 | The asymmetric algorithm to validate with
894 | The header and payload bytes to validate
895 | The decodedSignatures to validate with
896 | Validation exception, if any
897 | True if exception is JWT is valid and exception is null, otherwise false
898 |
899 |
900 |
901 | Base64 encoding/decoding implementation according to the JWT spec
902 |
903 |
904 |
905 |
906 |
907 |
908 |
909 |
910 |
911 |
912 |
913 |
914 |
915 |
916 | Decodes JWT.
917 |
918 |
919 |
920 |
921 | Creates an instance of
922 |
923 |
924 | This overload supplies no and no so the resulting decoder cannot be used for signature validation.
925 |
926 | The Json Serializer
927 | The Base64 URL Encoder
928 |
929 |
930 |
931 |
932 | Creates an instance of
933 |
934 | The Json Serializer
935 | The Jwt validator
936 | The Base64 URL Encoder
937 | The Algorithm Factory
938 |
939 |
940 |
941 |
942 | Creates an instance of
943 |
944 | The Json Serializer
945 | The Jwt validator
946 | The Base64 URL Encoder
947 | The Algorithm
948 |
949 |
950 |
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
962 |
963 |
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 |
973 |
974 |
975 |
976 |
977 |
978 |
979 |
980 |
981 |
982 |
983 |
984 |
985 |
986 |
987 |
988 |
989 |
990 |
991 |
992 |
993 |
994 |
995 |
996 |
997 |
998 |
999 |
1000 |
1001 |
1002 |
1003 |
1004 |
1005 |
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 | Prepares data before calling
1013 |
1014 | The array representation of a JWT
1015 | The key that was used to sign the JWT
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 | Prepares data before calling
1025 |
1026 | The array representation of a JWT
1027 | The keys provided which one of them was used to sign the JWT
1028 |
1029 |
1030 |
1031 |
1032 |
1033 |
1034 |
1035 |
1036 | Prepares data before calling
1037 |
1038 | The JWT parts
1039 | The keys provided which one of them was used to sign the JWT
1040 |
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1047 |
1048 |
1049 | Unmodified JWT.
1050 |
1051 |
1052 |
1053 |
1054 | Deserialized JWT header.
1055 |
1056 |
1057 |
1058 |
1059 | Decoded JWT payload.
1060 |
1061 |
1062 |
1063 |
1064 | Encodes Jwt.
1065 |
1066 |
1067 |
1068 |
1069 | Creates an instance of
1070 |
1071 | The Json Serializer
1072 | The Jwt Algorithm
1073 | The Base64 URL Encoder
1074 |
1075 |
1076 |
1077 |
1078 |
1079 |
1080 |
1081 | Represent the parts of a JWT
1082 |
1083 |
1084 |
1085 |
1086 | Creates a new instance of from the string representation of a JWT
1087 |
1088 | The string representation of a JWT
1089 |
1090 |
1091 |
1092 |
1093 |
1094 | Creates a new instance of from the array representation of a JWT
1095 |
1096 | The array representation of a JWT
1097 |
1098 |
1099 |
1100 |
1101 |
1102 | Gets the Header part of a JWT
1103 |
1104 |
1105 |
1106 |
1107 | Gets the Payload part of a JWT
1108 |
1109 |
1110 |
1111 |
1112 | Gets the Signature part of a JWT
1113 |
1114 |
1115 |
1116 |
1117 | Gets the parts of a JWT
1118 |
1119 |
1120 |
1121 |
1122 | Helper enum to get the correct part from the array representation of a JWT parts
1123 |
1124 |
1125 |
1126 |
1127 | Jwt validator.
1128 |
1129 |
1130 |
1131 |
1132 | Creates an instance of
1133 |
1134 | The Json Serializer
1135 | The DateTime Provider
1136 |
1137 |
1138 |
1139 |
1140 |
1141 |
1142 |
1143 |
1144 |
1145 |
1146 |
1147 |
1148 |
1149 |
1150 |
1151 |
1152 |
1153 |
1154 |
1155 |
1156 |
1157 |
1158 |
1159 |
1160 | In the future this method can be opened for extension hence made protected virtual
1161 |
1162 |
1163 |
1164 | Verifies the 'exp' claim.
1165 |
1166 | See https://tools.ietf.org/html/rfc7515#section-4.1.4
1167 |
1168 |
1169 |
1170 |
1171 |
1172 | Verifies the 'nbf' claim.
1173 |
1174 | See https://tools.ietf.org/html/rfc7515#section-4.1.5
1175 |
1176 |
1177 |
1178 |
1179 | JSON serializer using Newtonsoft.Json implementation.
1180 |
1181 |
1182 |
1183 |
1184 | Creates a new instance of
1185 |
1186 | Uses as internal serializer
1187 |
1188 |
1189 |
1190 | Creates a new instance of
1191 |
1192 | Internal to use for serialization
1193 |
1194 |
1195 |
1196 |
1197 |
1198 |
1199 |
1200 |
1201 |
1202 | Describes a point in time, defined as the number of seconds that have elapsed since 00:00:00 UTC, Thursday, 1 January 1970, not counting leap seconds.
1203 | See https://en.wikipedia.org/wiki/Unix_time />
1204 |
1205 |
1206 |
1207 |
1208 | Provider for UTC DateTime.
1209 |
1210 |
1211 |
1212 |
1213 | Retuns the current time (UTC).
1214 |
1215 |
1216 |
1217 |
1218 |
1219 |
--------------------------------------------------------------------------------
/public/ConvertFrom-JWT.ps1:
--------------------------------------------------------------------------------
1 | Function ConvertFrom-JWT {
2 | [CmdletBinding()]
3 | [OutputType([string])]
4 | Param
5 | (
6 | [Parameter(Mandatory = $true)]
7 | [string]
8 | $Token
9 | )
10 |
11 | begin {
12 | #region initialize Decoder Object
13 | $Serializer = [JWT.Serializers.JsonNetSerializer]::new()
14 | $Provider = [JWT.UtcDateTimeProvider]::new()
15 | $Validator = [JWT.JwtValidator]::new($Serializer, $provider)
16 | $Algorithm = [JWT.Algorithms.HMACSHA256Algorithm]::new()
17 | $UrlEncoder = [JWT.JwtBase64UrlEncoder]::new()
18 |
19 | $Decoder = [JWT.JwtDecoder]::new($Serializer, $Validator, $UrlEncoder, $Algorithm)
20 | #endregion
21 | }
22 | process {
23 | #region Decode JWT Token
24 |
25 | return [PSCustomObject]@{
26 | 'Header' = ($Decoder.DecodeHeader($token) | ConvertFrom-Json)
27 | 'Payload' = ($Decoder.Decode($Token) | ConvertFrom-Json)
28 | }
29 | #endregion
30 | }
31 | end {
32 | Remove-Variable -Name Decoder
33 | }
34 | }
--------------------------------------------------------------------------------
/public/ConvertTo-JWT.ps1:
--------------------------------------------------------------------------------
1 | Function ConvertTo-JWT {
2 | [CmdletBinding()]
3 | [OutputType([string])]
4 | Param
5 | (
6 | [Parameter(Mandatory = $true,
7 | ValueFromPipeline = $true)]
8 | [HashTable]
9 | $PayLoad,
10 | [Parameter(Mandatory = $false)]
11 | [HashTable]
12 | $Header,
13 | [Parameter(Mandatory = $true)]
14 | [String]
15 | $Secret
16 | )
17 |
18 | begin {
19 | #region initialize Encoder Object
20 | $Algorithm = [JWT.Algorithms.HMACSHA256Algorithm]::new()
21 | $Serializer = [JWT.Serializers.JsonNetSerializer]::new()
22 | $UrlEncoder = [JWT.JwtBase64UrlEncoder]::new()
23 |
24 | $Encoder = [JWT.JwtEncoder]::new($Algorithm, $Serializer, $UrlEncoder)
25 | #endregion
26 | }
27 | process {
28 | #region Encode JWT Token
29 | if ($Header) {
30 | $extraHeaders = [Collections.Generic.Dictionary[string, object]]::new()
31 | $Header.GetEnumerator() | ForEach-Object { $extraHeaders.Add(([string]$_.Key), $_.Value) }
32 | $result = $Encoder.Encode($extraHeaders, $PayLoad, [system.Text.Encoding]::UTF8.GetBytes($Secret))
33 | }
34 | else {
35 | $extraHeaders = [Collections.Generic.Dictionary[string, object]]::new()
36 | $result = $Encoder.Encode($extraHeaders, $PayLoad, [system.Text.Encoding]::UTF8.GetBytes($Secret))
37 | }
38 |
39 | return $result
40 | #endregion
41 | }
42 | end {
43 | Remove-Variable -Name Encoder
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/tests/PSJwt.tests.ps1:
--------------------------------------------------------------------------------
1 | $ModulePath = Split-Path -Parent -Path (Split-Path -Parent -Path $MyInvocation.MyCommand.Path)
2 | $ModuleName = 'PSJwt'
3 | $ManifestPath = "$ModulePath\$ModuleName.psd1"
4 | if (Get-Module -Name $ModuleName) {
5 | Remove-Module $ModuleName -Force
6 | }
7 | Import-Module $ManifestPath -Verbose:$false
8 |
9 |
10 | # test the module manifest - exports the right functions, processes the right formats, and is generally correct
11 | Describe -Name 'Manifest' -Fixture {
12 | $ManifestHash = Invoke-Expression -Command (Get-Content $ManifestPath -Raw)
13 |
14 | It -name 'has a valid manifest' -test {
15 | {
16 | $null = Test-ModuleManifest -Path $ManifestPath -ErrorAction Stop -WarningAction SilentlyContinue
17 | } | Should Not Throw
18 | }
19 |
20 | It -name 'has a valid root module' -test {
21 | $ManifestHash.RootModule | Should Be "$ModuleName.psm1"
22 | }
23 |
24 | It -name 'has a valid Description' -test {
25 | $ManifestHash.Description | Should Not BeNullOrEmpty
26 | }
27 |
28 | It -name 'has a valid guid' -test {
29 | $ManifestHash.Guid | Should Be '6934ef7a-f360-4d10-8e61-471823ec44c1'
30 | }
31 |
32 | It -name 'has a valid version' -test {
33 | $ManifestHash.ModuleVersion -as [Version] | Should Not BeNullOrEmpty
34 | }
35 |
36 | It -name 'has a valid copyright' -test {
37 | $ManifestHash.CopyRight | Should Not BeNullOrEmpty
38 | }
39 |
40 | It -name 'has a valid license Uri' -test {
41 | $ManifestHash.PrivateData.Values.LicenseUri | Should Be 'http://opensource.org/licenses/MIT'
42 | }
43 |
44 | It -name 'has a valid project Uri' -test {
45 | $ManifestHash.PrivateData.Values.ProjectUri | Should Be 'https://github.com/stefanstranger/PSJwt'
46 | }
47 |
48 | It -name "gallery tags don't contain spaces" -test {
49 | foreach ($Tag in $ManifestHash.PrivateData.Values.tags) {
50 | $Tag -notmatch '\s' | Should Be $true
51 | }
52 | }
53 | }
54 |
55 |
56 | Describe -Name 'Module PSJwt works' -Fixture {
57 | It -name 'Passed Module load' -test {
58 | Get-Module -Name 'PSJwt' | Should Not Be $null
59 | }
60 | }
61 |
62 |
63 | Describe -Name 'Test Functions in PSJwt Module' -Fixture {
64 | Context -Name 'Testing Public Functions' -Fixture {
65 |
66 | It -name 'Passes ConvertFrom-JWT Function for Payload' -test {
67 | $Token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJGaXJzdE5hbWUiOiJTdGVmYW4iLCJMYXN0TmFtZSI6IlN0cmFuZ2VyIiwiRGVtbyI6IkVuY29kZSBBY2Nlc3MgVG9rZW4iLCJleHAiOjEzOTMyODY4OTMsImlhdCI6MTM5MzI2ODg5M30.8-YqAPPth3o-C_xO9WFjW5RViAnDe2WrmVyqLRnNEV0'
68 | (ConvertFrom-JWT -Token $Token).PayLoad.Demo | Should Be 'Encode Access Token'
69 | }
70 |
71 | It -name 'Passes ConvertFrom-JWT Function for extra Header' -test {
72 | $Token = 'eyJFbnYiOiJEZW1vIiwidHlwIjoiSldUIiwiYWxnIjoiSFMyNTYifQ.eyJpYXQiOiIxMzkzMjY4ODkzIiwiRGVtbyI6IkVuY29kZSBBY2Nlc3MgVG9rZW4iLCJGaXJzdE5hbWUiOiJTdGVmYW4iLCJleHAiOiIxMzkzMjg2ODkzIiwiTGFzdE5hbWUiOiJTdHJhbmdlciJ9.JFJVUaBIUJmHQUawkK1dH5Iie8tSTTXKFbZZka3_k7Y'
73 | (ConvertFrom-JWT -Token $Token).Header.Env | Should Be 'Demo'
74 | }
75 |
76 | It -name 'Passes ConvertTo-JWT Function without extra header' -test {
77 | $Secret = 'qwerty'
78 | $Result = ( @{'FirstName' = 'Stefan'; 'LastName' = 'Stranger'; 'Demo' = 'Encode Access Token'; 'exp' = '1393286893'; 'iat' = '1393268893'} | ConvertTo-Jwt -secret $secret)
79 | $Result.Length | Should Be 229
80 | }
81 |
82 | It -name 'Passes ConvertTo-JWT Function with extra header' -test {
83 | $Secret = 'qwerty'
84 | $Header = @{'Env' = 'Demo'}
85 | $Result = ( @{'FirstName' = 'Stefan'; 'LastName' = 'Stranger'; 'Demo' = 'Encode Access Token'; 'exp' = '1393286893'; 'iat' = '1393268893'} | ConvertTo-Jwt -Header $Header -secret $secret)
86 | $Result.Length | Should Be 247
87 | }
88 | }
89 | }
--------------------------------------------------------------------------------