Skip to content

Commit

Permalink
Merge pull request #824 from Badgerati/develop
Browse files Browse the repository at this point in the history
v2.4.2
  • Loading branch information
Badgerati committed Sep 13, 2021
2 parents 0f5a522 + a27a80f commit ea3e397
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 22 deletions.
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion docs/Getting-Started/Installation.md
Expand Up @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions docs/Hosting/Docker.md
Expand Up @@ -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

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions docs/Tutorials/Middleware/Types/CSRF.md
Expand Up @@ -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
```

Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -94,7 +94,7 @@ Start-PodeServer {
}
```

*index.pode*
*views/index.pode*
```html
<html>
<head>
Expand Down
1 change: 1 addition & 0 deletions docs/Tutorials/Middleware/Types/Sessions.md
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion 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).
Expand Down
15 changes: 15 additions & 0 deletions 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
Expand Down
2 changes: 1 addition & 1 deletion 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}

Expand Down
4 changes: 2 additions & 2 deletions src/Private/OpenApi.ps1
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/Private/Sessions.ps1
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 10 additions & 8 deletions src/Public/Core.ps1
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit ea3e397

Please sign in to comment.