Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6330423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:52:03+00:00 2026-05-24T17:52:03+00:00

Can anyone point me to a suitable WCF Extension Point for hooking into the

  • 0

Can anyone point me to a suitable WCF Extension Point for hooking into the WCF Pipeline to extract credentials for UserNamePasswordValidator from the headers of an incoming HTTP REST Request?

Yes I know about all the funky stunts with Http Handlers etc. you can pull to somehow get Basic/Digest Auth working but since the client I’m working on will be strictly Javascript based I’ve opted for a simple model where the credentials are passed using two custom headers over an SSL pipe.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:52:04+00:00Added an answer on May 24, 2026 at 5:52 pm

    Update: I’ve managed to improve on this by using the approach described here. While this does not solves the problem described in my question, it gets rid of having to authenticate in a authorization policy since authentication is now handled by a custom AuthenticationManager, bypassing the UsernamePasswordValidator alltogether.

    For the time being I’ve solved the problem by combining Authentication and Authorization in a custom Authorization Policy. I’d still rather find a way to hook into the normal UserNamePasswordValidator authentication scheme because an Authorization Policy is supposed to to Authorization not Authentication.

    internal class RESTAuthorizationPolicy : IAuthorizationPolicy
    {
      public RESTAuthorizationPolicy()
      {
        Id = Guid.NewGuid().ToString();
        Issuer = ClaimSet.System;
      }
    
      public bool Evaluate(EvaluationContext evaluationContext, ref object state)
      {
        const String HttpRequestKey = "httpRequest";
        const String UsernameHeaderKey = "x-ms-credentials-username";
        const String PasswordHeaderKey = "x-ms-credentials-password";
        const String IdentitiesKey = "Identities";
        const String PrincipalKey = "Principal";
    
        // Check if the properties of the context has the identities list 
        if (evaluationContext.Properties.Count > 0 ||
          evaluationContext.Properties.ContainsKey(IdentitiesKey) ||
          !OperationContext.Current.IncomingMessageProperties.ContainsKey(HttpRequestKey))
          return false;
    
        // get http request
        var httpRequest = (HttpRequestMessageProperty)OperationContext.Current.IncomingMessageProperties[HttpRequestKey];
    
        // extract credentials
        var username = httpRequest.Headers[UsernameHeaderKey];
        var password = httpRequest.Headers[PasswordHeaderKey];
    
        // verify credentials complete
        if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
          return false;
    
        // Get or create the identities list 
        if (!evaluationContext.Properties.ContainsKey(IdentitiesKey))
          evaluationContext.Properties[IdentitiesKey] = new List<IIdentity>();
        var identities = (List<IIdentity>) evaluationContext.Properties[IdentitiesKey];
    
        // lookup user
        using (var con = ServiceLocator.Current.GetInstance<IDbConnection>())
        {
          using (var userDao = ServiceLocator.Current.GetDao<IUserDao>(con))
          {
            var user = userDao.GetUserByUsernamePassword(username, password);
    
            ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone point me in the right direction on this. From reading the FAQs
Can anyone point to libraries that can be used for Printing from Compact .Net
Can anyone point to some good articles on WCF Service Throttling settings to improve
Can anyone point out an extension where we can add articles in another language,
Can anyone point me to a good resource (or throw me a clue) to
Can anyone point me to a good introduction to coding against the paypal API?
Can anyone point me to a tutorial on the best way to open a
Can anyone point me to a library for 2D game physics, etc for programming
Can anyone point me to a good, simple, example of a Google API (AJAX
Can anyone point to some code that deals with the security of files access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.