-
Notifications
You must be signed in to change notification settings - Fork 991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the REMOTE_USER (for example mod_auth_kerb) support #967
Conversation
[test] |
Rebased on develop, including Marek H.'s tests: 34defdc55765700eff0723e5852c2bc5ac1d2774. |
Thanks [test] |
Oh this is great, would it work with mod_auth_openid? https://github.com/bmuller/mod_auth_openid |
I did not verify it specifically with mod_auth_openid but the plan is to support anything that populates REMOTE_USER which mod_auth_openid does. |
@@ -0,0 +1,4 @@ | |||
[Dolphin] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, could you please remove .directory files? I accidentaly added them to my commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Wed, Oct 23, 2013 at 11:05:57PM -0700, Marek Hulán wrote:
@@ -0,0 +1,4 @@
+[Dolphin]oops, could you please remove .directory files? I accidentaly added them to my commit
Done, and rebased on latest develop: 1ecfb77.
Jan Pazdziora
Principal Software Engineer, Identity Management Engineering, Red Hat
On Wed, Oct 23, 2013 at 11:05:57PM -0700, Marek Hulán wrote:
Done, and rebased on latest develop: 1ecfb77. |
I went through this once again and when adelton/pull/3 gets in, you have my 👍 The only unresolved comment from #958 is about authorize_login_delegation_auth_source_user_autocreate type - @domcleal? |
[test] |
What is preventing this pull request from being merged / rebased on develop? |
if auth_source.nil? | ||
auth_source = AuthSourceExternal.new(:name => auth_source_name) | ||
auth_source.save! | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be simplified:
options = { :name => auth_source_name }
auth_source = AuthSourceExternal.where(options).first || AuthSourceExternal.create!(options)
User.create!(:login => login, :auth_source => auth_source)
this first ensures we are always talking about External Authsources vs any authsource.
secondly, I'm wondering what happens if AutoSource is created, but user does not, I did not try, but we could try using the build method instead and save them in one go... maybe something like
options = { :name => auth_source_name }
auth_source = AuthSourceExternal.where(options).first || AuthSourceExternal.build(options)
User.create!(:login => login, :auth_source => auth_source)
AFAIK (require a bit testing) would create both user and auth source in the same transaction. (would nice to see a test like that).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal is to be able to name any auth_source, not necessarily the external one.
If the build approach works, by all means go for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attempt to use the build
approach leads to
x undefined method `build' for #<Class:0x000000070bcb90>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right.. i guess it should be auth_source.build(:type =>
'AuthSourceExternal'...)
but that would also need to include Foreman::STI to the AuthSource class
for it to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, no idea what Foreman::STI is and how to include it in this patch. I'll go with the
options = { :name => auth_source_name }
auth_source = AuthSourceExternal.where(options).first || AuthSourceExternal.create!(options)
User.create!(:login => login, :auth_source => auth_source)
approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, but as you said, you might need to use AuthSource.where (vs.
AuthSourceExternal.where)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Pushed out as 12d820e. Thanks.
… on REMOTE_USER.
Rebased on latest develop and added commit 8a1f17c9fa03d51f9a28fd94362a37d372975f4a to give the new user the Anonymous role upon login, like form-based logons do. |
…ser_autocreate is set, creates the unknown authenticated user.
…ogin so that it can be used for external logins as well.
New rebase to address Ohad's comments: 59f9484. |
I'm having problems testing this after seeing up Foreman as per the wiki page. My browser begins looping around the /users/extlogin page with a series of 302 and 401 HTTP responses. http://people.redhat.com/~dcleal/extlogin_redirect.png (browser logs) Any thoughts? |
Production log contains only 302 so 401 is rendered by apache before it gets to foreman? How did you set the |
I hadn't set the logout_url setting, but have now have - it makes no difference:
Yes, I'm only using mod_auth_kerb on /users/extlogin using /etc/httpd/conf.d/auth_kerb.conf: <Location /users/extlogin> AuthType Kerberos AuthName "Kerberos Login" KrbMethodNegotiate On KrbMethodK5Passwd Off KrbAuthRealms IPA.FM.EXAMPLE.NET Krb5KeyTab /etc/http.keytab KrbLocalUserMapping On require valid-user ErrorDocument 401 'Kerberos authentication did not pass.' ErrorDocument 500 'Kerberos authentication did not pass.' </Location> |
My output after successful Kergeros login is
Since I don't see that |
I assume the culprit could be in
-- if you have But I have no idea how that |
Did you have chance to test this? If the endless loop comes from this code, we might want to not do the |
PEBKAC, sorry for the noise. I'd done a nightly install and attempted to apply the patch on top, but somehow it hadn't fully applied. An RPM build of the branch worked much better. |
Awesome work! I'm very excited about this merge, thanks @adelton! |
Thanks for the merge. I'll now rebase #986 and work on it. |
This series of patches addresses http://projects.theforeman.org/issues/3312, making it possible to set up a protected "logon" location in Apache via
and configure mod_auth_* authentication modules for that location. It was tested with mod_auth_kerb.
The possibilities and issues with the existing REMOTE_USER support are listed at http://projects.theforeman.org/projects/foreman/wiki/Foreman_and_mod_auth_kerb, together with explanations introduced by this pull request.
This is a refactoring of #958, addressing all comments in that pull request.