Hi there all!
I have as you found the potential in coyahoga, however I today use Active Directory as my main catalogue for user administration purposes.
So I am know wondering if I should start looking in to developing such a module or modification of coyahoga.
What I would like to know before I futher investigate in this is if you (Martin), on the top of your head can forsee some complications with managing users through Active Directory in coyahoga?
And if there perhaps allready is someone out there working on such a module/ modification?
It would be great to have AD/LDAP for user authentication. The thing that needs to be done is to abstract out the current authentication and user/groups management and make it pluggable.
Added to the list for 1.1.
Hi again..
I have very slowly started to look in on howto implement AD Authentication in cuyahoga.
And the first thing I have noticed is that to make Authentication as a whole pluggeble, is that the object User in 'Cuyahoga.Core.Domain' should be extracted to an interface and any other object wich references it insteed refrences the extracted interface (ex IUser). In this case anyone who thinks they can implement a better way of authentication only need to implement the interface and the automaticly still can use all other parts of the framework (offcourse changes to web.config, a construction of a separate HttpAuthentication module and possible additions to the database might be needed).
Any comment on this possible design thought would be most appriciated.. :)
And again thanks for a great framework.(h5)
//smithimage
I think, it's not the User class that should have an interface. It already has no notion of persistence whatsoever.
To make authentication and user management pluggable, we need some IUserService interface that has everything related to login, and user- and role management. The related logic that is currently in the CoreRepository should be transfered to the Database implementation of IUserService, DBUserService.
Makes sense?
Thinking about it: I don't think it's entirely possible to store everything in AD. Modules need some user stuff (for example, to show the author of an article). It think it might be crazy to query AD for those things.
martijnbThinking about it: I don't think it's entirely possible to store everything in AD. Modules need some user stuff (for example, to show the author of an article). It think it might be crazy to query AD for those things.
Martin,
Hi, I just downloaded Cuyahoga Thanks! It looks like a solid base so far.
You may very well have already thought of this but:
In my past life, I mean job, I did a lot of LDAP & Active Directory integrations with a variety of Business Intelligence products.
All of those products had information that was specific for a role to some resource in them. IMHO - the trick is to allow some type of translation between what LDAP or AD thinks is a user and a role and what your product does.
So you would have some predefined roles for portal management and such and in a config file or DB you would have a 1-1 or 1 to many relationship between your role and the roles or groups defined in LDAP-AD
I hope that makes sense & thanks again,
Bill
Hi again..
To comment on what wcpeabody said:
So you would have some predefined roles for portal management and such and in a config file or DB you would have a 1-1 or 1 to many
relationship between your role and the roles or groups defined in LDAP-AD
Thats the kind of solution I was thinking about, eg adding a separate table in the databse (ex ad_user) which has a many-to-many relation
to cm_roles (through a relation table ex ad_userrole) this only to create the needed connection with object such as sections etc.
A question that revealed itself to me yesterday was:
In the Cuyahoga.Web.HttpModules.AuthenticationModule one hooks up to the "AuthenticateRequest" event. And in this eventhandler checks
whether there is an IPricipal connected to the context and if this principal is Authenticated. If this is true the method retrives the
IPrincipal and with the help of the Name property retrives a User from the database. Then turns this User into a CuyahogaPrincipal add
changes the current IPrincipal in the context to the CuyahogaPrincipal.
My question/s is, is this needed?
(the comment from the source)
// There is a logged-in user with a standard Forms Identity. Replace it with
// the cached Cuyahoga identity (the User class implements IIdentity).
Can it happen that there is a (standard) IPrincipal connected to the context that isn´t a CuyahogaPricipal?
smithimageMy question/s is, is this needed?
(the comment from the source)// There is a logged-in user with a standard Forms Identity. Replace it with
// the cached Cuyahoga identity (the User class implements IIdentity).
Can it happen that there is a (standard) IPrincipal connected to the context that isn´t a CuyahogaPricipal?
Yes, it is needed because probably every security check in the system is based on a Cuyahoga User (that implements IIdentity).
But that shouldn't be a very big problem. For AD authentication, only the concrete authentication part has to swapped (via a plugin structure). As long as the authentication engine (wheter it be with Cuyahoga's own tables, AD, or the ASP.NET membership tables) comes up with a proper Cuyahoga User object, everything should work fine.
Hi..
I should perhaps clearify my earlier question.
I have understood that all security checks are done against the Cuyahoga.User class, however when a user logs on to the framework this is done with the help of the AuthenticateUser method in the Cuyahoga.Core.HttpModules.Authenticationmodule.
In this method after a succesfull authentication we add a CuyahogaPrincipal to the context.
From AuthenticateUser method
..
....
// Save login date and IP
cr.UpdateObject(user);
// Create the authentication ticket
HttpContext.Current.User = new CuyahogaPrincipal(user);
FormsAuthentication.SetAuthCookie(user.Name, persistLogin);
return true;
From the AuthenticateRequest method
..
...
if (app.Context.User != null && app.Context.User.Identity.IsAuthenticated)
{
CoreRepository cr = (CoreRepository)HttpContext.Current.Items["CoreRepository"];
// There is a logged-in user with a standard Forms Identity. Replace it with
// the cached Cuyahoga identity (the User class implements IIdentity).
int userId = Int32.Parse(app.Context.User.Identity.Name);
User cuyahogaUser = (User)cr.GetObjectById(typeof(ADUser), userId);
cuyahogaUser.IsAuthenticated = true;
app.Context.User = new CuyahogaPrincipal(cuyahogaUser);
}
My question therfore is, shouldnt a authenticated user allready be in the context as a CuyahogaPrincipal?
(see the bold marked lines)
Hope I dont make a complete ass of myself asking this question.. :$
By the way.. Kudos to you Martijn for answering so fast in all forum topics.. this is really helpfull
smithimageMy question therfore is, shouldnt a authenticated user allready be in the context as a CuyahogaPrincipal?
(see the bold marked lines)
I think this is not the case. Cuyahoga uses the normal ASP.NET forms authentication. It automatically reads the authentication cookie and always creates a GenericPrincipal that has a FormsIdentity. If we want to have the CuyahogaPrincipal in the context automatically we have to write the cookie handling stuff ourselves.
Hope I dont make a complete ass of myself asking this question.. :$
Definately not ;).
Juval Lowy did a great Interfaced based unified security model using web services. That really wasn't the interesting part. The way that he wired it together was the interesting part.
http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=-1&tabid=19&download=100
He uses the .NET 2.0 Role provider API. We could create a 1.1 version of this that would allow us to easily move forward, while still leveraging and being compatible with 2.0