| Author |
Share Topic Topic Search Topic Options
|
antalakas
Newbie
Joined: 25-Jun-2007
Location: Greece
Posts: 28
|
Post Options
Quote Reply
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
|
 |
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
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.
|
 |
Chrizy
Newbie
Joined: 10-Jan-2012
Posts: 10
|
Post Options
Quote Reply
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
|
 |
Thomas
Newbie
Joined: 21-Feb-2012
Posts: 23
|
Post Options
Quote Reply
Posted: 21-Feb-2012 at 11:57pm |
|
I would be also interested in such an example using ODATA.
|
 |
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
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.
|
 |
Chrizy
Newbie
Joined: 10-Jan-2012
Posts: 10
|
Post Options
Quote Reply
Posted: 28-Feb-2012 at 2:06am |
uploads/1374/DebugLog.zip
Debug file attached.
Thanks Chris
|
 |
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
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.
|
 |
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
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.
|
 |
Chrizy
Newbie
Joined: 10-Jan-2012
Posts: 10
|
Post Options
Quote Reply
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
|
 |
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
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.
|
 |
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
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"); } }
|
|
 |
Chrizy
Newbie
Joined: 10-Jan-2012
Posts: 10
|
Post Options
Quote Reply
Posted: 12-Mar-2012 at 3:17pm |
Hi, That worked, thanks for the quick response.
Chris
|
 |