Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

UserNamePasswordValidator and custom authentication

 
 
Thread Tools Display Modes
Old 09-27-2006   #1 (permalink)
Vadym Stetsyak
Guest


 

UserNamePasswordValidator and custom authentication

Hello, All!

I have a service that is based on BasicHttpBinding. It also exposes metadata,
so others can see its WSDL.

Now I want to apply custom authentication that will be based on
HTTP basic athentication.

The problem is that my custom validator is not being called, to perform
validation ( authentication ), and client gets 403 error.

So, I setup my BasicHttpBinding, like so

httpBinding.Security.Transport.ClientCredentialType
= HttpClientCredentialType.Basic;

httpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;

Then, I've setup ServiceHost to perform authentication. The code is:

//setting the credentials behavior
ServiceCredentials sc = new ServiceCredentials();
Validator validator = new Validator();

sc.UserNameAuthentication.UserNamePasswordValidationMode
= System.ServiceModel.Security.UserNamePasswordValidationMode.Custom;

sc.UserNameAuthentication.CustomUserNamePasswordValidator = validator;
serviceHost.Description.Behaviors.Remove<ServiceCredentials>();
serviceHost.Description.Behaviors.Add(sc);

Validator code is pretty simple
class Validator : System.IdentityModel.Selectors.UserNamePasswordValidator
{
public override void Validate(string username, string password)
{
//perform validation here
}
}

I suspect that smth is wrong here, but there is no documentation out there that
can assist my problem.

--
With best regards, Vadym Stetsyak.
www: http://vadmyst.blogspot.com
Old 09-28-2006   #2 (permalink)
Arkady Frenkel
Guest


 

Re: UserNamePasswordValidator and custom authentication

Hi,Vadim!
Did you tried HttpClientCredentialType.Windows instead of
HttpClientCredentialType.Basic ?
OTOH try BasicHttpSecurityMode.Message and not TransportCredentialOnly

Arkady

"Vadym Stetsyak" <vadym_s@ukr.net> wrote in message
news:up$2sck4GHA.4832@TK2MSFTNGP06.phx.gbl...
> Hello, All!
>
> I have a service that is based on BasicHttpBinding. It also exposes
> metadata,
> so others can see its WSDL.
>
> Now I want to apply custom authentication that will be based on
> HTTP basic athentication.
>
> The problem is that my custom validator is not being called, to perform
> validation ( authentication ), and client gets 403 error.
>
> So, I setup my BasicHttpBinding, like so
>
> httpBinding.Security.Transport.ClientCredentialType
> = HttpClientCredentialType.Basic;
>
> httpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
>
> Then, I've setup ServiceHost to perform authentication. The code is:
>
> //setting the credentials behavior
> ServiceCredentials sc = new ServiceCredentials();
> Validator validator = new Validator();
>
> sc.UserNameAuthentication.UserNamePasswordValidationMode
> = System.ServiceModel.Security.UserNamePasswordValidationMode.Custom;
>
> sc.UserNameAuthentication.CustomUserNamePasswordValidator = validator;
> serviceHost.Description.Behaviors.Remove<ServiceCredentials>();
> serviceHost.Description.Behaviors.Add(sc);
>
> Validator code is pretty simple
> class Validator : System.IdentityModel.Selectors.UserNamePasswordValidator
> {
> public override void Validate(string username, string password)
> {
> //perform validation here
> }
> }
>
> I suspect that smth is wrong here, but there is no documentation out there
> that
> can assist my problem.
>
> --
> With best regards, Vadym Stetsyak.
> www: http://vadmyst.blogspot.com



Old 09-28-2006   #3 (permalink)
Vadym Stetsyak
Guest


 

Re: UserNamePasswordValidator and custom authentication

Hello, Arkady!

AF> Did you tried HttpClientCredentialType.Windows instead of
AF> HttpClientCredentialType.Basic ?
AF> OTOH try BasicHttpSecurityMode.Message and not
AF> TransportCredentialOnly

The problem is that I have to support Basic authentication.
AFAIK Basic authentication requires TransportCredentialOnly

What I've found with Reflector is that Basic authentication is not supported.

BasicHttpBinding creates HttpChannelListener class, which represents channel
(IChannelListener).

And HttpChannelListener uses WindowsUserNameSecurityTokenAuthenticator
to process authentication. This authenticator internally uses LogonUser(...).

As a workaround I one can provide custom IChannelListener class, but this seems to be
an overkill.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Old 09-29-2006   #4 (permalink)
Guest


 

Re: UserNamePasswordValidator and custom authentication

this works for me :

HTH
-----------------
server config :

<service name="MyService.ClassServiceSSL" behaviorConfiguration ="ssl">
<endpoint contract="MyService.IMyServiceSSL"
binding="wsHttpBinding" address ="/paperino/"
bindingConfiguration ="ssl"/>
<host>
<baseAddresses>
<add baseAddress ="https://localhost:8082"/>
</baseAddresses>
</host>
</service>

.....

<behaviors>
<serviceBehaviors>
<behavior name="ssl">
<serviceDebug includeExceptionDetailInFaults ="true"/>
<serviceMetadata httpsGetEnabled ="true"/>
<serviceCredentials>
<serviceCertificate storeName ="My" storeLocation="LocalMachine"
findValue ="CN=localhost" x509FindType ="FindBySubjectDistinguishedName"/>
<userNameAuthentication
userNamePasswordValidationMode="Custom"/>
</serviceCredentials>
</behavior>

....

<bindings>
<wsHttpBinding>
<binding name ="mymessage">
<security mode ="None">
</security >
</binding>
<binding name ="ssl">
<security mode ="TransportWithMessageCredential">
<message clientCredentialType ="UserName"/>
</security >
</binding>


<behavior name="ssl">
<serviceDebug includeExceptionDetailInFaults ="true"/>
<serviceMetadata httpsGetEnabled ="true"/>
<serviceCredentials>
<serviceCertificate storeName ="My" storeLocation="LocalMachine"
findValue ="CN=localhost" x509FindType ="FindBySubjectDistinguishedName"/>
<userNameAuthentication
userNamePasswordValidationMode="Custom"/>
</serviceCredentials>
</behavior>

--------
server code


using (ServiceHost hostssl = new
ServiceHost(typeof(MyService.ClassServiceSSL))) {
ServiceCredentials l_ServiceCredentials = hostssl.Credentials;
l_ServiceCredentials.UserNameAuthentication.CustomUserNamePasswordValidator
= new MyService.MyValidator();
hostssl.Open();



"Vadym Stetsyak" <vadym_s@ukr.net> wrote in message
news:up$2sck4GHA.4832@TK2MSFTNGP06.phx.gbl...
> Hello, All!
>
> I have a service that is based on BasicHttpBinding. It also exposes
> metadata,
> so others can see its WSDL.
>
> Now I want to apply custom authentication that will be based on
> HTTP basic athentication.
>
> The problem is that my custom validator is not being called, to perform
> validation ( authentication ), and client gets 403 error.
>
> So, I setup my BasicHttpBinding, like so
>
> httpBinding.Security.Transport.ClientCredentialType
> = HttpClientCredentialType.Basic;
>
> httpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
>
> Then, I've setup ServiceHost to perform authentication. The code is:
>
> //setting the credentials behavior
> ServiceCredentials sc = new ServiceCredentials();
> Validator validator = new Validator();
>
> sc.UserNameAuthentication.UserNamePasswordValidationMode
> = System.ServiceModel.Security.UserNamePasswordValidationMode.Custom;
>
> sc.UserNameAuthentication.CustomUserNamePasswordValidator = validator;
> serviceHost.Description.Behaviors.Remove<ServiceCredentials>();
> serviceHost.Description.Behaviors.Add(sc);
>
> Validator code is pretty simple
> class Validator : System.IdentityModel.Selectors.UserNamePasswordValidator
> {
> public override void Validate(string username, string password)
> {
> //perform validation here
> }
> }
>
> I suspect that smth is wrong here, but there is no documentation out there
> that
> can assist my problem.
>
> --
> With best regards, Vadym Stetsyak.
> www: http://vadmyst.blogspot.com


Old 09-29-2006   #5 (permalink)
Vadym Stetsyak
Guest


 

Re: UserNamePasswordValidator and custom authentication

Hello, x!

Thans for the example, I saw it in the WCF technical samples.

But it doesn't suit me, since it uses WsHttpBinding and SSL.
I have to support legacy clients that uses common HTTP Basic
authentication.

What in WCF terms will mean BasicHttpBinding, winth Basic authentication mode set.

x> this works for me :

x> HTH
x> -----------------
x> server config :

x> <service name="MyService.ClassServiceSSL" behaviorConfiguration
x> ="ssl">
x> <endpoint contract="MyService.IMyServiceSSL"
x> binding="wsHttpBinding" address ="/paperino/"
x> bindingConfiguration ="ssl"/>
x> <host>
x> <baseAddresses>
x> <add baseAddress ="https://localhost:8082"/>
x> </baseAddresses>
x> </host>
x> </service>

x> ....

x> <behaviors>
x> <serviceBehaviors>
x> <behavior name="ssl">
x> <serviceDebug includeExceptionDetailInFaults ="true"/>
x> <serviceMetadata httpsGetEnabled ="true"/>
x> <serviceCredentials>
x> <serviceCertificate storeName ="My"
x> storeLocation="LocalMachine"
x> findValue ="CN=localhost" x509FindType
x> ="FindBySubjectDistinguishedName"/>
x> <userNameAuthentication
x> userNamePasswordValidationMode="Custom"/>
x> </serviceCredentials>
x> </behavior>

x> ...

x> <bindings>
x> <wsHttpBinding>
x> <binding name ="mymessage">
x> <security mode ="None">
x> </security >
x> </binding>
x> <binding name ="ssl">
x> <security mode ="TransportWithMessageCredential">
x> <message clientCredentialType ="UserName"/>
x> </security >
x> </binding>


x> <behavior name="ssl">
x> <serviceDebug includeExceptionDetailInFaults ="true"/>
x> <serviceMetadata httpsGetEnabled ="true"/>
x> <serviceCredentials>
x> <serviceCertificate storeName ="My"
x> storeLocation="LocalMachine"
x> findValue ="CN=localhost" x509FindType
x> ="FindBySubjectDistinguishedName"/>
x> <userNameAuthentication
x> userNamePasswordValidationMode="Custom"/>
x> </serviceCredentials>
x> </behavior>

x> --------
x> server code


x> using (ServiceHost hostssl = new
x> ServiceHost(typeof(MyService.ClassServiceSSL))) {
x> ServiceCredentials l_ServiceCredentials = hostssl.Credentials;
x> l_ServiceCredentials.UserNameAuthentication.
x> CustomUserNamePasswordValidator
x> = new MyService.MyValidator();
x> hostssl.Open();



x> "Vadym Stetsyak" <vadym_s@ukr.net> wrote in message
x> news:up$2sck4GHA.4832@TK2MSFTNGP06.phx.gbl...

>> Hello, All!


>> I have a service that is based on BasicHttpBinding. It also exposes
>> metadata,
>> so others can see its WSDL.


>> Now I want to apply custom authentication that will be based on
>> HTTP basic athentication.


>> The problem is that my custom validator is not being called, to
>> perform
>> validation ( authentication ), and client gets 403 error.


>> So, I setup my BasicHttpBinding, like so


>> httpBinding.Security.Transport.ClientCredentialType
>> = HttpClientCredentialType.Basic;


>> httpBinding.Security.Mode =
>> BasicHttpSecurityMode.TransportCredentialOnly;


>> Then, I've setup ServiceHost to perform authentication. The code is:


>> //setting the credentials behavior
>> ServiceCredentials sc = new ServiceCredentials();
>> Validator validator = new Validator();


>> sc.UserNameAuthentication.UserNamePasswordValidationMode
>> =
>> System.ServiceModel.Security.UserNamePasswordValidationMode.Custom;


>> sc.UserNameAuthentication.CustomUserNamePasswordValidator = validator;
>> serviceHost.Description.Behaviors.Remove<ServiceCredentials>();
>> serviceHost.Description.Behaviors.Add(sc);


>> Validator code is pretty simple
>> class Validator :
>> System.IdentityModel.Selectors.UserNamePasswordValidator
>> {
>> public override void Validate(string username, string password)
>> {
>> //perform validation here
>> }
>> }


>> I suspect that smth is wrong here, but there is no documentation out
>> there
>> that
>> can assist my problem.


>> --
>> With best regards, Vadym Stetsyak.
>> www: http://vadmyst.blogspot.com



--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Old 10-03-2006   #6 (permalink)
Vadym Stetsyak
Guest


 

Re: UserNamePasswordValidator and custom authentication

Hi, All!

It appears that creadentials validation for BasicHttpBinding is done via
Windows account. And there is no way to do it manually.

So, in order to make this type if authentication work
it is necessary to create windows account on the machine where ServiceHost is
operating

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
types.custom.ps1xml for custom members hasten PowerShell 0 02-25-2008 08:30 PM
Asking for authentication Chris Vista mail 0 01-16-2008 04:00 PM
authentication conservativeadvisor Vista mail 2 08-06-2007 06:40 PM
Custom Dependency Property in custom class hierarchy not workingcorrectly?! MueMeister Avalon 0 03-02-2006 06:19 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50