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

Two Factor authentication #1297

Open
LLIT opened this issue May 15, 2024 · 0 comments
Open

Two Factor authentication #1297

LLIT opened this issue May 15, 2024 · 0 comments

Comments

@LLIT
Copy link

LLIT commented May 15, 2024

What to do?

I m working on adding 2FA to my pode site, but I am getting gray hairs....
The PowerShell part is up and running, I can generate and validate the keys.

But what to do in Pode.

User1 has 2FA enabled.
Use2 has not.

Example 1

Step 1:
Validate user/pass (easy with New-PodeAuthScheme -Form{...})

Step 2:
if
2FA is enabled (another form with pin and hidden username )
else
Skip this step, but how?

Example 2

$custom_scheme | Add-PodeAuth -Name 'Login' -ScriptBlock {
    param($username, $password, $pin)
}

Create 2 login forms
Hide Pin with value ""

Example 3

The one I am hoping for

Add-PodeRoute -Method Post -Path '/login' -ScriptBlock {
    if (!(Test-PodeAuth -Name TwoFALogin) {
        if (Test-PodeAuth -Name Login) {
            if ($User.TwoFA) {
                Write-PodeViewResponse -Path 'auth-login2fa'
            }
            else {
                "Set-PodeAuth -Name TwoFALogin" - The one i cant find :-)
            }
        }
        else {
            Write-PodeViewResponse -Path 'auth-login2fa'
        }
    else {
        "Set-PodeAuth -Name TwoFALogin" - The one i cant find :-)
    }
} 
Add-PodeRoute -Method Post -Path '/OtherPAge' -Authentication TwoFALogin -ScriptBlock {
    Do Stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant