< Back

Get-PodeAuthMiddleware

Sat Jan 18, 2020 7:15 pm

NAME Get-PodeAuthMiddleware



SYNOPSIS

Returns Authentication Middleware that can be used globally, or an Routes.





SYNTAX

Get-PodeAuthMiddleware [-Name] <String> [[-FailureUrl] <String>] [[-FailureMessage] <String>] [[-SuccessUrl]

<String>] [-EnableFlash] [-Sessionless] [-AutoLogin] [-Logout] [<CommonParameters>]





DESCRIPTION

Returns Authentication Middleware that can be used globally, or an Routes.





PARAMETERS

-Name <String>

The Name of the Authentication method.



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-FailureUrl <String>

The URL to redirect to when authentication fails.



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-FailureMessage <String>

An override Message to throw when authentication fails.



Required? false

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-SuccessUrl <String>

The URL to redirect to when authentication succeeds.



Required? false

Position? 4

Default value

Accept pipeline input? false

Accept wildcard characters? false



-EnableFlash [<SwitchParameter>]

If supplied, error messages will be added as Flash messages.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Sessionless [<SwitchParameter>]

If supplied, authenticated users will not be stored in sessions, and sessions will not be used.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-AutoLogin [<SwitchParameter>]

If supplied, navigating to a login page with a valid session will redirect to the SuccessUrl. Otherwise the

login page will be displayed.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Logout [<SwitchParameter>]

If supplied, the current session will be purged, and the user will be redirected to the FailureUrl.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

System.Collections.Hashtable





-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Add-PodeRoute -Method Get -Path '/' -Middleware (Get-PodeAuthMiddleware -Name 'Main') -ScriptBlock { /*

logic */ }













-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-PodeAuthMiddleware -Name 'BasicAuth' -Sessionless | Add-PodeMiddeware -Name 'GlobalAuth'













-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Add-PodeRoute -Method Get -Path '/login' -Middleware (Get-PodeAuthMiddleware -Name 'Main' -SuccessUrl '/'

-AutoLogin) -ScriptBlock { /* logic */ }















RELATED LINKS