| Author |
Share Topic Topic Search Topic Options
|
smi-mark
DevForce MVP
Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
|
Post Options
Quote Reply
Topic: AllowAnonymousLogIn Posted: 27-Jan-2011 at 6:39am |
|
Glad to hear that works for you!
|
 |
gregweb
DevForce MVP
Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
|
Post Options
Quote Reply
Posted: 26-Jan-2011 at 4:19pm |
Well, here is what I came up with that works so far. Basically, I allow anon access, and then check the entity type as follows:
public class QueryInterceptor : EntityServerQueryInterceptor { protected override bool AuthorizeQuery() { if (this.Principal.Identity.IsAuthenticated) { return true; } else { if (this.Query.ElementType == typeof(menuentity)) { return true; } } return false; } }
|
 |
smi-mark
DevForce MVP
Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
|
Post Options
Quote Reply
Posted: 26-Jan-2011 at 2:24pm |
|
There are a few approaches you could do.
On your custom User class you could have an IsGuest property, or something similar. When the app starts up, you could log in with null credentials, or some other way of letting the LoginManager know it's a guest user. Then in your query interceptors, you could only allow/deny requests based on the property.
There is a chapter in the manual that explains it a bit better. http://www.ideablade.com/CommonProductDocs/DevForce2010DevelopersGuide/DevForce2010DevelopersGuide.pdf Page 307-308
|
 |
gregweb
DevForce MVP
Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
|
Post Options
Quote Reply
Posted: 26-Jan-2011 at 2:20pm |
Hmmm, interesting idea. I hadn't thought of that.
Do you mean create a user say "DefaultUser" and then programatically log the user on when the app first starts up?
By the way, it's good to see another DevForce here in Dallas!
Greg
|
 |
smi-mark
DevForce MVP
Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
|
Post Options
Quote Reply
Posted: 26-Jan-2011 at 2:04pm |
|
Greg, why not do something like this, setup a guest user, and then use query interceptors to only allow access to certain entities for that user.
|
 |
gregweb
DevForce MVP
Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
|
Post Options
Quote Reply
Posted: 26-Jan-2011 at 10:06am |
OK, thanks very much.
Greg
|
 |
kimj
IdeaBlade
Joined: 09-May-2007
Posts: 1391
|
Post Options
Quote Reply
Posted: 26-Jan-2011 at 9:17am |
Generally only one IEntityLoginManager is supported within an application, which means that the same authentication is used everywhere, for all EntityManagers.
If using your own IEntityLoginManager you can control what it accepts as credentials - so you can write it to accept no credentials (or guest credentials) and then also real credentials. You can also add Authorization attributes and other authorization checks on server side code to ensure that only the correct type of users perform certain actions.
There's also the CompositionContext, which does allow you to have multiple IEntityLoginManager instances, with metadata or filters determining which instance should be used for a given context. The CompositionContext is an argument to the EntityManager, so different EMs can have their own context. There's a writeup in the DevForce Resource Center at http://drc.ideablade.com/xwiki/bin/view/Documentation/AdvPersist_CompositionContext which has a better explanation. (This page will likely move within the next few days, but a search of the DRC for "CompositionContext" should find it.)
|
 |
gregweb
DevForce MVP
Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
|
Post Options
Quote Reply
Posted: 24-Jan-2011 at 6:46pm |
Hi Kim,
The metadata IS accessed through Dev-Force. So I need to be able to access data while the user is a "guest" before he logs in. But I don't want all data to be exposed to guests, only some of it.
I have two different Entity Managers, one for the metadata entities, and another for everything else. If there was a way to require authentication on one, but not for the other MetaDataEntityManager, that would be ideal.
Greg
|
 |
kimj
IdeaBlade
Joined: 09-May-2007
Posts: 1391
|
Post Options
Quote Reply
Posted: 24-Jan-2011 at 12:26pm |
|
The AllowAnonymousLogin determines whether "guest" users can login to your application to use DevForce services such as query and save. It doesn't actually have anything to do with the "Anonymous Authentication" setting within IIS. So, if your metadata download is not performed by DevForce proper, then you should be able to do this if your IIS authorization/authentication settings allow it.
|
 |
gregweb
DevForce MVP
Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
|
Post Options
Quote Reply
Posted: 22-Jan-2011 at 7:39pm |
In my config file, I have these settings. This works fine. However, I have a need to have both allowAnonymousLogin to be both true and false. In other words, I have metadata that I would like to download when the site is first accessed, before the user logs in. The once logged in, other data is gotten. Is there a way to do both?
Thanks,
Greg
<objectServer> <serverSettings useAspNetSecurityServices=" true" loginManagerRequired=" true" allowAnonymousLogin=" false" /> </objectServer>
|
 |