WebAdministrationDsc icon indicating copy to clipboard operation
WebAdministrationDsc copied to clipboard

Add Support for Editing Anonymous Authentication Credentials

Open PlagueHO opened this issue 8 years ago • 37 comments

This should be available in xWebApplication and xWebSite. It should allow setting the username/password or setting them to blank which forces it to use the Application Pool credentials.

capture

PlagueHO avatar Oct 04 '16 02:10 PlagueHO

+1, this is an issue for us.

TopperKain avatar May 16 '17 21:05 TopperKain

+1

bhmahler avatar Aug 29 '17 14:08 bhmahler

+1

duk3ofed avatar Dec 04 '17 16:12 duk3ofed

+1 I would like to help but I am not sure how this additional options should be provided. Currently all information about authentication are defined as follows

AuthenticationInfo = `
            MSFT_xWebApplicationAuthenticationInformation
            {
                Anonymous = $true
                Basic     = $false
                Digest    = $false
                Windows   = $false
            }

Where can I find definition of MSFT_xWebApplicationAuthenticationInformation? Does it contain other properties which could be used to provide user/password information? Or should I introduce another parameter for this functionality, something like that:

AuthenticationInfo =   MSFT_xWebApplicationAuthenticationInformation
            {
                Anonymous = $true
                Basic     = $false
                Digest    = $false
                Windows   = $false
            };
AnonymousAuthenticationInfo = @{
               User="TestUser";
               Password = "secret"
}

Necessary configuration sections are described here: https://docs.microsoft.com/en-us/iis/configuration/system.webserver/security/authentication/anonymousauthentication

cezarypiatek avatar Jan 10 '18 11:01 cezarypiatek

@cezarypiatek Sorry that nobody answered you for so long. I think you need a new property AnonymousCredential that provides the username and password to use when Anonymous = $true. Also, if that new property AnonymousCredential is not provided, then maybe it can blank out username and password which means Application Pool is used (as per @PlagueHO comment above). Let me know if you want to work on this, then I label this as 'in progress'.

johlju avatar Apr 26 '18 12:04 johlju

I can take it.

cezarypiatek avatar Apr 26 '18 12:04 cezarypiatek

Awesome! I have labeled this as 'In progress'. Thanks!

johlju avatar Apr 26 '18 15:04 johlju

Is this a thing yet ? I really need this feature

maxgqc avatar May 31 '18 15:05 maxgqc

I've started to implement it on my fork https://github.com/cezarypiatek/xWebAdministration but I haven't had time to manage the UT. Btw I think that xWebApplication and xWebSite require refactoring because there is a massive code duplication which make those modules hard to extend.

In the meantime I've found xIISApplicationPoolIdentityType resource which probably is the missing part.

cezarypiatek avatar Jun 04 '18 19:06 cezarypiatek

@cezarypiatek Agree with that those should be refactored to use helper functions, same goes for the *Defaults resource(s) too.

johlju avatar Jun 05 '18 08:06 johlju

I've got stuck with weird error related to CIM objects. The issue is described in related PR https://github.com/PowerShell/xWebAdministration/pull/408

Can somebody help me with that?

cezarypiatek avatar Dec 20 '18 21:12 cezarypiatek

@johlju @kwirkykat could you help me?

cezarypiatek avatar Dec 29 '18 20:12 cezarypiatek

@cezarypiatek Thanks for submitting the PR for this issue. Sorry for the delay. I'll take a look at the error you're running into later tonight and reproduce in my environment.

regedit32 avatar Jan 09 '19 14:01 regedit32

@regedit32 Any progress on the PR yet?

bartjanson avatar Jan 21 '19 15:01 bartjanson

Still waiting for a help, no response from @regedit32 so far.

cezarypiatek avatar Jan 21 '19 15:01 cezarypiatek

@cezarypiatek I see you have some recent commits, are you close to having a working solution?

twerthi avatar Feb 01 '19 19:02 twerthi

@twerthi I'm in the middle of adding tests for this feature in xWebSite module. After that I need to repeat everything forxWebApplication because there is a code duplication between this two modules (or find a way to reuse current solution) I'm probably going to split this into two PR.

cezarypiatek avatar Feb 01 '19 21:02 cezarypiatek

Any progress to report on?

bartjanson avatar Mar 04 '19 16:03 bartjanson

Would be great to have this. Currently using some idempotent powershell to accomplish this.

bradwilliamson avatar Apr 09 '19 13:04 bradwilliamson

Thanks for the reminder. I will try to get back to this on Saturday.

cezarypiatek avatar Apr 09 '19 19:04 cezarypiatek

I think I've finished with UT for xWebsite module. I need to only complete non-development task, such as doc update etc.

cezarypiatek avatar Apr 14 '19 21:04 cezarypiatek

Two things:

  1. I think I've got stuck again with integration tests. Some of them are failing and there is no useful error message. Details in #408. Help needed.

  2. Instead of adding custom CIM type for credentials maybe I should use MSFT_Credential ? What is the proper way of handling passwords in DSC?

cezarypiatek avatar Apr 15 '19 19:04 cezarypiatek

@cezarypiatek I think for item 2 you should have MSFT_Credential for the property Password in MSFT_xWebAnonymousAuthenticationCredentials, otherwise the password will not be encrypted.

Looking at item 1 now.

johlju avatar Apr 16 '19 15:04 johlju

For item 1. Could it be that it does not return the correct object on this line AnonymousCredentials = $anonymousCredentials. That this line is $null but should always be the CIM instance MSFT_xWebAnonymousAuthenticationCredentials. For example if the website returns false for this $anonymousAuthentication.enabled then Get-AnonymousCredentials will not return the correct CIM instance.

Could this be the problem?

johlju avatar Apr 16 '19 15:04 johlju

@johlju so CIM fields cannot be null?

cezarypiatek avatar Apr 16 '19 17:04 cezarypiatek

Honestly not sure, but Get-DscConfiguration that is failing in the integration test usually fails if the return value has the wrong type. So I’m guessing it tries to access the object, but there are no objects. If that is the case, maybe you can return a CIM instance but the properties are null.

To test it, I would hard code an object in the code and manually run Get-DscConfiguration to see what the value can and cannot contain. :thinking:

johlju avatar Apr 16 '19 17:04 johlju

thanks, I will try this.

cezarypiatek avatar Apr 16 '19 17:04 cezarypiatek

Ok, I'm trying now to implement it using MSFT_Credential. I model myself on xWebAppPool and application pool credentials. The Get-TargetResource method is returning Credential field with username and password values. Doesn't it violate security? It looks like a way to retrieve credentials from the system.

https://github.com/PowerShell/xWebAdministration/blob/2e1778f42c782e98583368612f692f2af7072b7c/DSCResources/MSFT_xWebAppPool/MSFT_xWebAppPool.psm1#L135

cc: @johlju

cezarypiatek avatar May 11 '19 20:05 cezarypiatek

What I meant it should return an CIM Instance of the instance MSFT_xWebAnonymousAuthenticationCredentials, not MSFT_Credential. The instance of MSFT_xWebAnonymousAuthenticationCredentials that is returned could just contain the user name, and not the password. Or both values in that instance could probably be $null.

We are talking about this line in the schema, right?

https://github.com/PowerShell/xWebAdministration/blob/e665489a92fa64b8e50f31d7f529f39efe504bfd/DSCResources/MSFT_xWebsite/MSFT_xWebsite.schema.mof#L52

johlju avatar May 12 '19 06:05 johlju

I think that introducing MSFT_xWebAnonymousAuthenticationCredentials is a bad idea and I want to implement this feature in the same way as MSFT_xWebAppPool is handling application pool identity credentials (It uses MSFT_Credential) but I'm not sure if that existing implementation of MSFT_xWebAppPool is secure. Please review Get-TargetResource from MSFT_xWebAppPool and tell me if it's secure or not.

cezarypiatek avatar May 12 '19 10:05 cezarypiatek