Hallo,
Voor een door mij ontwikkelde WCF service probeer ik een beveiliging in te stellen.
De web.config is als volgt opgebouwd:
Service
Binding
Behavior
De validator is als volgt opgebouwd:
Met behulp van .NET WebServiceStudio roep ik de service aan (over SSL).
Hierna krijg ik mijn functies terug (de WSDL is dus gewoon op te vragen).
Als ik nu echter een InVoke doe op een functie dan krijg ik een 401 Unauthorized.
Wat heb ik tot nu toe gedaan?
- Programming WCF Services van O'reilly
- Google
- Microsoft
- Microsoft
- Nog meer microsoft
- Wrox Professional WCF Programming (Hoofdstuk 10, Security)
- Microsoft.Press.Inside.Windows.Communication.Foundation.May.2007 (HelpFile)
Ik hoop dat jullie me een zet in de goede richting kunnen geven want ik kom er niet meer uit...
BVD
Voor een door mij ontwikkelde WCF service probeer ik een beveiliging in te stellen.
De web.config is als volgt opgebouwd:
Service
XML: web.config
11
12
13
14
15
16
17
18
19
20
21
| <services> <service name="[NameSpace].Service" behaviorConfiguration="bedrijfBehavior"> <host> <baseAddresses> <add baseAddress="[BasePath naar de serviceroot]"/> </baseAddresses> </host> <endpoint binding="basicHttpBinding" bindingConfiguration="bedrijfBindingConfiguration" contract="[NameSpace].IService"> </endpoint> </service> </services> |
Binding
XML: web.config
22
23
24
25
26
27
28
29
30
| <bindings> <basicHttpBinding> <binding name="bedrijfBindingConfiguration"> <security mode="Transport"> <transport clientCredentialType="Basic" /> </security> </binding> </basicHttpBinding> </bindings> |
Behavior
XML: web.config
31
32
33
34
35
36
37
38
39
40
41
42
43
44
| <behaviors> <serviceBehaviors> <behavior name="bedrijfBehavior"> <serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="[NameSpace].CValidate, [NameSpace]"/> </serviceCredentials> <serviceMetadata httpsGetEnabled="true" /> <dataContractSerializer maxItemsInObjectGraph="5000000"/> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> </behaviors> |
De validator is als volgt opgebouwd:
C#: CustomValidator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| namespace [NameSpace] { public class CValidate : UserNamePasswordValidator { public override void Validate(string userName, string password) { if (null == userName || null == password) { throw new ArgumentNullException(); } if (!((userName == "test1") && (password == "test2"))) { throw new SecurityTokenException("Unknown Username or Incorrect Password"); } } } } |
Met behulp van .NET WebServiceStudio roep ik de service aan (over SSL).
Hierna krijg ik mijn functies terug (de WSDL is dus gewoon op te vragen).
Als ik nu echter een InVoke doe op een functie dan krijg ik een 401 Unauthorized.
Wat heb ik tot nu toe gedaan?
- Programming WCF Services van O'reilly
- Microsoft
- Microsoft
- Nog meer microsoft
- Wrox Professional WCF Programming (Hoofdstuk 10, Security)
- Microsoft.Press.Inside.Windows.Communication.Foundation.May.2007 (HelpFile)
Ik hoop dat jullie me een zet in de goede richting kunnen geven want ik kom er niet meer uit...
BVD