{"id":1174,"date":"2011-06-24T12:46:22","date_gmt":"2011-06-24T04:46:22","guid":{"rendered":"http:\/\/www.se.cuhk.edu.hk\/~hmleung\/wordpress\/?p=1174"},"modified":"2011-06-24T14:22:00","modified_gmt":"2011-06-24T06:22:00","slug":"apache-nis-accounts-authentication","status":"publish","type":"post","link":"https:\/\/www1.se.cuhk.edu.hk\/~hmleung\/wordpress\/?p=1174","title":{"rendered":"Apache NIS accounts authentication"},"content":{"rendered":"<p>In the past , I use mod_auth_sys as a compiled in modules in apache1.3.28 under Sun Solaris platform for authentication on NIS user acounts on confidential webpages . As for apache2.2.19 under CentOS (well, most of our Sun workstations are retiring) ,  I use <a href=\"http:\/\/code.google.com\/p\/mod-auth-external\/downloads\/detail?name=mod_authnz_external-3.2.5.tar.gz\">mod_authnz_external_3.2.5<\/a> and <a href=\"http:\/\/code.google.com\/p\/mod-auth-external\/downloads\/detail?name=mod_authz_unixgroup-1.0.2.tar.gz&#038;can=2&#038;q=\">mod_authz_unixgroup_1.0.2<\/a> for this purpose.<\/p>\n<p>Module mod_authnz_external allows apache to use external application (pwauth here) for user authentication  while mod_authz_unixgroup  allow apache to use unix group instead of individual username as access control in .htaccess. <\/p>\n<p>Compile and install them as loadable modules into apache server (In my case, the apache server is manually installed to \/export\/web\/apache ) :<\/p>\n<blockquote>\n<p><font size=-2><br \/>\n% cd {source dir}\/mod_authnz_external-3.2.5<br \/>\n% \/export\/web\/apache\/bin\/apxs -c mod_authnz_external.c<br \/>\n% \/export\/web\/apache\/bin\/apxs -i -a mod_authnz_external.la<br \/>\n% cd {source dir}\/mod_authz_unixgroup-1.0.2<br \/>\n% \/export\/web\/apache\/bin\/apxs -c mod_authz_unixgroup.c<br \/>\n% \/export\/web\/apache\/bin\/apxs -i -a mod_authz_unixgroup.la<br \/>\n<\/font><\/p>\n<\/blockquote>\n<p>Ensure loadable module authz_user_module is also loaded , here is my list of loadable modules related to authentication :<\/p>\n<blockquote>\n<p><font size=-2><br \/>\nLoadModule auth_basic_module modules\/mod_auth_basic.so<br \/>\nLoadModule auth_digest_module modules\/mod_auth_digest.so<br \/>\nLoadModule authz_host_module modules\/mod_authz_host.so<br \/>\nLoadModule authz_user_module modules\/mod_authz_user.so<br \/>\nLoadModule authz_unixgroup_module modules\/mod_authz_unixgroup.so<br \/>\nLoadModule authnz_external_module modules\/mod_authnz_external.so<br \/>\n<\/font><\/p>\n<\/blockquote>\n<p>I use <a href=\"http:\/\/code.google.com\/p\/pwauth\/\">pwauth-2.3.9<\/a> , as mentioned in README of mod_authnz_external source directory, as external application for authenting our NIS users .  <\/p>\n<p>Now check the uid for user who run the apache (uid is 1230 for webuser here ), as pwauth should only be allowed to run by webuser . In {source dir}\/pwauth-2.3.9\/config.h,  uncomment the line for PAM , and then  comment  the definition for &#8220;SHADOW_SUN&#8221; and &#8220;MIN_UNIX_UID&#8221; :<\/p>\n<blockquote>\n<p><font size=-2><br \/>\n\/* #define SHADOW_SUN           \/* Linux, Solaris, IRIX *\/<br \/>\n#define PAM                     \/* Linux PAM or OpenPAM *\/<br \/>\n\/*#define MIN_UNIX_UID 500      \/**\/<br \/>\n#define SERVER_UIDS 1230             \/* user webuser uid :1230 *\/<br \/>\n<\/font><\/p>\n<\/blockquote>\n<p>Update the {source dir}\/pwauth-2.3.9\/Makefile : <\/p>\n<blockquote>\n<p><font size=-2><br \/>\n#LIB= -lcrypt<br \/>\n# For PAM on Redhat Linux<br \/>\nLIB=-lpam -ldl<br \/>\n<\/font><\/p>\n<\/blockquote>\n<p>After finish the make for pwauth , I copy it to \/usr\/local\/bin. According to the readme for pwauth  , you need to setuid as root for it as it need to read shadow passwd file in centos, however, in my case , I only need it to authenticate our NIS user only and I do not need it to authenticate the local users  . So I do not setuid it to root . However,  if you need it to authenticate local users as well , you must do the setuid . <\/p>\n<p>Create a file \/etc\/pam.d\/pwauth as follow :<\/p>\n<blockquote>\n<p><font size=-2><br \/>\nauth       include      system-auth<br \/>\naccount    include      system-auth<br \/>\n<\/font><\/p>\n<\/blockquote>\n<p>Now back to configuration of httpd.conf , I want to ensure only NIS users of unix group &#8220;techstf&#8221; &#8220;infogrp&#8221; are allowed into the webpage http:\/\/www.mysite.com:1080\/local\/  : <\/p>\n<blockquote>\n<p><font size=-2><\/p>\n<p>NameVirtualHost *:1080<br \/>\n< VirtualHost *:1080><br \/>\n&#8230;&#8230;.<br \/>\nAddExternalAuth pwauth \/usr\/local\/bin\/pwauth<br \/>\nSetExternalAuthMethod pwauth pipe<br \/>\n&#8230;.<br \/>\nAlias \/local\/ &#8220;\/export\/web\/apache\/htdocs\/&#8221;<br \/>\n< Location \/local\/><br \/>\n    AuthType Basic<br \/>\n    AuthName &#8220;Restricted&#8221;<br \/>\n    AuthBasicProvider external<br \/>\n    AuthExternal pwauth<br \/>\n    require group techstf infogrp<br \/>\n< \/Location><\/p>\n<\/blockquote>\n<p><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the past , I use mod_auth_sys as a compiled in modules in apache1.3.28 under Sun Solaris platform for authentication on NIS user acounts on confidential webpages . As for apache2.2.19 under CentOS (well,&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-1174","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/www1.se.cuhk.edu.hk\/~hmleung\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1174","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www1.se.cuhk.edu.hk\/~hmleung\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www1.se.cuhk.edu.hk\/~hmleung\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www1.se.cuhk.edu.hk\/~hmleung\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www1.se.cuhk.edu.hk\/~hmleung\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1174"}],"version-history":[{"count":0,"href":"https:\/\/www1.se.cuhk.edu.hk\/~hmleung\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1174\/revisions"}],"wp:attachment":[{"href":"https:\/\/www1.se.cuhk.edu.hk\/~hmleung\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www1.se.cuhk.edu.hk\/~hmleung\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www1.se.cuhk.edu.hk\/~hmleung\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}