Enable-PodeSessionMiddleware
SYNOPSIS
Enables Middleware for creating, retrieving and using Sessions within Pode.
SYNTAX
Cookies (Default)
Enable-PodeSessionMiddleware [-Secret <String>] [-Name <String>] [-Duration <Int32>] [-Generator <ScriptBlock>]
[-Storage <PSObject>] [-Extend] [-HttpOnly] [-Secure] [-Strict] [<CommonParameters>]
Headers
Enable-PodeSessionMiddleware [-Secret <String>] [-Name <String>] [-Duration <Int32>] [-Generator <ScriptBlock>]
[-Storage <PSObject>] [-Extend] [-Strict] [-UseHeaders] [<CommonParameters>]
DESCRIPTION
Enables Middleware for creating, retrieving and using Sessions within Pode; with support for defining Session duration, and custom Storage. If you're storing sessions outside of Pode, you must supply a Secret value so sessions aren't corrupted.
EXAMPLES
EXAMPLE 1
Enable-PodeSessionMiddleware -Duration 120
EXAMPLE 2
Enable-PodeSessionMiddleware -Duration 120 -Extend -Generator { return [System.IO.Path]::GetRandomFileName() }
EXAMPLE 3
Enable-PodeSessionMiddleware -Secret 'schwifty' -Duration 120 -UseHeaders -Strict
PARAMETERS
-Duration
The duration a Session should last for, before being expired.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-Extend
If supplied, the Sessions will have their durations extended on each successful Request.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Generator
A custom ScriptBlock to generate a random unique SessionId. The value returned must be a String.
Type: ScriptBlock
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-HttpOnly
If supplied, the Session cookie will only be accessible to browsers.
Type: SwitchParameter
Parameter Sets: Cookies
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Name
The name of the cookie/header used for the Session.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Pode.sid
Accept pipeline input: False
Accept wildcard characters: False
-Secret
An optional Secret to use when signing Sessions (Default: random GUID).
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Secure
If supplied, the Session cookie will only be accessible over HTTPS Requests.
Type: SwitchParameter
Parameter Sets: Cookies
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Storage
A custom PSObject that defines methods for Delete, Get, and Set. This allow you to store Sessions in custom Storage such as Redis. A Secret is required.
Type: PSObject
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Strict
If supplied, the Secret will be extended using the client request's UserAgent and RemoteIPAddress.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-UseHeaders
If supplied, Sessions will be sent back in a header on the Response with the Name supplied.
Type: SwitchParameter
Parameter Sets: Headers
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.