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

2.0: Changes to Authentication functions, and how to use Auth on Routes #575

Closed
Badgerati opened this issue May 26, 2020 · 0 comments · Fixed by #587
Closed

2.0: Changes to Authentication functions, and how to use Auth on Routes #575

Badgerati opened this issue May 26, 2020 · 0 comments · Fixed by #587
Assignees
Milestone

Comments

@Badgerati
Copy link
Owner

This will deal with a number of changes to the authentication functions, and how authentication is used/referenced on routes. A number of parameters will also be moved around.

The Get-PodeAuthMiddleware function will ultimately be removed, but there will be something like Add-PodeAuthMiddleware for setting up global authentication on multiple route paths.

With the removal of Get-PodeAuthMiddleware it also makes wiring up multiple Auths to one route not possible. While adding multiple Get-PodeAuthMiddleware technically wouldn't work, one idea I'm considering is creating a new Merge-PodeAuth -Name -Auths[] <-All> <-One>. This will return a "merged" auth type usable on Routes, and you can either have All auths needed to pass, or just One to pass.

Another change is that New-PodeAuthType will be renamed to New-PodeAuthScheme (and its -Scheme parameter will be renamed to -Type)

Routes

Middleware

Currently when using Authentication in Routes, you need to use the Get-PodeAuthMiddleware function. This to be honest is a little clunky, and it would be nice to just say "please use this Auth on this Route".

So for this change, there'll be a new -Authentication (or just -Auth) parameter which accepts the name of the Auth:

New-PodeAuthScheme -Basic | Add-PodeAuth -Name 'Login' #etc

Add-PodeRoute -Method Get -Path '/path' -Authentication Login -ScriptBlock {}

This will automatically wire-up the authentication middleware - which will run prior to other Route middleware.

Log in/out

The next change on Routes is to remove the -AutoLogin and -Logout switches from Get-PodeAuthMiddleware and move them onto Add-PodeRoute. These will work along side the -Auth parameter, to auto-login requests, or logout.

Flash

And the final change is to remove the -EnableFlash from Get-PodeAuthMiddleware, and move onto Add-PodeRoute.

Auth

Sessions

The first change is to remove the -Sessionless switch from Get-PodeAuthMiddleware, and move it onto Add-PodeAuth - it makes more sense here anyway, as you'll either was an Auth to be generically sessionable/sessionless.

Success/Failure

The next change is to remove the -FailureUrl, -FailureMessage and -SuccessUrl parameters from Get-PodeAuthMiddleware, and move them onto Add-PodeAuth.

Global

After the above, the only thing to do is remove the Get-PodeAuthMiddleware function. This then makes setting up global auth middleware impossible, so a new Add-PodeAuthMiddleware should be created to wire-up an authentication as global middleware for multiple routes/paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant