New Posts New Posts RSS Feed: ODATA and LoginManager
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

ODATA and LoginManager

 Post Reply Post Reply
Author
antalakas View Drop Down
Newbie
Newbie
Avatar

Joined: 25-Jun-2007
Location: Greece
Posts: 28
Post Options Post Options   Quote antalakas Quote  Post ReplyReply Direct Link To This Post Topic: ODATA and LoginManager
    Posted: 07-Nov-2011 at 2:01pm
Hello,

I am building an application that implements IEntityLoginManager to provide custom User/Role management.
I need to add an ODATA service. When i try to get an entity with my odata client, i get an IdeaBlade.EntityModel.LoginException, with message : No credentials supplied.

I agree that this is true. How can i add credentials using ODATA?

Andreas
Andreas Ntalakas
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 08-Nov-2011 at 10:29am
Hi Andreas

In general, to secure OData service we can use Forms Authentication (http://msdn.microsoft.com/en-us/data/gg192996) or Basic Authentication (http://msdn.microsoft.com/en-us/data/gg192997) where the credentials are passed in the Authorization header of a client request. The credentials in turn will be passed to the IEntityLoginManager.

Hope this helps.
Back to Top
Chrizy View Drop Down
Newbie
Newbie
Avatar

Joined: 10-Jan-2012
Posts: 10
Post Options Post Options   Quote Chrizy Quote  Post ReplyReply Direct Link To This Post Posted: 21-Feb-2012 at 4:53am
Hi,
Do you have any code examples showing ODATA being used with a custom Login Manager and Basic Authentication?

I'm not currently even getting the No credentials error when viewing via the browser.
getting "The server encountered an error processing the request. See server logs for more details." and cant see any error logged.

Thanks
Chris
Back to Top
Thomas View Drop Down
Newbie
Newbie
Avatar

Joined: 21-Feb-2012
Posts: 23
Post Options Post Options   Quote Thomas Quote  Post ReplyReply Direct Link To This Post Posted: 21-Feb-2012 at 11:57pm
I would be also interested in such an example using ODATA.
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 22-Feb-2012 at 12:27pm
Hi Chrizy and Thomas,

We currently don't have such samples but I've submitted a feature request to provide it in the future.

Chrizy, if you can provide me with your DebugLog.xml that DevForce generates, I can try and help you with the server error.
Back to Top
Chrizy View Drop Down
Newbie
Newbie
Avatar

Joined: 10-Jan-2012
Posts: 10
Post Options Post Options   Quote Chrizy Quote  Post ReplyReply Direct Link To This Post Posted: 28-Feb-2012 at 2:06am
uploads/1374/DebugLog.zip

Debug file attached.

Thanks
Chris
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 28-Feb-2012 at 6:20pm
The DebugLog doesn't record anything of significance either. Would you mind zipping up your project, upload it somewhere and let me know where to get it? You can PM me if you prefer. Thanks.
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 29-Feb-2012 at 8:21pm
Hi Chris,

Thanks for the project. Here's what's happening.

You've added some custom properties on the Group and PropertyToSaleOrLet entities that are non-serializable types. You have to add them to the IgnorePropertiesAttribute like below.

  [IgnoreProperties(@"EntityAspect", @"TypeID")]
  public partial class Group : IbEm.Entity {..........}

  [IgnoreProperties(@"EntityAspect", @"PriceQualifierIDenum")]
  public partial class PropertyToSaleOrLet : IbEm.Entity {......}

For the time being, you can hook into the code generation for IgnorePropertiesAttribute by overriding the default T4 template. A feature request has been submitted for this to be supported without messing with the code generation.

Back to Top
Chrizy View Drop Down
Newbie
Newbie
Avatar

Joined: 10-Jan-2012
Posts: 10
Post Options Post Options   Quote Chrizy Quote  Post ReplyReply Direct Link To This Post Posted: 07-Mar-2012 at 1:44am

Thanks that fixed the error, I have set up a test client to the pass basic authentication header, but when my custom login manager gets called the credentials are null. I've tried creating a BasicAuthenticationModule which creates an instance of the EnityManager and calls the Login method, and also putting the service in a separate folder and setting IIS to use Basic Authentication. In my test environment I'm not using https could this be the problem?

Thanks
Chris

Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 07-Mar-2012 at 5:08pm
Hi Chris,

Could you zip up and send me your sample project again so I can take a look? Again, you can use PM if you prefer. Thanks.
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 08-Mar-2012 at 5:18pm
Hi Chris,

Thanks for the sample.

In your custom LoginManager, you have to get the Authorization header, decode the credential and create your own LoginCredential.

public IPrincipal Login(ILoginCredential credential, EntityManager entityManager) {
      
      string authHeader = HttpContext.Current.Request.Headers["Authorization"];
      var creds = ParseAuthHeader(authHeader);
      credential = new LoginCredential(creds[0], creds[1], "");
      if (credential == null) {
         throw new LoginException(LoginExceptionType.NoCredentials, "No credentials supplied");
      }
      
}
Back to Top
Chrizy View Drop Down
Newbie
Newbie
Avatar

Joined: 10-Jan-2012
Posts: 10
Post Options Post Options   Quote Chrizy Quote  Post ReplyReply Direct Link To This Post Posted: 12-Mar-2012 at 3:17pm
Hi,
That worked, thanks for the quick response.

Chris
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down