Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Define a binding in the web.config like :</p> <pre><code>&lt;basicHttpBinding&gt; &lt;binding name="BasicAuthBinding"&gt; &lt;security mode="Message"&gt; &lt;message clientCredentialType="UserName"/&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/basicHttpBinding&gt; </code></pre> <p>Then define a service behaviour like :</p> <pre><code>&lt;behavior name="Namespace.TestBehaviour"&gt; &lt;serviceCredentials&gt; &lt;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Namespace.ServiceSecurity.UserAuthenticator, Namespace" /&gt; &lt;/serviceCredentials&gt; &lt;serviceAuthorization&gt; &lt;authorizationPolicies&gt; &lt;add policyType="Namespace.ServiceSecurity.MyAuthorizationPolicy, Namespace" /&gt; &lt;/authorizationPolicies&gt; &lt;/serviceAuthorization&gt; &lt;/behavior&gt; </code></pre> <p>Then provide the custom authentication and authorization classes as follows :</p> <pre><code>public class MyAuthorizationPolicy: IAuthorizationPolicy { public bool Evaluate(EvaluationContext evaluationContext, ref object state) { IList&lt;IIdentity&gt; identities = (IList&lt;IIdentity&gt;) evaluationContext.Properties["Identities"]; foreach (IIdentity identity in identities) { if (identity.IsAuthenticated &amp;&amp; identity.AuthenticationType == "UserAuthenticator") { evaluationContext.Properties["Principal"] = identity.Name; return true; } } if (!evaluationContext.Properties.ContainsKey("Principal")) { evaluationContext.Properties["Principal"] = ""; } return false; } public ClaimSet Issuer { get { throw new NotImplementedException(); } } } </code></pre> <p>authentication as follows :</p> <pre><code>public class UserAuthenticator : UserNamePasswordValidator { public override void Validate(string userName, string password) { //authenticate me however you want //then set whatever you want } } </code></pre> <p>If you need further security, change basicHttpBinding to a wsHttpBinding and use a certificate </p> <p>EDIT : Almost forgot, use the defined service behaviour and binding in your service interface definition in web.config.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload