Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.9.0 #1176

Merged
merged 85 commits into from
Oct 30, 2023
Merged

v2.9.0 #1176

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
9b1456e
fix for choco packer
Badgerati Feb 3, 2023
b0f0dcc
Fix: Test-PodeJwt comparison against Local/Unspecified Kind
avin3sh Mar 6, 2023
613e5de
Allowing JSON depth >10 in Save/Restore Pode state cmdlets
plk Apr 22, 2023
440aae0
Fix casing
plk Apr 23, 2023
70862b6
Merge pull request #1084 from avin3sh/develop
Badgerati Apr 24, 2023
2e7e069
Merge pull request #1094 from plk/develop
Badgerati Apr 24, 2023
34045a6
#1106: Add helper security functions to hide/show the Server header
Badgerati Jul 7, 2023
a587d75
Merge pull request #1111 from Badgerati/Issue-1106
Badgerati Jul 8, 2023
9af23b4
#1081: Don't parse Query String if there is no Query String
Badgerati Jul 8, 2023
bf54a47
Merge pull request #1113 from Badgerati/Issue-1081
Badgerati Jul 8, 2023
2e448b8
#1107, #1082: Add new Running event, which triggers after Start when …
Badgerati Jul 8, 2023
9884114
Clean-up from review
Badgerati Jul 8, 2023
8398bf0
Merge pull request #1114 from Badgerati/Issue-1107
Badgerati Jul 8, 2023
cfad91b
fix port
ArieHein Jul 9, 2023
638891e
fix comment
ArieHein Jul 9, 2023
e975841
Mardown style changes
ArieHein Jul 9, 2023
05136a7
Markdown fixes
ArieHein Jul 9, 2023
114a149
Markdown fixes
ArieHein Jul 9, 2023
1cf91cd
Merge pull request #1115 from ArieHein/patch-1
Badgerati Jul 16, 2023
22405b0
Merge pull request #1116 from ArieHein/patch-2
Badgerati Jul 16, 2023
4912ec6
Merge pull request #1117 from ArieHein/patch-3
Badgerati Jul 16, 2023
a82f07b
Merge pull request #1118 from ArieHein/patch-4
Badgerati Jul 16, 2023
1d97f9b
Merge pull request #1119 from ArieHein/patch-5
Badgerati Jul 16, 2023
b8165e1
#992: initial work for authorization middleware
Badgerati Aug 5, 2023
b576a64
#992: added support for custom access validation
Badgerati Aug 7, 2023
02080bd
#992: tweak to the functions, it's now Add-PodeAuthAccess with a re-u…
Badgerati Aug 14, 2023
5780b18
#992: added User based authorisation as an inbuilt type from Pode.Web
Badgerati Aug 15, 2023
bc4f5a3
#992: add function summaries
Badgerati Aug 16, 2023
78a4e1a
#992: fix unit test
Badgerati Aug 16, 2023
3691990
#992: add authorisation docs
Badgerati Aug 20, 2023
a5dab78
#992: update authorisation docs for multiple methods
Badgerati Aug 20, 2023
9b9849c
#992: fix missing function parameter summary
Badgerati Aug 20, 2023
a86bbb9
Merge pull request #1126 from Badgerati/Issue-992
Badgerati Aug 20, 2023
a026ed6
#1125: fix verb cleardown on server restart
Badgerati Aug 20, 2023
60de12e
Merge pull request #1127 from Badgerati/Issue-1125
Badgerati Aug 20, 2023
a1da354
Fixed links to Lock-PodeState docs
Chris--A Aug 25, 2023
0dbebb0
Update RestApiSessions.md
Chris--A Aug 28, 2023
e44d052
Update Sessions.md
Chris--A Aug 28, 2023
8d6dae7
Update 0X-to-1X.md
Chris--A Aug 28, 2023
2d18e84
Update LoginPage.md
Chris--A Aug 28, 2023
f9cc3a7
Merge pull request #1133 from Chris--A/Chris--A-patch-1
Badgerati Sep 4, 2023
e8f1437
#588: initial work for supporting 'merging' auth methods
Badgerati Sep 18, 2023
1d8428d
#588: allows for merging of access methods as well
Badgerati Sep 28, 2023
e1b601f
#1142 | Make the Test-PodeJwt function Public
alan-null Oct 2, 2023
c3683e5
#588: add function summaries
Badgerati Oct 2, 2023
e362262
#588: fix auth tests and null headers
Badgerati Oct 3, 2023
0f151b0
#588: added test cases, fixed auth scoping issue with access
Badgerati Oct 4, 2023
cc2b370
#588: update docs
Badgerati Oct 5, 2023
fe9b7dd
#588: fixes from review
Badgerati Oct 7, 2023
c327eb6
Merge pull request #1146 from Badgerati/Issue-588
Badgerati Oct 7, 2023
519cbdd
Merge pull request #1145 from alan-null/issue/1142
Badgerati Oct 7, 2023
f68becd
#1137: fix the loading of AutoImport config
Badgerati Oct 7, 2023
ec82a3e
Merge pull request #1147 from Badgerati/Issue-1137
Badgerati Oct 7, 2023
5e28e2f
#1101: allow SSL protocols to be set on Add-PodeEndpoint
Badgerati Oct 7, 2023
1b01680
#1101: update docs to add SSL protos mention in Endpoints docs
Badgerati Oct 7, 2023
36e4711
#1101: this one test is driving me nuts now
Badgerati Oct 7, 2023
c3fbb59
Merge pull request #1148 from Badgerati/Issue-1101
Badgerati Oct 7, 2023
11c90d2
#1087: fix parsing of SMTP headers when there are multiple
Badgerati Oct 7, 2023
40a791d
Merge pull request #1149 from Badgerati/Issue-1087
Badgerati Oct 7, 2023
fbcf4b4
#1141: update IIS docs for max worker processes
Badgerati Oct 7, 2023
1f72176
#1123: add link to SecretManagement automation docs
Badgerati Oct 7, 2023
90055d4
#1099: reference the Protected Users group in Windows AD
Badgerati Oct 7, 2023
6494384
Merge pull request #1150 from Badgerati/Issue-1141
Badgerati Oct 7, 2023
2ce7d02
Merge pull request #1151 from Badgerati/Issue-1123
Badgerati Oct 7, 2023
2d2c137
Merge pull request #1152 from Badgerati/Issue-1099
Badgerati Oct 7, 2023
6342588
#1078: add dates to release notes
Badgerati Oct 7, 2023
589f44f
Merge pull request #1153 from Badgerati/Issue-1078
Badgerati Oct 7, 2023
9ae1a52
#1130: when available, add the username to the request log output
Badgerati Oct 8, 2023
c26902e
#1130: update logs
Badgerati Oct 8, 2023
27ca58e
Merge pull request #1162 from Badgerati/Issue-1130
Badgerati Oct 8, 2023
cd66136
#1163: add initial session auth func
Badgerati Oct 8, 2023
30fe4a9
#1163: slight rewrite of access logic: move to own file out of auth, …
Badgerati Oct 11, 2023
1ca29ee
Merge pull request #1166 from Badgerati/Issue-1163
Badgerati Oct 12, 2023
31c8670
#1030: allow UsersFile, WindowsAd, and WindowsLocal auths work with -…
Badgerati Oct 12, 2023
822960f
Merge pull request #1167 from Badgerati/Issue-1030
Badgerati Oct 12, 2023
3a7ce1c
#1169: add vscode workspace settings for pwsh code formatting
Badgerati Oct 17, 2023
9388cf5
#1169: reformats the src powershell files using the auto code-formatter
Badgerati Oct 17, 2023
6243fe2
Merge pull request #1172 from Badgerati/Issue-1169
Badgerati Oct 17, 2023
b8dd623
#1170: bump images in dockerfiles
Badgerati Oct 17, 2023
c4439d5
#1171: bump mkdocs and theme versions
Badgerati Oct 17, 2023
e0f7e66
Merge pull request #1173 from Badgerati/Issue-1170
Badgerati Oct 17, 2023
3febc77
Merge pull request #1174 from Badgerati/Issue-1171
Badgerati Oct 17, 2023
dc15078
add v2.9.0 release notes
Badgerati Oct 24, 2023
d1a70d4
minor tweaks to release notes
Badgerati Oct 24, 2023
7459f73
add 2.9.0 release date
Badgerati Oct 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 35 additions & 34 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,34 @@ The following is a set of guidelines for contributing to Pode on GitHub. These a

## Table of Contents

* [Code of Conduct](#code-of-conduct)
* [I just have a Question](#i-just-have-a-question)
* [About Pode](#about-pode)
* [How to Contribute](#how-to-contribute)
* [Issues](#issues)
* [Branch Names](#branch-names)
* [Pull Requests](#pull-requests)
* [Building](#building)
* [Testing](#testing)
* [Documentation](#documentation)
* [Styleguide](#styleguide)
* [Code](#code)
* [Comments](#comments)
* [General](#general)
* [Help](#help)
* [PowerShell Commandlets](#powershell-commandlets)
* [Foreach-Object](#foreach-object)
* [Where-Object](#where-object)
* [Select-Object](#select-object)
* [Measure-Object](#measure-object)
- [Contributing to Pode](#contributing-to-pode)
- [Table of Contents](#table-of-contents)
- [Code of Conduct](#code-of-conduct)
- [I just have a Question](#i-just-have-a-question)
- [About Pode](#about-pode)
- [How to Contribute](#how-to-contribute)
- [Issues](#issues)
- [Branch Names](#branch-names)
- [Pull Requests](#pull-requests)
- [Building](#building)
- [Testing](#testing)
- [Documentation](#documentation)
- [Importing](#importing)
- [Styleguide](#styleguide)
- [Editor](#editor)
- [Code](#code)
- [Comments](#comments)
- [General](#general)
- [Help](#help)
- [PowerShell Commandlets](#powershell-commandlets)
- [Foreach-Object](#foreach-object)
- [Where-Object](#where-object)
- [Select-Object](#select-object)
- [Measure-Object](#measure-object)

## Code of Conduct

This project and everyone participating in it is governed by the Pode's [Code of Conduct](../.github/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
This project, and everyone participating in it, is governed by the Pode's [Code of Conduct](../.github/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.

## I just have a Question

Expand Down Expand Up @@ -111,22 +115,20 @@ When editing Pode and you need to import the local dev module for testing, you w

## Styleguide

### Editor

You can use whatever editor you like, but it's recommended to use Visual Studio Code. To help with this style guide, specifically for PowerShell, Pode has code formatting workspace setting which will automatically format the files on save.

### Code

In general, observe the coding style used within the file/project and mimic that as best as you can. Some standards that are typical are:

* Bracers (`{}`) on the function header should be on a new line, such as:
* Bracers (`{}`) should be on the same line of the statement they following, such as `function`, `foreach`, `if`, etc.
```powershell
function Add-Something
{
# logic
}
```

* Bracers (`{}`) should be on the same line of other calls, such as `foreach`, `if`, etc.
```powershell
foreach ($item in $items) {
# logic
function Add-Something {
foreach ($item in $items) {
# logic
}
}
```

Expand All @@ -135,8 +137,7 @@ foreach ($item in $items) {
* Ensure public functions always declare `[CmdletBinding()]` attribute.
* Ensure parameter names, types, and attributes are declared on new lines - not all on one line.
```powershell
function Add-Something
{
function Add-Something {
[CmdletBinding()]
param(
[Parameter()]
Expand Down
24 changes: 24 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"editor.formatOnSave": true,
"editor.formatOnType": false,
"editor.minimap.enabled": false,
"powershell.codeFormatting.addWhitespaceAroundPipe": true,
"powershell.codeFormatting.alignPropertyValuePairs": true,
"powershell.codeFormatting.autoCorrectAliases": true,
"powershell.codeFormatting.avoidSemicolonsAsLineTerminators": true,
"powershell.codeFormatting.ignoreOneLineBlock": true,
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline",
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
"powershell.codeFormatting.useConstantStrings": true,
"powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
"powershell.codeFormatting.whitespaceAroundOperator": true,
"powershell.codeFormatting.whitespaceAfterSeparator": true,
"powershell.codeFormatting.useCorrectCasing": false,
"powershell.codeFormatting.openBraceOnSameLine": true,
"powershell.codeFormatting.newLineAfterOpenBrace": true,
"powershell.codeFormatting.newLineAfterCloseBrace": true,
"powershell.codeFormatting.whitespaceBeforeOpenParen": true,
"powershell.codeFormatting.whitespaceBetweenParameters": false,
"powershell.codeFormatting.whitespaceInsideBrace": true,
"files.trimTrailingWhitespace": true
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Then navigate to `http://127.0.0.1:8000` in your browser.
* Basic rate limiting for IP addresses and subnets
* Middleware and Sessions on web servers, with Flash message and CSRF support
* Authentication on requests, such as Basic, Windows and Azure AD
* Authorisation support on requests, using Roles, Groups, Scopes, etc.
* Support for dynamically building Routes from Functions and Modules
* Generate/bind self-signed certificates
* Secret management support to load secrets from vaults
Expand Down
2 changes: 1 addition & 1 deletion alpine.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/powershell:7.3-alpine-3.15
FROM mcr.microsoft.com/powershell:7.3-alpine-3.17
LABEL maintainer="Matthew Kelly (Badgerati)"
RUN mkdir -p /usr/local/share/powershell/Modules/Pode
COPY ./pkg/ /usr/local/share/powershell/Modules/Pode
2 changes: 1 addition & 1 deletion arm32.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/powershell:preview-7.3-arm32v7-ubuntu-18.04
FROM mcr.microsoft.com/powershell:7.3-ubuntu-22.04-arm32
LABEL maintainer="Matthew Kelly (Badgerati)"
RUN mkdir -p /usr/local/share/powershell/Modules/Pode
COPY ./pkg/ /usr/local/share/powershell/Modules/Pode
2 changes: 1 addition & 1 deletion docs/Getting-Started/Migrating/0X-to-1X.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ There is a new [`New-PodeMiddleware`](../../../Functions/Middleware/New-PodeMidd

([Tutorial](../../../Tutorials/Middleware/Types/Sessions))

The `session` function has now been replaced by the new [`Enable-PodeSessionMiddleware`](../../../Functions/Middleware/Enable-PodeSessionMiddleware) function. With the new function, not only will it automatically enabled session middleware for you, but the old `-Options` hashtable has now been converted into proper function parameters.
The `session` function has now been replaced by the new [`Enable-PodeSessionMiddleware`](../../../Functions/Sessions/Enable-PodeSessionMiddleware) function. With the new function, not only will it automatically enabled session middleware for you, but the old `-Options` hashtable has now been converted into proper function parameters.

### CSRF

Expand Down
4 changes: 4 additions & 0 deletions docs/Hosting/IIS.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ This allows you to write a Pode server that works locally, but will also automat
!!! note
This does mean that Pode will force all endpoints to `127.0.0.1:PORT`. So if you had two different IPs before, they'll be merged into one. Something to be aware of if you assign routes to specific endpoints, as under IIS this won't work.

### Maximum Worker Processes

Unless you're using an external data store for sessions, ensure the Maximum Worker Processes is 1. Each worker process will spawn a new instance of your Pode server, and if using Pode's inbuilt session storage you'll face authenticated/session timeout issues when one instance doesn't contain the right session.

### Advanced/Domain/Kerberos

The above IIS site setup works, but only for simple sites. If you require the use of the Active Directory module, or your site to be running as a different user then follow the steps below.
Expand Down
6 changes: 5 additions & 1 deletion docs/Tutorials/Authentication/Inbuilt/AzureAD.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ To setup and start using Azure AD authentication in Pode you use `New-PodeAuthAz

```powershell
Start-PodeServer {
Enable-PodeSessionMiddleware -Duration 120 -Extend

$scheme = New-PodeAuthAzureADScheme -ClientID '<clientId>' -ClientSecret '<clientSecret>' -Tenant '<tenant>'

$scheme | Add-PodeAuth -Name 'Login' -FailureUrl '/login' -SuccessUrl '/' -ScriptBlock {
Expand All @@ -63,6 +65,8 @@ To setup Azure AD authentcation, but using your own Form login, then you can use

```powershell
Start-PodeServer {
Enable-PodeSessionMiddleware -Duration 120 -Extend

$form = New-PodeAuthScheme -Form

$scheme = New-PodeAuthAzureADScheme -ClientID '<clientId>' -ClientSecret '<clientSecret>' -Tenant '<tenant>' -InnerScheme $form
Expand Down Expand Up @@ -97,7 +101,7 @@ The Pode side needs to be configured to allow basic authentication as well. This
$form = New-PodeAuthScheme -Form
$schemeForm = New-PodeAuthAzureADScheme -ClientID '<clientId>' -ClientSecret '<clientSecret>' -Tenant '<tenant>' -InnerScheme $form

$basic = New-PodeAuthSceme -Basic
$basic = New-PodeAuthScheme -Basic
$schemeBasic = New-PodeAuthAzureADScheme -ClientID '<clientId>' -ClientSecret '<clientSecret>' -Tenant '<tenant>' -InnerScheme $basic

$authLogin = {
Expand Down
59 changes: 59 additions & 0 deletions docs/Tutorials/Authentication/Inbuilt/Session.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Sessions

Pode has support for Sessions when using Authentication, by default if you call a Route with authentication and you already have a session on the request then you're "authenticated". If there's no session, then the authentication logic is invoked, and if the details are invalid you're redirected to a login screen.

If you have a need to use multiple authentication methods for login, and the user can chose the one they want, then on Routes there's no simple way of say which authentication is required. However, under the hood they all create a session object which can be used as a "shared" authentication method.

This sessions authenticator can be used to pass authentication if a valid session in on the request, or to automatically redirect to a login page if there is no valid session. Useful for if you're using multiple authentication methods the user can choose from.

## Usage

To add sessions authentication you can use [`Add-PodeAuthSession`](../../../../Functions/Authentication/Add-PodeAuthSession). The following example will validate a user's credentials on login using Form authentication, but the home page uses session authentication to just verify there's a valid session:

```powershell
Start-PodeServer {
# endpoint and view engine
Add-PodeEndpoint -Address * -Port 8085 -Protocol Http
Set-PodeViewEngine -Type Pode

# enable sessions
Enable-PodeSessionMiddleware -Duration 120 -Extend

# setup form auth for login
New-PodeAuthScheme -Form | Add-PodeAuth -Name 'FormAuth' -FailureUrl '/login' -SuccessUrl '/' -ScriptBlock {
param($username, $password)

# here you'd check a real user storage, this is just for example
if ($username -eq 'morty' -and $password -eq 'pickle') {
return @{ User = @{ Name = 'Morty' } }
}

return @{ Message = 'Invalid details supplied' }
}

# setup session auth for routes and logout
Add-PodeAuthSession -Name 'SessionAuth' -FailureUrl '/login'

# home page: use session auth, and redirect to login if no valid session
Add-PodeRoute -Method Get -Path '/' -Authentication SessionAuth -ScriptBlock {
Write-PodeViewResponse -Path 'auth-home'
}

# login page: use form auth here to actually verify the user's credentials
Add-PodeRoute -Method Get -Path '/login' -Authentication FormAuth -Login -ScriptBlock {
Write-PodeViewResponse -Path 'auth-login' -FlashMessages
}

# login check: again, use form auth
Add-PodeRoute -Method Post -Path '/login' -Authentication FormAuth -Login

# logout - use session auth here to purge the session
Add-PodeRoute -Method Post -Path '/logout' -Authentication SessionAuth -Logout
}
```

### User Object

If a valid session is found on the request, then the user object set at `$WebEvent.Auth.User` will take the form of which ever authentication method using for login.

The user object will simply be loaded from the session.
2 changes: 2 additions & 0 deletions docs/Tutorials/Authentication/Inbuilt/UserFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Start-PodeServer {
Regardless of whether the password is a standard SHA256 hash or HMAC hash, the hashed output should be a base64 string. The following functions will return the hashed value in the expected format:

**SHA256 HASH**:

```powershell
function ConvertTo-SHA256([string]$String)
{
Expand All @@ -73,6 +74,7 @@ function ConvertTo-SHA256([string]$String)
```

**HMAC HASH:**

```powershell
function ConvertTo-HMACSHA256([string]$String, [string]$Secret) {
$HMACSHA256 = New-Object System.Security.Cryptography.HMACSHA256
Expand Down
4 changes: 4 additions & 0 deletions docs/Tutorials/Authentication/Inbuilt/WindowsAD.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,7 @@ New-PodeAuthScheme -Form | Add-PodeAuthWindowsAd -Name 'Login' -ScriptBlock {
return @{ Message = 'Authorisation failed' }
}
```

## Protected Users

In Windows AD there is a "Protected Users" group that you can assign users into. If users in this group are trying to use your site, then they will fail authentication. Unfortunately, this is just a secure feature of Windows AD, and the only way around this is to take the affected users out of the Protected Users group.
2 changes: 1 addition & 1 deletion docs/Tutorials/Authentication/Methods/Bearer.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To start using Bearer authentication in Pode you can use `New-PodeAuthScheme -Be

```powershell
Start-PodeServer {
New-PodeAuthScheme -Bearer | Add-PodeAuth -Name 'Authenticate' -ScriptBlock {
New-PodeAuthScheme -Bearer | Add-PodeAuth -Name 'Authenticate' -Sessionless -ScriptBlock {
param($token)

# check if the token is valid, and get user
Expand Down
Loading
Loading