Pode.Web icon indicating copy to clipboard operation
Pode.Web copied to clipboard

AccessUsers und AccessGroups

Open eugen257 opened this issue 2 years ago • 2 comments

Hi, it's not clear how to use Add-PodeWebPage with -AccessUsers and -AccessGroups. If I enter a user or group, then this page disappears altogether. Can someone shed some light on how this works.

The question is how to hide some pages for some and show for others.

Thanks

eugen257 avatar Sep 27 '22 16:09 eugen257

Hi @eugen257,

The two work if authentication/login is enabled. -AccessUsers is an array of usernames that can access the page, and -AccessGroups is an array of groups for users that can access the page. If a user's username, or a user's group isn't in either, the page is hidden.

If you've got WindowsAD auth enabled say, and a user with username joe.bloggs logged in, if this username is in -AccessUsers for some page then that page will show. But if a jane.doe logged in and their username wasn't in that list, the page would be hidden.

-AccessUsers checks the $WebEvent.Auth.User.Username property, and -AccessGroups checks the $WebEvent.Auth.User.Groups property.

I've noticed these are missing from the docs; so I'll label this as documentation to get it added.

Badgerati avatar Oct 04 '22 22:10 Badgerati

Hi @Badgerati,

what's wrong? no user can see this page example:

    #Login
    Enable-PodeSessionMiddleware -Secret 'stringisadatatype' -Duration 600 -Extend
    New-PodeAuthScheme -Form | Add-PodeAuthWindowsAd -Name 'Login' -Users @('testuser1','testuser2') -SuccessUseOrigin
    Set-PodeWebLoginPage -Authentication Login -PassThru  |
        Register-PodeWebPageEvent -Type Load -NoAuthentication -ScriptBlock {
            Show-PodeWebToast -Message "Willkommen auf unserer internen Webseite!" -Duration 10000 -Title "TestSeite"
        }
    #Page
    Add-PodeWebPage -Name Test -Title "Test" -AccessUsers @('testuser1') -ScriptBlock {
            New-PodeWebBadge -Colour Blue -Id test -Value test
    }

eugen257 avatar Oct 11 '22 12:10 eugen257