diff --git a/Dockerfile b/Dockerfile index 491887e92..aff807d09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/powershell:7.1.3-ubuntu-18.04 +FROM mcr.microsoft.com/powershell:7.1.4-ubuntu-20.04 LABEL maintainer="Matthew Kelly (Badgerati)" RUN mkdir -p /usr/local/share/powershell/Modules/Pode COPY ./pkg/ /usr/local/share/powershell/Modules/Pode \ No newline at end of file diff --git a/alpine.dockerfile b/alpine.dockerfile index b8a871013..30230d7a7 100644 --- a/alpine.dockerfile +++ b/alpine.dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/powershell:7.1.3-alpine-3.12-20210316 +FROM mcr.microsoft.com/powershell:7.1.4-alpine-3.12-20210819 LABEL maintainer="Matthew Kelly (Badgerati)" RUN mkdir -p /usr/local/share/powershell/Modules/Pode COPY ./pkg/ /usr/local/share/powershell/Modules/Pode \ No newline at end of file diff --git a/arm32.dockerfile b/arm32.dockerfile index 00cd0e443..c7aa45650 100644 --- a/arm32.dockerfile +++ b/arm32.dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/powershell:7.1.3-arm32v7-ubuntu-18.04-20210316 +FROM mcr.microsoft.com/powershell:7.1.4-arm32v7-ubuntu-18.04-20210819 LABEL maintainer="Matthew Kelly (Badgerati)" RUN mkdir -p /usr/local/share/powershell/Modules/Pode COPY ./pkg/ /usr/local/share/powershell/Modules/Pode \ No newline at end of file diff --git a/docs/Getting-Started/Installation.md b/docs/Getting-Started/Installation.md index 2bb880c15..0197fccf4 100644 --- a/docs/Getting-Started/Installation.md +++ b/docs/Getting-Started/Installation.md @@ -41,7 +41,7 @@ Install-Module -Name Pode [![Docker](https://img.shields.io/docker/stars/badgerati/pode.svg?label=Stars)](https://hub.docker.com/r/badgerati/pode/) [![Docker](https://img.shields.io/docker/pulls/badgerati/pode.svg?label=Pulls)](https://hub.docker.com/r/badgerati/pode/) -Pode can run on *nix environments, therefore it only makes sense for there to be Docker images for you to use! The images use PowerShell v7.1.3 on either an Ubuntu Bionic image (default), an Alpine image, or an ARM32 image (for Raspberry Pis). +Pode can run on *nix environments, therefore it only makes sense for there to be Docker images for you to use! The images use PowerShell v7.1.4 on either an Ubuntu Bionic image (default), an Alpine image, or an ARM32 image (for Raspberry Pis). * To pull down the latest Pode image you can do: diff --git a/docs/Hosting/Docker.md b/docs/Hosting/Docker.md index 6ec1a3e72..cf02d0b1a 100644 --- a/docs/Hosting/Docker.md +++ b/docs/Hosting/Docker.md @@ -2,7 +2,7 @@ Pode has a Docker image that you can use to host your server, for instructions on pulling these images you can [look here](../../Installation). -The images use PowerShell v7.1.3 on either an Ubuntu Bionic (default), Alpine, or ARM32 image. +The images use PowerShell v7.1.4 on either an Ubuntu Bionic (default), Alpine, or ARM32 image. ## Images @@ -11,7 +11,7 @@ The images use PowerShell v7.1.3 on either an Ubuntu Bionic (default), Alpine, o ### Default -The default Pode image is an Ubuntu Bionic image with PowerShell v7.1.3 and Pode installed. An example of using this image in your Dockerfile could be as follows: +The default Pode image is an Ubuntu Bionic image with PowerShell v7.1.4 and Pode installed. An example of using this image in your Dockerfile could be as follows: ```dockerfile # pull down the pode image diff --git a/docs/Tutorials/Middleware/Types/CSRF.md b/docs/Tutorials/Middleware/Types/CSRF.md index e3322a06b..8783ffb0f 100644 --- a/docs/Tutorials/Middleware/Types/CSRF.md +++ b/docs/Tutorials/Middleware/Types/CSRF.md @@ -21,7 +21,7 @@ The secret used to generate a token is, by default, stored using sessions (so yo The below code will setup default CSRF middleware, which will store the random secret using sessions (so session middleware is required), and will ignore the default HTTP methods of GET, HEAD, OPTIONS, TRACE: ```powershell -Enable-PodeSessionMiddleware -Secret 'toss-a-coin' +Enable-PodeSessionMiddleware -Duration 120 Enable-PodeCsrfMiddleware ``` @@ -55,7 +55,7 @@ To generate the token, you could use the following example: ```powershell Start-PodeServer { - Enable-PodeSessionMiddleware -Secret 'vegeta' + Enable-PodeSessionMiddleware -Duration 120 Enable-PodeCsrfMiddleware Add-PodeRoute -Method Get -Path '/' -ScriptBlock { @@ -77,7 +77,7 @@ Start-PodeServer { Set-PodeViewEngine -Type Pode # setup session and csrf middleware - Enable-PodeSessionMiddleware -Secret 'vegeta' + Enable-PodeSessionMiddleware -Duration 120 Enable-PodeCsrfMiddleware # this route will work, as GET methods are ignored by CSRF by default @@ -94,7 +94,7 @@ Start-PodeServer { } ``` -*index.pode* +*views/index.pode* ```html diff --git a/docs/Tutorials/Middleware/Types/Sessions.md b/docs/Tutorials/Middleware/Types/Sessions.md index 12dc8f4d3..19669e5db 100644 --- a/docs/Tutorials/Middleware/Types/Sessions.md +++ b/docs/Tutorials/Middleware/Types/Sessions.md @@ -101,6 +101,7 @@ An example of using sessions in a Route to increment a views counter could be do ```powershell Start-PodeServer { + Add-PodeEndpoint -Address localhost -Port 8080 -Protocol Http Enable-PodeSessionMiddleware -Duration 120 Add-PodeRoute -Method Get -Path '/' -ScriptBlock { diff --git a/docs/Tutorials/Routes/Examples/LoginPage.md b/docs/Tutorials/Routes/Examples/LoginPage.md index f18165db8..fc0a7725d 100644 --- a/docs/Tutorials/Routes/Examples/LoginPage.md +++ b/docs/Tutorials/Routes/Examples/LoginPage.md @@ -1,6 +1,6 @@ # Creating a Login Page -This is an example of having a website with a login and home page - with a logout button. The pages will all be done using `.pode` files, and authentication will be done using [Form authentication](../../../Authentication/Methods/Form) with [Sessions]((../../../Middleware/Types/Sessions)). +This is an example of having a website with a login and home page - with a logout button. The pages will all be done using `.pode` files, and authentication will be done using [Form authentication](../../../Authentication/Methods/Form) with [Sessions](../../../Middleware/Types/Sessions). !!! info The full example can be seen on GitHub in [`examples/web-auth-form.ps1`](https://github.com/Badgerati/Pode/blob/develop/examples/web-auth-form.ps1). diff --git a/docs/release-notes.md b/docs/release-notes.md index 1cd95302d..83edbdef7 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,5 +1,20 @@ # Release Notes +## v2.4.2 + +```plain +### Bugs +* #810: Fixes a Local/UTC datetime issue on Cookies, expiring sessions early +* #811: Fixes the HTTPS parameter set on `Start-PodeStaticServer` +* #814: Fixes a route ordering issue on Swagger pages + +### Documentation +* #816: Fixes a typo on LoginPage (thanks @phatmandrake!) + +### Packaging +* #818: Bumps PowerShell to v7.1.4 in Docker images +``` + ## v2.4.1 ```plain diff --git a/packers/docker/arm32/Dockerfile b/packers/docker/arm32/Dockerfile index 384abdec5..f301d654e 100644 --- a/packers/docker/arm32/Dockerfile +++ b/packers/docker/arm32/Dockerfile @@ -1,6 +1,6 @@ FROM arm32v7/ubuntu:bionic -ENV PS_VERSION=7.1.3 +ENV PS_VERSION=7.1.4 ENV PS_PACKAGE=powershell-${PS_VERSION}-linux-arm32.tar.gz ENV PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE} diff --git a/src/Private/OpenApi.ps1 b/src/Private/OpenApi.ps1 index 303c6c0cc..50120a472 100644 --- a/src/Private/OpenApi.ps1 +++ b/src/Private/OpenApi.ps1 @@ -281,11 +281,11 @@ function Get-PodeOpenApiDefinitionInternal } # paths - $def['paths'] = @{} + $def['paths'] = [ordered]@{} $filter = "^$($RouteFilter)" foreach ($method in $PodeContext.Server.Routes.Keys) { - foreach ($path in $PodeContext.Server.Routes[$method].Keys) { + foreach ($path in ($PodeContext.Server.Routes[$method].Keys | Sort-Object)) { # does it match the route? if ($path -inotmatch $filter) { continue diff --git a/src/Private/Sessions.ps1 b/src/Private/Sessions.ps1 index cadb7a21d..be5fd833f 100644 --- a/src/Private/Sessions.ps1 +++ b/src/Private/Sessions.ps1 @@ -111,7 +111,11 @@ function Get-PodeSession # get details from cookie $name = $cookie.Name $value = $cookie.Value + $timestamp = $cookie.TimeStamp + if ($null -ne $timestamp) { + $timestamp = $timestamp.ToUniversalTime() + } } # generate the session data @@ -200,6 +204,9 @@ function Get-PodeSessionExpiry $expiry = [DateTime]::UtcNow if (!([bool]$Session.Properties.Extend)) { $expiry = $Session.Properties.TimeStamp + if ($null -ne $expiry) { + $expiry = $expiry.ToUniversalTime() + } } $expiry = $expiry.AddSeconds($Session.Properties.Duration) diff --git a/src/Public/Core.ps1 b/src/Public/Core.ps1 index a364d9fe7..91ef47e82 100644 --- a/src/Public/Core.ps1 +++ b/src/Public/Core.ps1 @@ -264,7 +264,7 @@ The IP/Hostname of the endpoint. The Port number of the endpoint. .PARAMETER Https -Start the server using HTTPS. +Start the server using HTTPS, if no certificate details are supplied a self-signed certificate will be generated. .PARAMETER Certificate The path to a certificate that can be use to enable HTTPS. @@ -319,23 +319,22 @@ function Start-PodeStaticServer [int] $Port = 0, - [Parameter(ParameterSetName='Https')] + [Parameter()] [switch] $Https, - [Parameter(ParameterSetName='Https')] + [Parameter()] [string] $Certificate = $null, - [Parameter(ParameterSetName='Https')] + [Parameter()] [string] $CertificatePassword = $null, - [Parameter(ParameterSetName='CertFile')] + [Parameter()] [string] $CertificateKey = $null, - [Parameter(ParameterSetName='Https')] [Parameter()] [X509Certificate] $X509Certificate = $null, @@ -358,11 +357,14 @@ function Start-PodeStaticServer Start-PodeServer -RootPath $RootPath -Threads $Threads -Browse:$Browse -ScriptBlock { # add either an http or https endpoint if ($Https) { - if ($null -eq $X509Certificate) { + if ($null -ne $X509Certificate) { + Add-PodeEndpoint -Address $Address -Port $Port -Protocol Https -X509Certificate $X509Certificate + } + elseif (![string]::IsNullOrWhiteSpace($Certificate)) { Add-PodeEndpoint -Address $Address -Port $Port -Protocol Https -Certificate $Certificate -CertificatePassword $CertificatePassword -CertificateKey $CertificateKey } else { - Add-PodeEndpoint -Address $Address -Port $Port -Protocol Https -X509Certificate $X509Certificate + Add-PodeEndpoint -Address $Address -Port $Port -Protocol Https -SelfSigned } } else {