Hi Andy,
Do you have any form of protection requirements at the WSE service, in
the form of policy or something? By default, when you install WSE, you get
the ability
to secure messages, however, if you don't specify the request to be signed
or encrypted, or the at the service for all incoming requests to be signed
or encrypted,
then one can easily send simple non-secure ASMX messages. You can see the
WSE Documentation on how to use policy to secure messages.
Also, with regards to the Invoke button. This is a test page that you
see when you browse a .asmx web service through a browser. The invoke button
automatically
shows up only on the local machine. If you try to access this from a remote
machine, you will not get this invoke button (unless you explicitly enable
the HttpPost
protocol in the web.config or machine.config of the server). Also, if you
really wanted to even block this
Invoke button on the test page to even execute your web method, you can do
the following at the start your web method:
if (RequestSoapContext.Current == null)
throw new ApplicationException("Only SOAP requests are allowed");
Let me know if this makes sense.
Thanks,
Sidd [MSFT]
> Hi
>
[quoted text clipped - 24 lines]
> xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
> xmlns:wsa=""http://schemas.xmlsoap.org/ws/2004/03/addressing""
xmlns:wsse=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecur
ity-secext-1.0.xsd""
xmlns:wsu=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
ty-utility-1.0.xsd"">";
> xml += @"<soap:Header>";
> xml +=
@"<wsa:Action>http://www.xxx.co.uk/HwroeServiceInterfaceIntranet/GetPdaDatab
aseVersion</wsa:Action>";
> xml +=
@"<wsa:MessageID>uuid:98d778d5-1970-45fa-a493-2172ef56abe1</wsa:MessageID>";
> xml += @"<wsa:ReplyTo>";
> xml +=
@"<wsa:Address>http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymo
us</wsa:Address>";
> xml += @"</wsa:ReplyTo>";
> xml +=
@"<wsa:To>http://localhost/HwroeServiceInterfaceIntranet/PdaServices.asmx</w
sa:To>";
> xml += @"<wsse:Security soap:mustUnderstand=""1"">";
> xml += @"<wsu:Timestamp
[quoted text clipped - 3 lines]
> xml += @"</wsu:Timestamp>";
> xml += @"<wsse:UsernameToken
xmlns:wsu=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
ty-utility-1.0.xsd""
> wsu:Id=""SecurityToken-5998b927-31a7-4778-91ed-4058ae944f1e"">";
> xml += @"<wsse:Username>CL701P</wsse:Username>";
> xml += @"<wsse:Password
Type=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-toke
n-profile-1.0#PasswordDigest"">j8ohdLGEMoaT9ue/LoDxbsPYq6Y=</wsse:Password>"
;
> xml += @"<wsse:Nonce>sfXD8hxSBJWYADDJW5avxw==</wsse:Nonce>";
> xml += @"<wsu:Created>2005-07-05T15:27:11Z</wsu:Created>";
[quoted text clipped - 11 lines]
>
> HttpWebRequest req =
(HttpWebRequest)WebRequest.Create("http://localhost/hwroeserviceinterfaceint
ranet/pdaservices.asmx/GetPdaDatabaseVersion");
> req.Headers.Add("SOAPAction","\"\"");
>
[quoted text clipped - 18 lines]
> "What are you going to do? Set the dogs on me? Or the bees? Or the dogs with
> bees in their mouths and every time they bark they shoot bees?"
Andy Stephens - 07 Jul 2005 09:32 GMT
Hi Sidd, thanks for the reply.
Yes, we are using a policyCache.config file (see below). We have implemented
our own UsernameTokenManager; the overridden AuthenticateToken() method
authenticates the username and password against a database, creates an
IPrincipal and populates it with roles, then assigns this to the token's
Principal. The policy file uses a role-based <Claims> section.
I came across the code snippet to check to reject non-soap requests
yesterday, but it is quite worrying that if a developer forgets to add this,
anyone can call WSE webservices using a HttpWebRequest, and completely bypass
WSE as if it wasn't there at all!
Policy file:
<policyDocument xmlns="http://schemas.microsoft.com/wse/2003/06/Policy">
<mappings xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy">
<defaultEndpoint>
<defaultOperation>
<request policy="#ValidateUsernameToken" />
<response policy="" />
<fault policy="" />
</defaultOperation>
</defaultEndpoint>
</mappings>
<policies
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"
xmlns:wssp="http://schemas.xmlsoap.org/ws/2002/12/secext"
xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing">
<wsp:Policy wsu:Id="ValidateUsernameToken">
<SecurityToken wsp:Usage="wsp:Required"
xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext"
xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" >
<TokenType>
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1
.0#UsernameToken
</TokenType>
<Claims xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy">
<wse:Role value="Admin" />
</Claims>
</SecurityToken>
</wsp:Policy>
</policies>
</policyDocument>
Andrew Stephens
.Net Consultant
"What are you going to do? Set the dogs on me? Or the bees? Or the dogs with
bees in their mouths and every time they bark they shoot bees?"