<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.ext-9.eprints-hosting.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sp</id>
	<title>EPrints Documentation - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.ext-9.eprints-hosting.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sp"/>
	<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/Special:Contributions/Sp"/>
	<updated>2026-05-09T04:32:51Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10553</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10553"/>
		<updated>2012-06-30T15:13:44Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* Prerequisites */ $v++&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files from http://files.eprints.org/738/&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice. (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests, creates new users and sessions, and returns to the originally requested resource. (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the correct, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A consequence of external authentication is that no self-registration of user accounts within EPrints is possible (or necessary, as many would see it) anymore, unless the system providing external authentication itself offers self-registration.&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.10) on a newly installed RHEL6 machine. All paths and file names are hence based on an RPM install on RHEL5/6 and will need to be adapted to your webserver and EPrints installation and configuration.&lt;br /&gt;
&lt;br /&gt;
Download the files from http://files.eprints.org/738/ and unpack them to a directory of choice, e.g.&lt;br /&gt;
 cd /tmp&lt;br /&gt;
 wget http://files.eprints.org/738/1/webserver-auth.tgz&lt;br /&gt;
 tar xvzf webserver-auth.tgz&lt;br /&gt;
 cd webserver-auth&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude a resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should &#039;&#039;not&#039;&#039; present the usual, nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add the login script ===&lt;br /&gt;
There are two example scripts provided in the package:&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-noprovisioning&amp;lt;/tt&amp;gt;, which failes logins for users not found in your EPrints instance and simply redirects them to a page of your choice. Provisioning user accounts needs to happen via some other process (e.g. manually, batch processes, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt;, which automatically creates local EPrints users (of type &amp;quot;user&amp;quot;) after successful external authentication.&lt;br /&gt;
Both variants can be extended according to local needs and capabilities, e.g. if your authentication system does not provide additional profile info (name, email, etc.) you could add a lookup from an LDAP directory or database to the code.&lt;br /&gt;
&lt;br /&gt;
Decide on a variant of the login script. We&#039;ll be assuming &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt; since it&#039;s more practically useful for a new install (which is what we&#039;re describing here). Create a directory in your EPrints directory and copy your choice of login script there, naming it &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;. (Again, non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about the login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified (as far as EPrints is concerned) SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Activate the new authentication method ===&lt;br /&gt;
To finally activate the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
Conversely, to deactivate webserver-based authentication and restore EPrints&#039; default authentication method either remove the file or wrap the whole file&#039;s content in a &amp;lt;tt&amp;gt;while(0){&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;}&amp;lt;/tt&amp;gt; block (Perl&#039;s approximation of a block comment) and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10552</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10552"/>
		<updated>2012-06-30T15:12:09Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* Conceptual overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files from http://files.eprints.org/738/&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice. (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests, creates new users and sessions, and returns to the originally requested resource. (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the correct, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A consequence of external authentication is that no self-registration of user accounts within EPrints is possible (or necessary, as many would see it) anymore, unless the system providing external authentication itself offers self-registration.&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.7) on a newly installed RHEL6 machine. All paths and file names are hence based on an RPM install on RHEL5/6 and will need to be adapted to your webserver and EPrints installation and configuration.&lt;br /&gt;
&lt;br /&gt;
Download the files from http://files.eprints.org/738/ and unpack them to a directory of choice, e.g.&lt;br /&gt;
 cd /tmp&lt;br /&gt;
 wget http://files.eprints.org/738/1/webserver-auth.tgz&lt;br /&gt;
 tar xvzf webserver-auth.tgz&lt;br /&gt;
 cd webserver-auth&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude a resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should &#039;&#039;not&#039;&#039; present the usual, nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add the login script ===&lt;br /&gt;
There are two example scripts provided in the package:&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-noprovisioning&amp;lt;/tt&amp;gt;, which failes logins for users not found in your EPrints instance and simply redirects them to a page of your choice. Provisioning user accounts needs to happen via some other process (e.g. manually, batch processes, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt;, which automatically creates local EPrints users (of type &amp;quot;user&amp;quot;) after successful external authentication.&lt;br /&gt;
Both variants can be extended according to local needs and capabilities, e.g. if your authentication system does not provide additional profile info (name, email, etc.) you could add a lookup from an LDAP directory or database to the code.&lt;br /&gt;
&lt;br /&gt;
Decide on a variant of the login script. We&#039;ll be assuming &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt; since it&#039;s more practically useful for a new install (which is what we&#039;re describing here). Create a directory in your EPrints directory and copy your choice of login script there, naming it &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;. (Again, non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about the login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified (as far as EPrints is concerned) SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Activate the new authentication method ===&lt;br /&gt;
To finally activate the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
Conversely, to deactivate webserver-based authentication and restore EPrints&#039; default authentication method either remove the file or wrap the whole file&#039;s content in a &amp;lt;tt&amp;gt;while(0){&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;}&amp;lt;/tt&amp;gt; block (Perl&#039;s approximation of a block comment) and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10551</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10551"/>
		<updated>2012-06-30T15:10:48Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* Conceptual overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files from http://files.eprints.org/738/&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice. (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests, creates new users and sessions, and returns to the originally requested resource. (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the right, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A consequence of external authentication is that no self-registration of user accounts within EPrints is possible (or necessary, as many would see it) anymore, unless the system providing external authentication itself offers self-registration.&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.7) on a newly installed RHEL6 machine. All paths and file names are hence based on an RPM install on RHEL5/6 and will need to be adapted to your webserver and EPrints installation and configuration.&lt;br /&gt;
&lt;br /&gt;
Download the files from http://files.eprints.org/738/ and unpack them to a directory of choice, e.g.&lt;br /&gt;
 cd /tmp&lt;br /&gt;
 wget http://files.eprints.org/738/1/webserver-auth.tgz&lt;br /&gt;
 tar xvzf webserver-auth.tgz&lt;br /&gt;
 cd webserver-auth&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude a resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should &#039;&#039;not&#039;&#039; present the usual, nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add the login script ===&lt;br /&gt;
There are two example scripts provided in the package:&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-noprovisioning&amp;lt;/tt&amp;gt;, which failes logins for users not found in your EPrints instance and simply redirects them to a page of your choice. Provisioning user accounts needs to happen via some other process (e.g. manually, batch processes, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt;, which automatically creates local EPrints users (of type &amp;quot;user&amp;quot;) after successful external authentication.&lt;br /&gt;
Both variants can be extended according to local needs and capabilities, e.g. if your authentication system does not provide additional profile info (name, email, etc.) you could add a lookup from an LDAP directory or database to the code.&lt;br /&gt;
&lt;br /&gt;
Decide on a variant of the login script. We&#039;ll be assuming &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt; since it&#039;s more practically useful for a new install (which is what we&#039;re describing here). Create a directory in your EPrints directory and copy your choice of login script there, naming it &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;. (Again, non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about the login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified (as far as EPrints is concerned) SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Activate the new authentication method ===&lt;br /&gt;
To finally activate the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
Conversely, to deactivate webserver-based authentication and restore EPrints&#039; default authentication method either remove the file or wrap the whole file&#039;s content in a &amp;lt;tt&amp;gt;while(0){&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;}&amp;lt;/tt&amp;gt; block (Perl&#039;s approximation of a block comment) and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10550</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10550"/>
		<updated>2012-06-30T15:09:53Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* Conceptual overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files from http://files.eprints.org/738/&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice. (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;), creates new users and sessions, and returns to the originally requested resource.&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the right, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A consequence of external authentication is that no self-registration of user accounts within EPrints is possible (or necessary, as many would see it) anymore, unless the system providing external authentication itself offers self-registration.&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.7) on a newly installed RHEL6 machine. All paths and file names are hence based on an RPM install on RHEL5/6 and will need to be adapted to your webserver and EPrints installation and configuration.&lt;br /&gt;
&lt;br /&gt;
Download the files from http://files.eprints.org/738/ and unpack them to a directory of choice, e.g.&lt;br /&gt;
 cd /tmp&lt;br /&gt;
 wget http://files.eprints.org/738/1/webserver-auth.tgz&lt;br /&gt;
 tar xvzf webserver-auth.tgz&lt;br /&gt;
 cd webserver-auth&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude a resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should &#039;&#039;not&#039;&#039; present the usual, nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add the login script ===&lt;br /&gt;
There are two example scripts provided in the package:&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-noprovisioning&amp;lt;/tt&amp;gt;, which failes logins for users not found in your EPrints instance and simply redirects them to a page of your choice. Provisioning user accounts needs to happen via some other process (e.g. manually, batch processes, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt;, which automatically creates local EPrints users (of type &amp;quot;user&amp;quot;) after successful external authentication.&lt;br /&gt;
Both variants can be extended according to local needs and capabilities, e.g. if your authentication system does not provide additional profile info (name, email, etc.) you could add a lookup from an LDAP directory or database to the code.&lt;br /&gt;
&lt;br /&gt;
Decide on a variant of the login script. We&#039;ll be assuming &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt; since it&#039;s more practically useful for a new install (which is what we&#039;re describing here). Create a directory in your EPrints directory and copy your choice of login script there, naming it &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;. (Again, non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about the login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified (as far as EPrints is concerned) SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Activate the new authentication method ===&lt;br /&gt;
To finally activate the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
Conversely, to deactivate webserver-based authentication and restore EPrints&#039; default authentication method either remove the file or wrap the whole file&#039;s content in a &amp;lt;tt&amp;gt;while(0){&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;}&amp;lt;/tt&amp;gt; block (Perl&#039;s approximation of a block comment) and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10526</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10526"/>
		<updated>2012-06-06T16:53:57Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* Exclude a resource from EPrints proper */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files from http://files.eprints.org/738/&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice and is &#039;&#039;not&#039;&#039; visible to people logging in! (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;), creates new users and sessions, and returns to the originally requested resource.&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the right, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A consequence of external authentication is that no self-registration of user accounts within EPrints is possible (or necessary, as many would see it) anymore, unless the system providing external authentication itself offers self-registration.&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.7) on a newly installed RHEL6 machine. All paths and file names are hence based on an RPM install on RHEL5/6 and will need to be adapted to your webserver and EPrints installation and configuration.&lt;br /&gt;
&lt;br /&gt;
Download the files from http://files.eprints.org/738/ and unpack them to a directory of choice, e.g.&lt;br /&gt;
 cd /tmp&lt;br /&gt;
 wget http://files.eprints.org/738/1/webserver-auth.tgz&lt;br /&gt;
 tar xvzf webserver-auth.tgz&lt;br /&gt;
 cd webserver-auth&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude a resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should &#039;&#039;not&#039;&#039; present the usual, nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add the login script ===&lt;br /&gt;
There are two example scripts provided in the package:&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-noprovisioning&amp;lt;/tt&amp;gt;, which failes logins for users not found in your EPrints instance and simply redirects them to a page of your choice. Provisioning user accounts needs to happen via some other process (e.g. manually, batch processes, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt;, which automatically creates local EPrints users (of type &amp;quot;user&amp;quot;) after successful external authentication.&lt;br /&gt;
Both variants can be extended according to local needs and capabilities, e.g. if your authentication system does not provide additional profile info (name, email, etc.) you could add a lookup from an LDAP directory or database to the code.&lt;br /&gt;
&lt;br /&gt;
Decide on a variant of the login script. We&#039;ll be assuming &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt; since it&#039;s more practically useful for a new install (which is what we&#039;re describing here). Create a directory in your EPrints directory and copy your choice of login script there, naming it &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;. (Again, non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about the login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified (as far as EPrints is concerned) SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Activate the new authentication method ===&lt;br /&gt;
To finally activate the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
Conversely, to deactivate webserver-based authentication and restore EPrints&#039; default authentication method either remove the file or wrap the whole file&#039;s content in a &amp;lt;tt&amp;gt;while(0){&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;}&amp;lt;/tt&amp;gt; block (Perl&#039;s approximation of a block comment) and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10525</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10525"/>
		<updated>2012-06-06T16:29:42Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* TLS/SSL */ formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files from http://files.eprints.org/738/&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice and is &#039;&#039;not&#039;&#039; visible to people logging in! (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;), creates new users and sessions, and returns to the originally requested resource.&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the right, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A consequence of external authentication is that no self-registration of user accounts within EPrints is possible (or necessary, as many would see it) anymore, unless the system providing external authentication itself offers self-registration.&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.7) on a newly installed RHEL6 machine. All paths and file names are hence based on an RPM install on RHEL5/6 and will need to be adapted to your webserver and EPrints installation and configuration.&lt;br /&gt;
&lt;br /&gt;
Download the files from http://files.eprints.org/738/ and unpack them to a directory of choice, e.g.&lt;br /&gt;
 cd /tmp&lt;br /&gt;
 wget http://files.eprints.org/738/1/webserver-auth.tgz&lt;br /&gt;
 tar xvzf webserver-auth.tgz&lt;br /&gt;
 cd webserver-auth&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude a resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should not present a nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add the login script ===&lt;br /&gt;
There are two example scripts provided in the package:&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-noprovisioning&amp;lt;/tt&amp;gt;, which failes logins for users not found in your EPrints instance and simply redirects them to a page of your choice. Provisioning user accounts needs to happen via some other process (e.g. manually, batch processes, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt;, which automatically creates local EPrints users (of type &amp;quot;user&amp;quot;) after successful external authentication.&lt;br /&gt;
Both variants can be extended according to local needs and capabilities, e.g. if your authentication system does not provide additional profile info (name, email, etc.) you could add a lookup from an LDAP directory or database to the code.&lt;br /&gt;
&lt;br /&gt;
Decide on a variant of the login script. We&#039;ll be assuming &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt; since it&#039;s more practically useful for a new install (which is what we&#039;re describing here). Create a directory in your EPrints directory and copy your choice of login script there, naming it &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;. (Again, non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about the login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified (as far as EPrints is concerned) SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Activate the new authentication method ===&lt;br /&gt;
To finally activate the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
Conversely, to deactivate webserver-based authentication and restore EPrints&#039; default authentication method either remove the file or wrap the whole file&#039;s content in a &amp;lt;tt&amp;gt;while(0){&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;}&amp;lt;/tt&amp;gt; block (Perl&#039;s approximation of a block comment) and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10367</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10367"/>
		<updated>2012-03-16T10:14:45Z</updated>

		<summary type="html">&lt;p&gt;Sp: slight rephrasing of headings&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files from http://files.eprints.org/738/&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice and is &#039;&#039;not&#039;&#039; visible to people logging in! (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;), creates new users and sessions, and returns to the originally requested resource.&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the right, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A consequence of external authentication is that no self-registration of user accounts within EPrints is possible (or necessary, as many would see it) anymore, unless the system providing external authentication itself offers self-registration.&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.7) on a newly installed RHEL6 machine. All paths and file names are hence based on an RPM install on RHEL5/6 and will need to be adapted to your webserver and EPrints installation and configuration.&lt;br /&gt;
&lt;br /&gt;
Download the files from http://files.eprints.org/738/ and unpack them to a directory of choice, e.g.&lt;br /&gt;
 cd /tmp&lt;br /&gt;
 wget http://files.eprints.org/738/1/webserver-auth.tgz&lt;br /&gt;
 tar xvzf webserver-auth.tgz&lt;br /&gt;
 cd webserver-auth&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude a resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should not present a nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add the login script ===&lt;br /&gt;
There are two example scripts provided in the package:&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-noprovisioning&amp;lt;/tt&amp;gt;, which failes logins for users not found in your EPrints instance and simply redirects them to a page of your choice. Provisioning user accounts needs to happen via some other process (e.g. manually, batch processes, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt;, which automatically creates local EPrints users (of type &amp;quot;user&amp;quot;) after successful external authentication.&lt;br /&gt;
Both variants can be extended according to local needs and capabilities, e.g. if your authentication system does not provide additional profile info (name, email, etc.) you could add a lookup from an LDAP directory or database to the code.&lt;br /&gt;
&lt;br /&gt;
Decide on a variant of the login script. We&#039;ll be assuming &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt; since it&#039;s more practically useful for a new install (which is what we&#039;re describing here). Create a directory in your EPrints directory and copy your choice of login script there, naming it &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;. (Again, non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about the login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified (as far as EPrints is concerned) SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Activate the new authentication method ===&lt;br /&gt;
To finally activate the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
Conversely, to deactivate webserver-based authentication and restore EPrints&#039; default authentication method either remove the file or wrap the whole file&#039;s content in a &amp;lt;tt&amp;gt;while(0){&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;}&amp;lt;/tt&amp;gt; block (Perl&#039;s approximation of a block comment) and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10366</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10366"/>
		<updated>2012-03-16T10:08:05Z</updated>

		<summary type="html">&lt;p&gt;Sp: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files from http://files.eprints.org/738/&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice and is &#039;&#039;not&#039;&#039; visible to people logging in! (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;), creates new users and sessions, and returns to the originally requested resource.&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the right, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A consequence of external authentication is that no self-registration of user accounts within EPrints is possible (or necessary, as many would see it) anymore, unless the system providing external authentication itself offers self-registration.&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.7) on a newly installed RHEL6 machine. All paths and file names are hence based on an RPM install on RHEL5/6 and will need to be adapted to your webserver and EPrints installation and configuration.&lt;br /&gt;
&lt;br /&gt;
Download the files from http://files.eprints.org/738/ and unpack them to a directory of choice, e.g.&lt;br /&gt;
 cd /tmp&lt;br /&gt;
 wget http://files.eprints.org/738/1/webserver-auth.tgz&lt;br /&gt;
 tar xvzf webserver-auth.tgz&lt;br /&gt;
 cd webserver-auth&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should not present a nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add login script ===&lt;br /&gt;
There are two example scripts provided in the package:&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-noprovisioning&amp;lt;/tt&amp;gt;, which failes logins for users not found in your EPrints instance and simply redirects them to a page of your choice. Provisioning user accounts needs to happen via some other process (e.g. manually, batch processes, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt;, which automatically creates local EPrints users (of type &amp;quot;user&amp;quot;) after successful external authentication.&lt;br /&gt;
Both variants can be extended according to local needs and capabilities, e.g. if your authentication system does not provide additional profile info (name, email, etc.) you could add a lookup from an LDAP directory or database to the code.&lt;br /&gt;
&lt;br /&gt;
Decide on a variant of the login script. We&#039;ll be assuming &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt; since it&#039;s more practically useful for a new install (which is what we&#039;re describing here). Create a directory in your EPrints directory and copy your choice of login script there, naming it &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;. (Again, non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified (as far as EPrints is concerned) SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Tell EPrints about it ===&lt;br /&gt;
To finally activate the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
Conversely, to deactivate webserver-based authentication and restore EPrints&#039; default authentication method either remove the file or wrap the whole file&#039;s content in a &amp;lt;tt&amp;gt;while(0){&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;}&amp;lt;/tt&amp;gt; block (Perl&#039;s approximation of a block comment) and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Files/EPrints_webserver_authentication&amp;diff=10365</id>
		<title>Files/EPrints webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Files/EPrints_webserver_authentication&amp;diff=10365"/>
		<updated>2012-03-16T09:46:22Z</updated>

		<summary type="html">&lt;p&gt;Sp: Redirected page to Webserver authentication&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Webserver authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10364</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10364"/>
		<updated>2012-03-15T20:54:36Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* Exclude resource from EPrints proper */ link 20_baseurls.pl&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not yet included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files from http://files.eprints.org/738/&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice and is &#039;&#039;not&#039;&#039; visible to people logging in! (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;), creates new users and sessions, and returns to the originally requested resource.&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the right, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A consequence of external authentication is that no self-registration of user accounts within EPrints is possible (or necessary, as many would see it) anymore, unless the system providing external authentication itself offers self-registration.&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.7) on a newly installed RHEL6 machine. All paths and file names are hence based on an RPM install on RHEL5/6 and will need to be adapted to your webserver and EPrints installation and configuration.&lt;br /&gt;
&lt;br /&gt;
Download the files from http://files.eprints.org/738/ and unpack them to a directory of choice, e.g.&lt;br /&gt;
 cd /tmp&lt;br /&gt;
 wget http://files.eprints.org/738/1/webserver-auth.tgz&lt;br /&gt;
 tar xvzf webserver-auth.tgz&lt;br /&gt;
 cd webserver-auth&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should not present a nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add login script ===&lt;br /&gt;
There are two example scripts provided in the package:&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-noprovisioning&amp;lt;/tt&amp;gt;, which failes logins for users not found in your EPrints instance and simply redirects them to a page of your choice. Provisioning user accounts needs to happen via some other process (e.g. manually, batch processes, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt;, which automatically creates local EPrints users (of type &amp;quot;user&amp;quot;) after successful external authentication.&lt;br /&gt;
Both variants can be extended according to local needs and capabilities, e.g. if your authentication system does not provide additional profile info (name, email, etc.) you could add a lookup from an LDAP directory or database to the code.&lt;br /&gt;
&lt;br /&gt;
Decide on a variant of the login script. We&#039;ll be assuming &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt; since it&#039;s more practically useful for a new install (which is what we&#039;re describing here). Create a directory in your EPrints directory and copy your choice of login script there, naming it &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;. (Again, non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified (as far as EPrints is concerned) SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Tell EPrints about it ===&lt;br /&gt;
To finally activate the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
Conversely, to deactivate webserver-based authentication and restore EPrints&#039; default authentication method either remove the file or wrap the whole file&#039;s content in a &amp;lt;tt&amp;gt;while(0){&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;}&amp;lt;/tt&amp;gt; block (Perl&#039;s approximation of a block comment) and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10363</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10363"/>
		<updated>2012-03-15T20:54:02Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* Conceptual overview */link 20_baseurls.pl&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not yet included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files from http://files.eprints.org/738/&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice and is &#039;&#039;not&#039;&#039; visible to people logging in! (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/[[20_baseurls.pl]]&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;), creates new users and sessions, and returns to the originally requested resource.&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the right, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A consequence of external authentication is that no self-registration of user accounts within EPrints is possible (or necessary, as many would see it) anymore, unless the system providing external authentication itself offers self-registration.&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.7) on a newly installed RHEL6 machine. All paths and file names are hence based on an RPM install on RHEL5/6 and will need to be adapted to your webserver and EPrints installation and configuration.&lt;br /&gt;
&lt;br /&gt;
Download the files from http://files.eprints.org/738/ and unpack them to a directory of choice, e.g.&lt;br /&gt;
 cd /tmp&lt;br /&gt;
 wget http://files.eprints.org/738/1/webserver-auth.tgz&lt;br /&gt;
 tar xvzf webserver-auth.tgz&lt;br /&gt;
 cd webserver-auth&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/20_baseurls.pl&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should not present a nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add login script ===&lt;br /&gt;
There are two example scripts provided in the package:&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-noprovisioning&amp;lt;/tt&amp;gt;, which failes logins for users not found in your EPrints instance and simply redirects them to a page of your choice. Provisioning user accounts needs to happen via some other process (e.g. manually, batch processes, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt;, which automatically creates local EPrints users (of type &amp;quot;user&amp;quot;) after successful external authentication.&lt;br /&gt;
Both variants can be extended according to local needs and capabilities, e.g. if your authentication system does not provide additional profile info (name, email, etc.) you could add a lookup from an LDAP directory or database to the code.&lt;br /&gt;
&lt;br /&gt;
Decide on a variant of the login script. We&#039;ll be assuming &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt; since it&#039;s more practically useful for a new install (which is what we&#039;re describing here). Create a directory in your EPrints directory and copy your choice of login script there, naming it &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;. (Again, non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified (as far as EPrints is concerned) SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Tell EPrints about it ===&lt;br /&gt;
To finally activate the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
Conversely, to deactivate webserver-based authentication and restore EPrints&#039; default authentication method either remove the file or wrap the whole file&#039;s content in a &amp;lt;tt&amp;gt;while(0){&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;}&amp;lt;/tt&amp;gt; block (Perl&#039;s approximation of a block comment) and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10362</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10362"/>
		<updated>2012-03-15T20:28:08Z</updated>

		<summary type="html">&lt;p&gt;Sp: (provisional) URL for code and configuration&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not yet included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files from http://files.eprints.org/738/&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice and is &#039;&#039;not&#039;&#039; visible to people logging in! (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/20_baseurls.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;), creates new users and sessions, and returns to the originally requested resource.&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the right, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A consequence of external authentication is that no self-registration of user accounts within EPrints is possible (or necessary, as many would see it) anymore, unless the system providing external authentication itself offers self-registration.&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.7) on a newly installed RHEL6 machine. All paths and file names are hence based on an RPM install on RHEL5/6 and will need to be adapted to your webserver and EPrints installation and configuration.&lt;br /&gt;
&lt;br /&gt;
Download the files from http://files.eprints.org/738/ and unpack them to a directory of choice, e.g.&lt;br /&gt;
 cd /tmp&lt;br /&gt;
 wget http://files.eprints.org/738/1/webserver-auth.tgz&lt;br /&gt;
 tar xvzf webserver-auth.tgz&lt;br /&gt;
 cd webserver-auth&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/20_baseurls.pl&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should not present a nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add login script ===&lt;br /&gt;
There are two example scripts provided in the package:&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-noprovisioning&amp;lt;/tt&amp;gt;, which failes logins for users not found in your EPrints instance and simply redirects them to a page of your choice. Provisioning user accounts needs to happen via some other process (e.g. manually, batch processes, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt;, which automatically creates local EPrints users (of type &amp;quot;user&amp;quot;) after successful external authentication.&lt;br /&gt;
Both variants can be extended according to local needs and capabilities, e.g. if your authentication system does not provide additional profile info (name, email, etc.) you could add a lookup from an LDAP directory or database to the code.&lt;br /&gt;
&lt;br /&gt;
Decide on a variant of the login script. We&#039;ll be assuming &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt; since it&#039;s more practically useful for a new install (which is what we&#039;re describing here). Create a directory in your EPrints directory and copy your choice of login script there, naming it &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;. (Again, non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified (as far as EPrints is concerned) SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Tell EPrints about it ===&lt;br /&gt;
To finally activate the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
Conversely, to deactivate webserver-based authentication and restore EPrints&#039; default authentication method either remove the file or wrap the whole file&#039;s content in a &amp;lt;tt&amp;gt;while(0){&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;}&amp;lt;/tt&amp;gt; block (Perl&#039;s approximation of a block comment) and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10361</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10361"/>
		<updated>2012-03-15T20:04:52Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* Tell EPrints about it */ deactive, more clearly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not yet included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files in/from FIXME:&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice and is &#039;&#039;not&#039;&#039; visible to people logging in! (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/20_baseurls.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;), creates new users and sessions, and returns to the originally requested resource.&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the right, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A consequence of external authentication is that no self-registration of user accounts within EPrints is possible (or necessary, as many would see it) anymore, unless the system providing external authentication itself offers self-registration.&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.7) on a newly installed RHEL6 machine. All paths and file names are hence based on an RPM install on RHEL5/6 and will need to be adapted to your webserver and EPrints installation and configuration.&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/20_baseurls.pl&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should not present a nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add login script ===&lt;br /&gt;
There are two example scripts provided in the package:&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-noprovisioning&amp;lt;/tt&amp;gt;, which failes logins for users not found in your EPrints instance and simply redirects them to a page of your choice. Provisioning user accounts needs to happen via some other process (e.g. manually, batch processes, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt;, which automatically creates local EPrints users (of type &amp;quot;user&amp;quot;) after successful external authentication.&lt;br /&gt;
Both variants can be extended according to local needs and capabilities, e.g. if your authentication system does not provide additional profile info (name, email, etc.) you could add a lookup from an LDAP directory or database to the code.&lt;br /&gt;
&lt;br /&gt;
Decide on a variant of the login script. We&#039;ll be assuming &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt; since it&#039;s more practically useful for a new install (which is what we&#039;re describing here). Create a directory in your EPrints directory and copy your choice of login script there, naming it &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;. (Again, non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified (as far as EPrints is concerned) SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Tell EPrints about it ===&lt;br /&gt;
To finally activate the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
Conversely, to deactivate webserver-based authentication and restore EPrints&#039; default authentication method either remove the file or wrap the whole file&#039;s content in a &amp;lt;tt&amp;gt;while(0){&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;}&amp;lt;/tt&amp;gt; block (Perl&#039;s approximation of a block comment) and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10360</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10360"/>
		<updated>2012-03-15T19:54:06Z</updated>

		<summary type="html">&lt;p&gt;Sp: more disclaimers, choice of two login scripts, state use of RPM-based paths once&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not yet included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files in/from FIXME:&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice and is &#039;&#039;not&#039;&#039; visible to people logging in! (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/20_baseurls.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;), creates new users and sessions, and returns to the originally requested resource.&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the right, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A consequence of external authentication is that no self-registration of user accounts within EPrints is possible (or necessary, as many would see it) anymore, unless the system providing external authentication itself offers self-registration.&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.7) on a newly installed RHEL6 machine. All paths and file names are hence based on an RPM install on RHEL5/6 and will need to be adapted to your webserver and EPrints installation and configuration.&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/20_baseurls.pl&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should not present a nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add login script ===&lt;br /&gt;
There are two example scripts provided in the package:&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-noprovisioning&amp;lt;/tt&amp;gt;, which failes logins for users not found in your EPrints instance and simply redirects them to a page of your choice. Provisioning user accounts needs to happen via some other process (e.g. manually, batch processes, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt;, which automatically creates local EPrints users (of type &amp;quot;user&amp;quot;) after successful external authentication.&lt;br /&gt;
Both variants can be extended according to local needs and capabilities, e.g. if your authentication system does not provide additional profile info (name, email, etc.) you could add a lookup from an LDAP directory or database to the code.&lt;br /&gt;
&lt;br /&gt;
Decide on a variant of the login script. We&#039;ll be assuming &amp;lt;tt&amp;gt;login-autocreate&amp;lt;/tt&amp;gt; since it&#039;s more practically useful for a new install (which is what we&#039;re describing here). Create a directory in your EPrints directory and copy your choice of login script there, naming it &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;. (Again, non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified (as far as EPrints is concerned) SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Tell EPrints about it ===&lt;br /&gt;
To finally activate (and deactivate, if you need to) the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10359</id>
		<title>Webserver authentication</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Webserver_authentication&amp;diff=10359"/>
		<updated>2012-03-15T19:32:28Z</updated>

		<summary type="html">&lt;p&gt;Sp: Created page with &amp;#039;How to &amp;#039;&amp;#039;&amp;#039;configure EPrints for authentication via the webserver&amp;#039;&amp;#039;&amp;#039;. This enables/provides for * re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts, * automated Just-In-Ti…&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to &#039;&#039;&#039;configure EPrints for authentication via the webserver&#039;&#039;&#039;. This enables/provides for&lt;br /&gt;
* re-use of externally managed (&amp;quot;enterprise&amp;quot;) user accounts,&lt;br /&gt;
* automated Just-In-Time provisioning (&amp;quot;on-access provisioning&amp;quot;), instead of Just-In-Case (seperately managed batch processes)&lt;br /&gt;
* Web Single Sign-On to EPrints (with Shibboleth, CAS/&amp;lt;tt&amp;gt;mod_cas&amp;lt;/tt&amp;gt;, Kerberos or just about any &amp;lt;tt&amp;gt;mod_auth_*&amp;lt;/tt&amp;gt; Module for Apache httpd).&lt;br /&gt;
With small changes (not yet included below) EPrints user types (&amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Editor&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Repository Administrator&amp;lt;/tt&amp;gt;) could also be assigned dynamically, based on data from an external authoritative source (e.g. an LDAP directory via &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; or an RDBMS via &amp;lt;tt&amp;gt;DBI&amp;lt;/tt&amp;gt;) or recieved as SAML attributes (in case of Shibboleth).&lt;br /&gt;
&lt;br /&gt;
== Conceptual overview ==&lt;br /&gt;
Here&#039;s how this integration works conceptually (not in order of steps performed). Filenames in parentheses refer to the files in/from FIXME:&lt;br /&gt;
# Enable [[HTTPS]] for your webserver and the EPrints instance.&lt;br /&gt;
# Configure EPrints to send requests requiring authentication to a specific resource/URL, we&#039;ll assume &amp;lt;tt&amp;gt;/shibboleth/login&amp;lt;/tt&amp;gt; below but this could be any string of your choice and is &#039;&#039;not&#039;&#039; visible to people logging in! (&amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Make EPrints proper ignore these requests (&amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/20_baseurls.pl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Require authentication (and possibly also authorization) in the webserver for access to this resource (&amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Add code to the installation which handles those pre-authenticated requests (&amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt;), creates new users and sessions, and returns to the originally requested resource.&lt;br /&gt;
&lt;br /&gt;
Note that the recipe below does &#039;&#039;&#039;not&#039;&#039;&#039; provide a parallel authentication method for EPrints -- it completely replaces the default authentication method and login prompt. You can disable the new authentication method to change the user type of some (possibly newly created) user account to &amp;quot;repository administrator&amp;quot; afterwards (when logging in as eprints admin with local/database authentication). Alternatively make sure that a user account already exists within EPrints that is of user type &amp;quot;repository adminstrator&amp;quot; and has a username that can authenticate to the external authentication system (with Shibboleth you&#039;d also need to make sure that this username is returned from the SAML Identity Provider and that the right, i.e., matching username is being mapped to httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable).&lt;br /&gt;
&lt;br /&gt;
A word of warning: Don&#039;t enable this in a production EPrints instance unless either all existing users have matching usernames in your external authentication system, or you can live with the consequences of any and all users being auto-created (again) with different usernames (thereby possibly losing access to all their data, roles, etc.). Updating usernames in EPrints or other migration strategies are &#039;&#039;not&#039;&#039; considered below. Conversely make sure that none of the external usernames &#039;&#039;unintendedly&#039;&#039; match any local EPrints accounts with admin or &amp;quot;repository administrator&amp;quot; or &amp;quot;editor&amp;quot; privileges -- unless you expressly want them to have those privileges.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
The EPrints instance this has been tested with was deployed from the latest [[Installing EPrints 3 on RedHat Enterprise 5|EPrints RPMs]] (which, at the time of writing, was at 3.3.7) on a newly installed RHEL6 machine.&lt;br /&gt;
&lt;br /&gt;
=== TLS/SSL ===&lt;br /&gt;
[[:Category:Authentication|SSL and HTTPS and Secure logins]] have been covered numerous times in this wiki, but most of the material is outdated and some seems horribly cumbersome (or both). Still, there&#039;s no point in creating &#039;&#039;yet another&#039;&#039; how-to for this so we&#039;ll keep this brief. TLS/SSL was enabled in the webserver by first installing the &amp;lt;tt&amp;gt;mod_ssl&amp;lt;/tt&amp;gt; package and configuring a key pair in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;tt&amp;gt;[[Getting Started with EPrints 3|epadmin create]]&amp;lt;/tt&amp;gt; supply a hostname for https connections. &#039;&#039;Contrary&#039;&#039; to a statement from [[Getting Started with EPrints 3]] (&amp;quot;If you will use https for your user pages (including login) enter the https hostname - &#039;&#039;&#039;No doubt, for secure usage you need another name&#039;&#039;&#039;&amp;quot;, my emphasis) this can and probably should be your main EPrints hostname also used for plain HTTP.&lt;br /&gt;
&lt;br /&gt;
(To change this after installation either edit &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/10_core.pl&amp;lt;/tt&amp;gt; or do as suggested in this file and run &amp;lt;tt&amp;gt;epadmin config_core [repo_id]&amp;lt;/tt&amp;gt;. Note that leaving this to &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt; does &#039;&#039;not&#039;&#039; set or change any of the &amp;lt;tt&amp;gt;*root&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;*cgiroot&amp;lt;/tt&amp;gt; statements which are mentioned [[HTTPS|in the wiki]]. Only &amp;lt;tt&amp;gt;$c-&amp;gt;{securehost}&amp;lt;/tt&amp;gt; seems to be needed.)&lt;br /&gt;
&lt;br /&gt;
Since the EPrints RPM already containes &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; EPrints should already be working fine over plain HTTP. To make EPrints available over TLS/SSL as well include the auto-generated SSL-specific config &#039;&#039;inside&#039;&#039; httpd&#039;s existing SSL-vhost as defined in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt; (assuming an RPM-based EPrints install):&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
Check httpd&#039;s config for syntax errors (&amp;lt;tt&amp;gt;apachtectl -t&amp;lt;/tt&amp;gt;) and restart httpd.&lt;br /&gt;
EPrints should now work over both http and https.&lt;br /&gt;
&lt;br /&gt;
=== Webserver authentication ===&lt;br /&gt;
To keep this document short(er) and generally useful, please refer to your webserver&#039;s or authentication system&#039;s documentation for installation and configuration. (Note: For Shibboleth you can [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPLinuxRPMInstall install from RPMs] as well). We&#039;ll assume you have the desired unique identifier for a user available in httpd&#039;s &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; variable, no matter what authentication system used.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
=== Exclude resource from EPrints proper ===&lt;br /&gt;
Add the name of the resource where webserver authentication should happen to the end of &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/20_baseurls.pl&amp;lt;/tt&amp;gt;, e.g.:&lt;br /&gt;
 $c-&amp;gt;{rewrite_exceptions} = [&#039;/shibboleth&#039;];&lt;br /&gt;
After a &amp;lt;tt&amp;gt;service httpd reload&amp;lt;/tt&amp;gt; EPrints should not present a nicely formatted error message when trying to access this resource (compare with any other non-existing request URI). Instead you should see an ordinary HTTP 404 &amp;quot;File not found&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
=== Add login script ===&lt;br /&gt;
Create a directory in your EPrints directory and copy the &amp;lt;tt&amp;gt;login&amp;lt;/tt&amp;gt; script there (non-RPM based installs will possibly need to adjust user, paths and file ownership):&lt;br /&gt;
 su - eprints&lt;br /&gt;
 cd /usr/share/eprints/&lt;br /&gt;
 mkdir shibboleth&lt;br /&gt;
 cp /path/to/login shibboleth/&lt;br /&gt;
 chown eprints:eprints shibboleth/login&lt;br /&gt;
 chmod +x shibboleth/login&lt;br /&gt;
&lt;br /&gt;
=== Tell httpd about login scipt ===&lt;br /&gt;
Next include the content of the file &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; inside your SSL vhost webserver configuration in &amp;lt;tt&amp;gt;/etc/httpd/conf.d/ssl.conf&amp;lt;/tt&amp;gt;, adapting file system paths as necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost _default_:443&amp;gt;&lt;br /&gt;
 ServerName https://your.hostname.example.org:443&lt;br /&gt;
 [...]&lt;br /&gt;
 Alias /shibboleth /usr/share/eprints/shibboleth&lt;br /&gt;
 &amp;lt;Directory &amp;quot;/usr/share/eprints/shibboleth&amp;quot;&amp;gt;&lt;br /&gt;
    SetHandler perl-script&lt;br /&gt;
    PerlHandler ModPerl::Registry&lt;br /&gt;
    PerlSendHeader Off&lt;br /&gt;
    Options ExecCGI FollowSymLinks&lt;br /&gt;
    &lt;br /&gt;
    AuthType shibboleth&lt;br /&gt;
    ShibRequestSetting requireSession 1&lt;br /&gt;
    require valid-user&lt;br /&gt;
 &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;or&#039;&#039;&#039; copy &amp;lt;tt&amp;gt;eprints-httpd-auth.conf&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;/etc/httpd/conf/&amp;lt;/tt&amp;gt; (for example) and only reference it inside your SSL vhost with an include directive. Then you only have two includes in your otherwise unmodified SSL config:&lt;br /&gt;
&lt;br /&gt;
 Include /etc/httpd/conf/eprints-httpd-auth.conf&lt;br /&gt;
 Include /usr/share/eprints/cfg/apache_ssl.conf&lt;br /&gt;
&lt;br /&gt;
Either way, there&#039;s an &amp;lt;tt&amp;gt;Alias&amp;lt;/tt&amp;gt; directive that makes the directory created before available in URL space as &amp;lt;tt&amp;gt;/shibboleth&amp;lt;/tt&amp;gt;, then a content handler is defined for everything in this &amp;lt;tt&amp;gt;&amp;lt;Directory&amp;gt;&amp;lt;/tt&amp;gt;, and finally authentication and autorization is enforced, using Shibboleth only as an example.&lt;br /&gt;
&lt;br /&gt;
With Shibboleth you could restrict logins to specific groups of people. e.g. only faculty and staff from your institution, but not students, or, if you&#039;re part of an [https://refeds.org/ Identity Federation] maybe you need to limit logins to members of specific institutions for some reason. You&#039;d then replace &amp;lt;tt&amp;gt;require valid-user&amp;lt;/tt&amp;gt; (which means anyone authenticated is also authorized to access the resource) with something like:&lt;br /&gt;
 require affiliation ~ ^(faculty|staff)@example\.edu$&lt;br /&gt;
There are [https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPhtaccess examples of the syntax in the Shibboleth documentation].&lt;br /&gt;
&lt;br /&gt;
For other WebSSO or authentication systems that don&#039;t provide any data about the subject to the webserver other than &amp;lt;tt&amp;gt;REMOTE_USER&amp;lt;/tt&amp;gt; (e.g. [http://weblogin.org/ CoSign] or systems using Kerberos) you can combine some of them with authorization in the webserver, e.g. via [http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html mod_authnz_ldap].&lt;br /&gt;
&lt;br /&gt;
Finally, instead of also including this config inside the non-SSL vhost we simply redirect all plain HTTP requests matching our resource to the SSL vhost, where authentication then kicks in. To do that we modify the auto-generated webserver config for EPrints in &amp;lt;tt&amp;gt;/usr/share/eprints/cfg/apache/[repo_id].conf&amp;lt;/tt&amp;gt; and add three Rewrite directives (assuming &amp;lt;tt&amp;gt;mod_rewrite&amp;lt;/tt&amp;gt; is available and has been loaded by the webserver, which usually is the default):&lt;br /&gt;
&lt;br /&gt;
 [...]&lt;br /&gt;
 ServerAdmin you@example.org&lt;br /&gt;
 &lt;br /&gt;
 RewriteEngine On&lt;br /&gt;
 RewriteCond %{REQUEST_URI} ^/shibboleth/&lt;br /&gt;
 RewriteRule ^(.+)$ https://your.hostname.example.org$1 [R]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;Location &amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alternatively&#039;&#039;&#039;, to avoid any unintentional changes to the auto-generated config file, which could be overwritten by careless use of &amp;lt;tt&amp;gt;epadmin&amp;lt;/tt&amp;gt;, you could assemble a config file for the non-SSL vhost yourself, based on the series of Includes starting with &amp;lt;tt&amp;gt;/etc/httpd/conf.d/eprints.conf&amp;lt;/tt&amp;gt; and include that within your httpd config instead.&lt;br /&gt;
&lt;br /&gt;
=== Tell EPrints about it ===&lt;br /&gt;
To finally activate (and deactivate, if you need to) the switch to webserver-based authentication copy &amp;lt;tt&amp;gt;auth.pl&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;archives/[repo_id]/cfg/cfg.d/&amp;lt;/tt&amp;gt; and reload httpd.&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP&amp;diff=10284</id>
		<title>LDAP</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP&amp;diff=10284"/>
		<updated>2012-03-06T20:00:22Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* LDAP Authentication with On-Demand Creation of Users */ as reported by joel.rosental@imdea.org on Wed, 13 Jul 2011 via eprints-tech@ecs.soton.ac.uk&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Authentication]]&lt;br /&gt;
&lt;br /&gt;
==LDAP Authentication==&lt;br /&gt;
&lt;br /&gt;
===LDAP and User Roles===&lt;br /&gt;
&lt;br /&gt;
It is recommended that certain user rights are removed when using LDAP for login. The user should not be allowed to change their password or their email address. It is also suggested that the user not be allowed to edit their profile, however I have found certain fields that I would like the user to edit. To set the rights edit the file : &lt;br /&gt;
&lt;br /&gt;
 vi /opt/eprints3/archives/yourarchivename/cfg/cfg.d/user_roles.pl&lt;br /&gt;
&lt;br /&gt;
 ######################################################################&lt;br /&gt;
 #&lt;br /&gt;
 # User Roles&lt;br /&gt;
 #&lt;br /&gt;
 #  Here you can configure which different types of user are &lt;br /&gt;
 #  parts of the system they are allowed to use.&lt;br /&gt;
 #&lt;br /&gt;
 ######################################################################&lt;br /&gt;
 $c-&amp;gt;{user_roles}-&amp;gt;{user} = [qw/&lt;br /&gt;
        general&lt;br /&gt;
        edit-own-record&lt;br /&gt;
        saved-searches&lt;br /&gt;
        deposit&lt;br /&gt;
 /],&lt;br /&gt;
 $c-&amp;gt;{user_roles}-&amp;gt;{editor} = [qw/&lt;br /&gt;
        general&lt;br /&gt;
        edit-own-record&lt;br /&gt;
        saved-searches&lt;br /&gt;
        deposit&lt;br /&gt;
        editor&lt;br /&gt;
        view-status&lt;br /&gt;
        staff-view&lt;br /&gt;
 /],&lt;br /&gt;
 $c-&amp;gt;{user_roles}-&amp;gt;{admin} = [qw/&lt;br /&gt;
        general&lt;br /&gt;
        edit-own-record&lt;br /&gt;
        saved-searches&lt;br /&gt;
        set-password&lt;br /&gt;
        deposit&lt;br /&gt;
        change-email&lt;br /&gt;
        editor&lt;br /&gt;
        view-status&lt;br /&gt;
        staff-view&lt;br /&gt;
        admin&lt;br /&gt;
 /],&lt;br /&gt;
 #$c-&amp;gt;{user_roles}-&amp;gt;{minuser} = [qw/&lt;br /&gt;
 #       saved-searches&lt;br /&gt;
 #       set-password&lt;br /&gt;
 #       change-email&lt;br /&gt;
 #       change-user&lt;br /&gt;
 #       no_edit_own_record&lt;br /&gt;
 #       lock-username-to-email&lt;br /&gt;
 #/];&lt;br /&gt;
&lt;br /&gt;
After editing restart Apache.&lt;br /&gt;
&lt;br /&gt;
===LDAP Authentication with Bulk Import of Users===&lt;br /&gt;
&lt;br /&gt;
This recipe enables authenticating passwords against an LDAP directory for all users (including administrators). The users will need to already exist in EPrints, most likely created by a bulk import from your LDAP server.&lt;br /&gt;
&lt;br /&gt;
The recommendation for EPrints is not to allow users to alter email and passwords, as these changes are not at present written back to the LDAP database.&lt;br /&gt;
&lt;br /&gt;
====LDAP Configuration====&lt;br /&gt;
&lt;br /&gt;
All changes for LDAP authentication can be made in a single file, the file contains useful notes on configuration. Here is an example from my site, I have configured a standard Samba Domain using LDAP for authentication, if you have similar then this config may work for you :&lt;br /&gt;
&lt;br /&gt;
See [[user_login.pl]] for general information on check_user_password.&lt;br /&gt;
&lt;br /&gt;
Edit the file :&lt;br /&gt;
&lt;br /&gt;
 vi /opt/eprints3/archives/yourarchivename/cfg/cfg.d/user_login.pl&lt;br /&gt;
&lt;br /&gt;
 # This function allows you to override the default username/password&lt;br /&gt;
 # authentication. For example, you could apply different authentication rules to &lt;br /&gt;
 # different types of user.&lt;br /&gt;
 #&lt;br /&gt;
 # Example: LDAP Authentication (Quick Start)&lt;br /&gt;
 #&lt;br /&gt;
 # Tip: use the test script to determine your LDAP parameters first!&lt;br /&gt;
 # Tip: remove the set-password priviledge from users and editors in&lt;br /&gt;
 # user_roles.pl. Also consider removing edit-own-record and &lt;br /&gt;
 # change-email.&lt;br /&gt;
 #&lt;br /&gt;
 use Net::LDAP; # IO::Socket::SSL also required&lt;br /&gt;
 use Net::LDAP::Util;&lt;br /&gt;
 &lt;br /&gt;
 $c-&amp;gt;{check_user_password} = sub {&lt;br /&gt;
  my( $repo, $username, $password ) = @_;&lt;br /&gt;
 &lt;br /&gt;
  my $user = $repo-&amp;gt;user_by_username( $username );&lt;br /&gt;
  return unless $user;&lt;br /&gt;
 &lt;br /&gt;
  $username = $user-&amp;gt;value( &amp;quot;username&amp;quot; );&lt;br /&gt;
 &lt;br /&gt;
  my $user_type = $user-&amp;gt;get_type;&lt;br /&gt;
  if( $user_type eq &amp;quot;admin&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
   # internal authentication for &amp;quot;admin&amp;quot; type&lt;br /&gt;
   return $repo-&amp;gt;database-&amp;gt;valid_login( $username, $password );&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # LDAP authentication for &amp;quot;user&amp;quot; and &amp;quot;editor&amp;quot; types&lt;br /&gt;
  #&lt;br /&gt;
  # LDAP hostname (and port if not the default)&lt;br /&gt;
  my $ldap_host = &amp;quot;ldap.yourdomain.ac.uk&amp;quot;;&lt;br /&gt;
  #my $ldap_host = &amp;quot;ldap.host.name:1234&amp;quot;;&lt;br /&gt;
  #my $ldap_host = &amp;quot;ldaps://ldap.host.name&amp;quot;; # if server supports LDAPS&lt;br /&gt;
 &lt;br /&gt;
  # Distinguished name for this user&lt;br /&gt;
  # The distinguished name is a unique name for an LDAP entry.&lt;br /&gt;
  # e.g. &amp;quot;cn=John Smith, ou=staff, dc=eprints, dc=org&amp;quot;&lt;br /&gt;
  # You will need to derive this from the username or user metadata&lt;br /&gt;
  my $ldap_dn = sprintf(&amp;quot;uid=%s,ou=People,dc=example,dc=org&amp;quot;,&lt;br /&gt;
   Net::LDAP::Util::escape_dn_value($username)&lt;br /&gt;
  );&lt;br /&gt;
 &lt;br /&gt;
  my $ldap = Net::LDAP-&amp;gt;new ( $ldap_host, version =&amp;gt; 3 );&lt;br /&gt;
  unless( $ldap )&lt;br /&gt;
  {&lt;br /&gt;
   $repo-&amp;gt;log( &amp;quot;LDAP error: $@&amp;quot; );&lt;br /&gt;
   return;&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Start secure connection (not needed if using LDAPS)&lt;br /&gt;
  my $ssl = $ldap-&amp;gt;start_tls( sslversion =&amp;gt; &amp;quot;sslv3&amp;quot; );&lt;br /&gt;
  if( $ssl-&amp;gt;code() )&lt;br /&gt;
  {&lt;br /&gt;
   $repo-&amp;gt;log( &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() );&lt;br /&gt;
   return;&lt;br /&gt;
  }&lt;br /&gt;
  # Check password&lt;br /&gt;
  my $mesg = $ldap-&amp;gt;bind( $ldap_dn, password =&amp;gt; $password );&lt;br /&gt;
  if( $mesg-&amp;gt;code() )&lt;br /&gt;
  {&lt;br /&gt;
   return;&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  return $username;&lt;br /&gt;
 }&lt;br /&gt;
 # Advanced LDAP Configuration&lt;br /&gt;
 #&lt;br /&gt;
 # 1. It is also possible to define additional user types, each with a different&lt;br /&gt;
 # authentication mechanism. For example, you could keep the default user, &lt;br /&gt;
 # editor and admin types and add ldapuser, ldapeditor and ldapadmin types with&lt;br /&gt;
 # LDAP authentication - this would suit an arrangement where internal staff are &lt;br /&gt;
 # authenticated against the LDAP server but user accounts can still be granted &lt;br /&gt;
 # to external users.&lt;br /&gt;
 #&lt;br /&gt;
 # 2. Sometimes the distinguished name of the user is not computable from the &lt;br /&gt;
 # username. You may need to use values from the user metadata (e.g. name_given,&lt;br /&gt;
 # name_family):&lt;br /&gt;
 #&lt;br /&gt;
 #       my $name = $user-&amp;gt;get_value( &amp;quot;name&amp;quot; );&lt;br /&gt;
 #       my $ldap_dn = $name-&amp;gt;{family} . &amp;quot;, &amp;quot; . $name-&amp;gt;{given} .&amp;quot;, ou=yourorg, dc=yourdomain&amp;quot;;&lt;br /&gt;
 #&lt;br /&gt;
 # or perform an LDAP lookup to determine it (more complicated):&lt;br /&gt;
 #&lt;br /&gt;
 #       my $base = &amp;quot;ou=yourorg, dc=yourdomain&amp;quot;;&lt;br /&gt;
 #       my $result = $ldap-&amp;gt;search (&lt;br /&gt;
 #               base    =&amp;gt; &amp;quot;$base&amp;quot;,&lt;br /&gt;
 #               scope   =&amp;gt; &amp;quot;sub&amp;quot;,&lt;br /&gt;
 #               filter  =&amp;gt; &amp;quot;cn=$username&amp;quot;,&lt;br /&gt;
 #               attrs   =&amp;gt;  [&#039;DN&#039;],&lt;br /&gt;
 #               sizelimit=&amp;gt;1&lt;br /&gt;
 #       );&lt;br /&gt;
 #&lt;br /&gt;
 #       my $entr = $result-&amp;gt;pop_entry;&lt;br /&gt;
 #       unless( defined $entr )&lt;br /&gt;
 #       {&lt;br /&gt;
 #               return 0;&lt;br /&gt;
 #       }&lt;br /&gt;
 #       my $ldap_dn = $entr-&amp;gt;dn&lt;br /&gt;
 #&lt;br /&gt;
 # Alternatively, you could store the distinguished name as part of the user &lt;br /&gt;
 # metadata when the user account is imported              print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
After editing restart Apache.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LDAP Import====&lt;br /&gt;
&lt;br /&gt;
You can use the [http://files.eprints.org/27/1/update_users update_users script] and apply the following patch to make it work with eprints3:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- update_users.orig   2007-04-23 16:22:26.000000000 +0200&lt;br /&gt;
+++ update_users    2007-04-24 21:16:40.000000000 +0200&lt;br /&gt;
@@ -1,6 +1,6 @@&lt;br /&gt;
-#!/usr/bin/perl -w -I/opt/eprints2/perl_lib&lt;br /&gt;
+#!/usr/bin/perl -w -I/opt/eprints3/perl_lib&lt;br /&gt;
&lt;br /&gt;
-use EPrints::User;&lt;br /&gt;
+use EPrints::DataObj::User;&lt;br /&gt;
 use EPrints::Session;&lt;br /&gt;
 use Net::LDAP;&lt;br /&gt;
 use strict;&lt;br /&gt;
@@ -16,6 +16,7 @@&lt;br /&gt;
&lt;br /&gt;
 # Start connection&lt;br /&gt;
 my $ldap = Net::LDAP-&amp;gt;new( &amp;quot;ldap.host.name&amp;quot;, version =&amp;gt; 3 );&lt;br /&gt;
+$ldap-&amp;gt;start_tls();&lt;br /&gt;
 unless( $ldap )&lt;br /&gt;
 {&lt;br /&gt;
    print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
@@ -74,7 +75,7 @@&lt;br /&gt;
        # New account&lt;br /&gt;
        if( $forreal )&lt;br /&gt;
        {&lt;br /&gt;
-           $user = EPrints::User::create_user( $session, &amp;quot;ldapuser&amp;quot; );&lt;br /&gt;
+           $user = EPrints::DataObj::User::create( $session, &amp;quot;user&amp;quot; );&lt;br /&gt;
            $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
            print &amp;quot;CREATING: $username\n&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
@@ -118,7 +119,7 @@&lt;br /&gt;
        print &amp;quot;FAMILY = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;sn&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        print &amp;quot;GIVEN = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;givenName&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        print &amp;quot;EMAIL = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;mail&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
-       print &amp;quot;DN = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;distinguishedName&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
+       print &amp;quot;DN = &amp;quot; . $entr-&amp;gt;dn . &amp;quot;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===LDAP Authentication with On-Demand Creation of Users===&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example of a customized &amp;lt;tt&amp;gt;/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/user_login.pl&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* allowing LDAP accounts to login, using the &amp;quot;Advanced LDAP Configuration&amp;quot; example&lt;br /&gt;
* allowing the local eprints admin account to login w/ database authentication&lt;br /&gt;
* creating eprints accounts for all successfully authenticated LDAP users &#039;&#039;on the fly&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Most of the code is from the default &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; and from the [http://files.eprints.org/27/1/update_users update_users] script (which does not seem to exist anymore, but code &amp;amp; text below seem to have been written by [[User:Sp]] not later than May 7th 2007).&lt;br /&gt;
&lt;br /&gt;
Be sure to only use this over [[HTTPS]]!&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{check_user_password} = sub {&lt;br /&gt;
    my( $session, $username, $password ) = @_;&lt;br /&gt;
    &lt;br /&gt;
    # LDAP authentication for &amp;quot;user&amp;quot;, &amp;quot;editor&amp;quot; and &amp;quot;admin&amp;quot; types (roles)&lt;br /&gt;
    &lt;br /&gt;
    use Net::LDAP; # IO::Socket::SSL also required&lt;br /&gt;
    &lt;br /&gt;
    # LDAP tunables&lt;br /&gt;
    my $ldap_host = &amp;quot;ldap.example.org&amp;quot;;&lt;br /&gt;
    my $base      = &amp;quot;dc=example,dc=org&amp;quot;;&lt;br /&gt;
    my $dn        = &amp;quot;cn=someProxyAccount,ou=accounts,$base&amp;quot;;&lt;br /&gt;
    &lt;br /&gt;
    my $ldap      = Net::LDAP-&amp;gt;new ( $ldap_host, version =&amp;gt; 3 );&lt;br /&gt;
    unless( $ldap )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Start secure connection (not needed if using LDAPS)&lt;br /&gt;
    my $ssl = $ldap-&amp;gt;start_tls();&lt;br /&gt;
    if( $ssl-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Get password for the search-bind-account&lt;br /&gt;
    my $repository = $session-&amp;gt;get_repository;&lt;br /&gt;
    my $id         = $repository-&amp;gt;get_id;&lt;br /&gt;
    my $ldappass   = `cat /opt/eprints3/archives/$id/cfg/ldap.passwd`;&lt;br /&gt;
    chomp($ldappass);&lt;br /&gt;
    &lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $dn, password=&amp;gt;$ldappass );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP Bind error: &amp;quot; . $mesg-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Distinguished name (and attribues needed later on) for this user&lt;br /&gt;
    my $result = $ldap-&amp;gt;search (&lt;br /&gt;
        base    =&amp;gt; &amp;quot;$base&amp;quot;,&lt;br /&gt;
        scope   =&amp;gt; &amp;quot;sub&amp;quot;,&lt;br /&gt;
        filter  =&amp;gt; &amp;quot;(&amp;amp;(uid=$username)(objectclass=inetOrgPerson))&amp;quot;,&lt;br /&gt;
        attrs   =&amp;gt;  [&#039;1.1&#039;, &#039;uid&#039;, &#039;sn&#039;, &#039;givenname&#039;, &#039;mail&#039;],&lt;br /&gt;
        sizelimit=&amp;gt;1&lt;br /&gt;
    );&lt;br /&gt;
    my $entr = $result-&amp;gt;pop_entry;&lt;br /&gt;
    unless( defined $entr )&lt;br /&gt;
    {&lt;br /&gt;
        # Allow local EPrints authentication for admins (accounts not found in LDAP)&lt;br /&gt;
        my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
        return 0 unless $user;&lt;br /&gt;
        &lt;br /&gt;
        my $user_type = $user-&amp;gt;get_type;&lt;br /&gt;
        if( $user_type eq &amp;quot;admin&amp;quot; )&lt;br /&gt;
        {&lt;br /&gt;
            # internal authentication for &amp;quot;admin&amp;quot; type&lt;br /&gt;
            return $session-&amp;gt;get_database-&amp;gt;valid_login( $username, $password );&lt;br /&gt;
        }&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    my $ldap_dn = $entr-&amp;gt;dn;&lt;br /&gt;
    &lt;br /&gt;
    # Check password&lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $ldap_dn, password =&amp;gt; $password );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Does account already exist?&lt;br /&gt;
    my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
    if( !defined $user )&lt;br /&gt;
    {&lt;br /&gt;
        # New account&lt;br /&gt;
        $user = EPrints::DataObj::User::create( $session, &amp;quot;user&amp;quot; );&lt;br /&gt;
        $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Set metadata&lt;br /&gt;
    my $name = {};&lt;br /&gt;
    $name-&amp;gt;{family} = $entr-&amp;gt;get_value( &amp;quot;sn&amp;quot; );&lt;br /&gt;
    $name-&amp;gt;{given} = $entr-&amp;gt;get_value( &amp;quot;givenName&amp;quot; );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;name&amp;quot;, $name );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;email&amp;quot;, $entr-&amp;gt;get_value( &amp;quot;mail&amp;quot; ) );&lt;br /&gt;
    $user-&amp;gt;commit();&lt;br /&gt;
    &lt;br /&gt;
    $ldap-&amp;gt;unbind if $ldap;&lt;br /&gt;
    &lt;br /&gt;
    return 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
====Things to note====&lt;br /&gt;
&lt;br /&gt;
* This script uses a dedicated proxy account which must exist in your LDAP tree and has appropriate permissions (ACL settings) to search for users and read their &amp;lt;tt&amp;gt;uid,givenname,sn,mail&amp;lt;/tt&amp;gt; attributes.&lt;br /&gt;
* It gets this proxy accounts&#039; password from a file inside the repository configuration. this file needs to have read permissions for the user your webserver runs as (e.g. &amp;lt;tt&amp;gt;www-data&amp;lt;/tt&amp;gt; on Debian).  Use file system permissions to protect this (e.g. &amp;lt;tt&amp;gt;chmod 400 ldap.passwd&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* It changes the flow of &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; a little to only check for local &#039;&#039;admin&#039;&#039; accounts (no users or editors; we have them all in our LDAP tree) and only when no user is found for ldap authentication. This allows you to have your admins in LDAP (if you want) but still use the local admin for &amp;quot;promoting&amp;quot; other users to admins, among other things (which could also be done with a simple SQL &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; directly in the RDBMS). If you don&#039;t need the local admin, remove those lines and just &amp;lt;tt&amp;gt;return 0&amp;lt;/tt&amp;gt; since no user was found in LDAP.&lt;br /&gt;
* you could change the default role for generated user accounts from &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt;, if you really wanted.&lt;br /&gt;
&lt;br /&gt;
====Possible enhancements====&lt;br /&gt;
&lt;br /&gt;
Currently this script does not remove local eprints accounts from the database: when accounts get deleted from the LDAP database the corresponding local EPrints accounts sit around forever. But since login isn&#039;t possible anymore this is not a risk or of high priority.&lt;br /&gt;
&lt;br /&gt;
Depending on your situation it may be enough to run some kind of cleanup script, e.g. once a year, that get&#039;s a list of all local EPrints accounts, loops over them and &amp;lt;code&amp;gt;$user-&amp;gt;remove&amp;lt;/code&amp;gt;s all those, which cannot be found in LDAP anymore (except for those where &amp;lt;code&amp;gt;$user_type eq &#039;admin&#039;&amp;lt;/code&amp;gt;, so you don&#039;t risk losing your local admins).&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP&amp;diff=9185</id>
		<title>LDAP</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP&amp;diff=9185"/>
		<updated>2010-04-28T13:26:02Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* LDAP Authentication with On-Demand Creation of Users */ wiki edits removed all authorship info&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See [[Integrating EPrints with LDAP]] for instructions for Eprints 2.*&lt;br /&gt;
&lt;br /&gt;
==LDAP and User Roles==&lt;br /&gt;
&lt;br /&gt;
It is recommended that certain user rights are removed when using LDAP for login. The user should not be allowed to change their password or their email address. It is also suggested that the user not be allowed to edit their profile, however I have found certain fields that I would like the user to edit. To set the rights edit the file : &lt;br /&gt;
&lt;br /&gt;
 vi /opt/eprints3/archives/yourarchivename/cfg/cfg.d/user_roles.pl&lt;br /&gt;
&lt;br /&gt;
 ######################################################################&lt;br /&gt;
 #&lt;br /&gt;
 # User Roles&lt;br /&gt;
 #&lt;br /&gt;
 #  Here you can configure which different types of user are &lt;br /&gt;
 #  parts of the system they are allowed to use.&lt;br /&gt;
 #&lt;br /&gt;
 ######################################################################&lt;br /&gt;
 $c-&amp;gt;{user_roles}-&amp;gt;{user} = [qw/&lt;br /&gt;
        general&lt;br /&gt;
        edit-own-record&lt;br /&gt;
        saved-searches&lt;br /&gt;
        deposit&lt;br /&gt;
 /],&lt;br /&gt;
 $c-&amp;gt;{user_roles}-&amp;gt;{editor} = [qw/&lt;br /&gt;
        general&lt;br /&gt;
        edit-own-record&lt;br /&gt;
        saved-searches&lt;br /&gt;
        deposit&lt;br /&gt;
        editor&lt;br /&gt;
        view-status&lt;br /&gt;
        staff-view&lt;br /&gt;
 /],&lt;br /&gt;
 $c-&amp;gt;{user_roles}-&amp;gt;{admin} = [qw/&lt;br /&gt;
        general&lt;br /&gt;
        edit-own-record&lt;br /&gt;
        saved-searches&lt;br /&gt;
        set-password&lt;br /&gt;
        deposit&lt;br /&gt;
        change-email&lt;br /&gt;
        editor&lt;br /&gt;
        view-status&lt;br /&gt;
        staff-view&lt;br /&gt;
        admin&lt;br /&gt;
 /],&lt;br /&gt;
 #$c-&amp;gt;{user_roles}-&amp;gt;{minuser} = [qw/&lt;br /&gt;
 #       saved-searches&lt;br /&gt;
 #       set-password&lt;br /&gt;
 #       change-email&lt;br /&gt;
 #       change-user&lt;br /&gt;
 #       no_edit_own_record&lt;br /&gt;
 #       lock-username-to-email&lt;br /&gt;
 #/];&lt;br /&gt;
&lt;br /&gt;
After editing restart Apache.&lt;br /&gt;
&lt;br /&gt;
==LDAP Authentication with Bulk Import of Users==&lt;br /&gt;
&lt;br /&gt;
This recipe enables authenticating passwords against an LDAP directory for all users (including administrators). The users will need to already exist in EPrints, most likely created by a bulk import from your LDAP server.&lt;br /&gt;
&lt;br /&gt;
The recommendation for EPrints is not to allow users to alter email and passwords, as these changes are not at present written back to the LDAP database.&lt;br /&gt;
&lt;br /&gt;
===LDAP Configuration===&lt;br /&gt;
&lt;br /&gt;
All changes for LDAP authentication can be made in a single file, the file contains useful notes on configuration. Here is an example from my site, I have configured a standard Samba Domain using LDAP for authentication, if you have similar then this config may work for you :&lt;br /&gt;
&lt;br /&gt;
Edit the file :&lt;br /&gt;
&lt;br /&gt;
 vi /opt/eprints3/archives/yourarchivename/cfg/cfg.d/user_login.pl&lt;br /&gt;
&lt;br /&gt;
 # This function allows you to override the default username/password&lt;br /&gt;
 # authentication. For example, you could apply different authentication rules to &lt;br /&gt;
 # different types of user.&lt;br /&gt;
 #&lt;br /&gt;
 # Example: LDAP Authentication (Quick Start)&lt;br /&gt;
 #&lt;br /&gt;
 # Tip: use the test script to determine your LDAP parameters first!&lt;br /&gt;
 # Tip: remove the set-password priviledge from users and editors in&lt;br /&gt;
 # user_roles.pl. Also consider removing edit-own-record and &lt;br /&gt;
 # change-email.&lt;br /&gt;
 #&lt;br /&gt;
 $c-&amp;gt;{check_user_password} = sub {&lt;br /&gt;
         my( $session, $username, $password ) = @_;&lt;br /&gt;
         my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
         return 0 unless $user;&lt;br /&gt;
         my $user_type = $user-&amp;gt;get_type;&lt;br /&gt;
         if( $user_type eq &amp;quot;admin&amp;quot; )&lt;br /&gt;
        {&lt;br /&gt;
        #       internal authentication for &amp;quot;admin&amp;quot; type&lt;br /&gt;
        #       return EPrints::Apache::Login::valid_login( $session, $username, $password );&lt;br /&gt;
        return $session-&amp;gt;get_database-&amp;gt;valid_login( $username, $password );&lt;br /&gt;
        }&lt;br /&gt;
 # LDAP authentication for &amp;quot;user&amp;quot; and &amp;quot;editor&amp;quot; types&lt;br /&gt;
 #&lt;br /&gt;
 # LDAP hostname (and port if not the default)&lt;br /&gt;
        my $ldap_host = &amp;quot;ldap.yourdomain.ac.uk&amp;quot;;&lt;br /&gt;
 #       #my $ldap_host = &amp;quot;ldap.host.name:1234&amp;quot;;&lt;br /&gt;
 #       #my $ldap_host = &amp;quot;ldaps://ldap.host.name&amp;quot;; # if server supports LDAPS&lt;br /&gt;
 #&lt;br /&gt;
 # Distinguished name for this user&lt;br /&gt;
 # The distinguished name is a unique name for an LDAP entry.&lt;br /&gt;
 # e.g. &amp;quot;cn=John Smith, ou=staff, dc=eprints, dc=org&amp;quot;&lt;br /&gt;
 # You will need to derive this from the username or user metadata&lt;br /&gt;
         my $ldap_dn = &amp;quot;uid=$username,ou=People,dc=yourdomain,dc=ac,dc=uk&amp;quot;;&lt;br /&gt;
 #&lt;br /&gt;
         use Net::LDAP; # IO::Socket::SSL also required&lt;br /&gt;
 #&lt;br /&gt;
         my $ldap = Net::LDAP-&amp;gt;new ( $ldap_host, version =&amp;gt; 3 );&lt;br /&gt;
         unless( $ldap )&lt;br /&gt;
         {&lt;br /&gt;
                 print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
                 return 0;&lt;br /&gt;
         }&lt;br /&gt;
 #&lt;br /&gt;
 # Start secure connection (not needed if using LDAPS)&lt;br /&gt;
         my $ssl = $ldap-&amp;gt;start_tls( sslversion =&amp;gt; &amp;quot;sslv3&amp;quot; );&lt;br /&gt;
         if( $ssl-&amp;gt;code() )&lt;br /&gt;
         {&lt;br /&gt;
                 print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
                 return 0;&lt;br /&gt;
        }&lt;br /&gt;
 # Check password&lt;br /&gt;
        my $mesg = $ldap-&amp;gt;bind( $ldap_dn, password =&amp;gt; $password );&lt;br /&gt;
        if( $mesg-&amp;gt;code() )&lt;br /&gt;
        {&lt;br /&gt;
                return 0;&lt;br /&gt;
        }&lt;br /&gt;
        return 1;&lt;br /&gt;
 }&lt;br /&gt;
 # Advanced LDAP Configuration&lt;br /&gt;
 #&lt;br /&gt;
 # 1. It is also possible to define additional user types, each with a different&lt;br /&gt;
 # authentication mechanism. For example, you could keep the default user, &lt;br /&gt;
 # editor and admin types and add ldapuser, ldapeditor and ldapadmin types with&lt;br /&gt;
 # LDAP authentication - this would suit an arrangement where internal staff are &lt;br /&gt;
 # authenticated against the LDAP server but user accounts can still be granted &lt;br /&gt;
 # to external users.&lt;br /&gt;
 #&lt;br /&gt;
 # 2. Sometimes the distinguished name of the user is not computable from the &lt;br /&gt;
 # username. You may need to use values from the user metadata (e.g. name_given,&lt;br /&gt;
 # name_family):&lt;br /&gt;
 #&lt;br /&gt;
 #       my $name = $user-&amp;gt;get_value( &amp;quot;name&amp;quot; );&lt;br /&gt;
 #       my $ldap_dn = $name-&amp;gt;{family} . &amp;quot;, &amp;quot; . $name-&amp;gt;{given} .&amp;quot;, ou=yourorg, dc=yourdomain&amp;quot;;&lt;br /&gt;
 #&lt;br /&gt;
 # or perform an LDAP lookup to determine it (more complicated):&lt;br /&gt;
 #&lt;br /&gt;
 #       my $base = &amp;quot;ou=yourorg, dc=yourdomain&amp;quot;;&lt;br /&gt;
 #       my $result = $ldap-&amp;gt;search (&lt;br /&gt;
 #               base    =&amp;gt; &amp;quot;$base&amp;quot;,&lt;br /&gt;
 #               scope   =&amp;gt; &amp;quot;sub&amp;quot;,&lt;br /&gt;
 #               filter  =&amp;gt; &amp;quot;cn=$username&amp;quot;,&lt;br /&gt;
 #               attrs   =&amp;gt;  [&#039;DN&#039;],&lt;br /&gt;
 #               sizelimit=&amp;gt;1&lt;br /&gt;
 #       );&lt;br /&gt;
 #&lt;br /&gt;
 #       my $entr = $result-&amp;gt;pop_entry;&lt;br /&gt;
 #       unless( defined $entr )&lt;br /&gt;
 #       {&lt;br /&gt;
 #               return 0;&lt;br /&gt;
 #       }&lt;br /&gt;
 #       my $ldap_dn = $entr-&amp;gt;dn&lt;br /&gt;
 #&lt;br /&gt;
 # Alternatively, you could store the distinguished name as part of the user &lt;br /&gt;
 # metadata when the user account is imported              print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
After editing restart Apache.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===LDAP Import===&lt;br /&gt;
&lt;br /&gt;
You can use the [http://files.eprints.org/27/1/update_users update_users script] and apply the following patch to make it work with eprints3:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- update_users.orig   2007-04-23 16:22:26.000000000 +0200&lt;br /&gt;
+++ update_users    2007-04-24 21:16:40.000000000 +0200&lt;br /&gt;
@@ -1,6 +1,6 @@&lt;br /&gt;
-#!/usr/bin/perl -w -I/opt/eprints2/perl_lib&lt;br /&gt;
+#!/usr/bin/perl -w -I/opt/eprints3/perl_lib&lt;br /&gt;
&lt;br /&gt;
-use EPrints::User;&lt;br /&gt;
+use EPrints::DataObj::User;&lt;br /&gt;
 use EPrints::Session;&lt;br /&gt;
 use Net::LDAP;&lt;br /&gt;
 use strict;&lt;br /&gt;
@@ -16,6 +16,7 @@&lt;br /&gt;
&lt;br /&gt;
 # Start connection&lt;br /&gt;
 my $ldap = Net::LDAP-&amp;gt;new( &amp;quot;ldap.host.name&amp;quot;, version =&amp;gt; 3 );&lt;br /&gt;
+$ldap-&amp;gt;start_tls();&lt;br /&gt;
 unless( $ldap )&lt;br /&gt;
 {&lt;br /&gt;
    print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
@@ -74,7 +75,7 @@&lt;br /&gt;
        # New account&lt;br /&gt;
        if( $forreal )&lt;br /&gt;
        {&lt;br /&gt;
-           $user = EPrints::User::create_user( $session, &amp;quot;ldapuser&amp;quot; );&lt;br /&gt;
+           $user = EPrints::DataObj::User::create( $session, &amp;quot;user&amp;quot; );&lt;br /&gt;
            $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
            print &amp;quot;CREATING: $username\n&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
@@ -118,7 +119,7 @@&lt;br /&gt;
        print &amp;quot;FAMILY = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;sn&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        print &amp;quot;GIVEN = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;givenName&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        print &amp;quot;EMAIL = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;mail&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
-       print &amp;quot;DN = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;distinguishedName&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
+       print &amp;quot;DN = &amp;quot; . $entr-&amp;gt;dn . &amp;quot;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==LDAP Authentication with On-Demand Creation of Users==&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example of a customized &amp;lt;tt&amp;gt;/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/user_login.pl&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* allowing LDAP accounts to login, using the &amp;quot;Advanced LDAP Configuration&amp;quot; example&lt;br /&gt;
* allowing the local eprints admin account to login w/ database authentication&lt;br /&gt;
* creating eprints accounts for all successfully authenticated LDAP users &#039;&#039;on the fly&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Most of the code is from the default &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; and from the [http://files.eprints.org/27/1/update_users update_users] script (which does not seem to exist anymore, but code &amp;amp; text below seem to have been written by [[User:Sp]] not later than May 7th 2007).&lt;br /&gt;
&lt;br /&gt;
Be sure to only use this over [[HTTPS]]!&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{check_user_password} = sub {&lt;br /&gt;
    my( $session, $username, $password ) = @_;&lt;br /&gt;
    &lt;br /&gt;
    # LDAP authentication for &amp;quot;user&amp;quot;, &amp;quot;editor&amp;quot; and &amp;quot;admin&amp;quot; types (roles)&lt;br /&gt;
    &lt;br /&gt;
    use Net::LDAP; # IO::Socket::SSL also required&lt;br /&gt;
    &lt;br /&gt;
    # LDAP tunables&lt;br /&gt;
    my $ldap_host = &amp;quot;ldap.example.org&amp;quot;;&lt;br /&gt;
    my $base      = &amp;quot;dc=example,dc=org&amp;quot;;&lt;br /&gt;
    my $dn        = &amp;quot;cn=someProxyAccount,ou=accounts,$base&amp;quot;;&lt;br /&gt;
    &lt;br /&gt;
    my $ldap      = Net::LDAP-&amp;gt;new ( $ldap_host, version =&amp;gt; 3 );&lt;br /&gt;
    unless( $ldap )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Start secure connection (not needed if using LDAPS)&lt;br /&gt;
    my $ssl = $ldap-&amp;gt;start_tls();&lt;br /&gt;
    if( $ssl-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Get password for the search-bind-account&lt;br /&gt;
    my $repository = $session-&amp;gt;get_repository;&lt;br /&gt;
    my $id         = $repository-&amp;gt;get_id;&lt;br /&gt;
    my $ldappass   = `cat /opt/eprints3/archives/$id/cfg/ldap.passwd`;&lt;br /&gt;
    chomp($ldappass);&lt;br /&gt;
    &lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $dn, password=&amp;gt;$password );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP Bind error: &amp;quot; . $mesg-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Distinguished name (and attribues needed later on) for this user&lt;br /&gt;
    my $result = $ldap-&amp;gt;search (&lt;br /&gt;
        base    =&amp;gt; &amp;quot;$base&amp;quot;,&lt;br /&gt;
        scope   =&amp;gt; &amp;quot;sub&amp;quot;,&lt;br /&gt;
        filter  =&amp;gt; &amp;quot;(&amp;amp;(uid=$username)(objectclass=inetOrgPerson))&amp;quot;,&lt;br /&gt;
        attrs   =&amp;gt;  [&#039;1.1&#039;, &#039;uid&#039;, &#039;sn&#039;, &#039;givenname&#039;, &#039;mail&#039;],&lt;br /&gt;
        sizelimit=&amp;gt;1&lt;br /&gt;
    );&lt;br /&gt;
    my $entr = $result-&amp;gt;pop_entry;&lt;br /&gt;
    unless( defined $entr )&lt;br /&gt;
    {&lt;br /&gt;
        # Allow local EPrints authentication for admins (accounts not found in LDAP)&lt;br /&gt;
        my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
        return 0 unless $user;&lt;br /&gt;
        &lt;br /&gt;
        my $user_type = $user-&amp;gt;get_type;&lt;br /&gt;
        if( $user_type eq &amp;quot;admin&amp;quot; )&lt;br /&gt;
        {&lt;br /&gt;
            # internal authentication for &amp;quot;admin&amp;quot; type&lt;br /&gt;
            return $session-&amp;gt;get_database-&amp;gt;valid_login( $username, $password );&lt;br /&gt;
        }&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    my $ldap_dn = $entr-&amp;gt;dn;&lt;br /&gt;
    &lt;br /&gt;
    # Check password&lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $ldap_dn, password =&amp;gt; $password );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Does account already exist?&lt;br /&gt;
    my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
    if( !defined $user )&lt;br /&gt;
    {&lt;br /&gt;
        # New account&lt;br /&gt;
        $user = EPrints::DataObj::User::create( $session, &amp;quot;user&amp;quot; );&lt;br /&gt;
        $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Set metadata&lt;br /&gt;
    my $name = {};&lt;br /&gt;
    $name-&amp;gt;{family} = $entr-&amp;gt;get_value( &amp;quot;sn&amp;quot; );&lt;br /&gt;
    $name-&amp;gt;{given} = $entr-&amp;gt;get_value( &amp;quot;givenName&amp;quot; );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;name&amp;quot;, $name );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;email&amp;quot;, $entr-&amp;gt;get_value( &amp;quot;mail&amp;quot; ) );&lt;br /&gt;
    $user-&amp;gt;commit();&lt;br /&gt;
    &lt;br /&gt;
    $ldap-&amp;gt;unbind if $ldap;&lt;br /&gt;
    &lt;br /&gt;
    return 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== things to note ===&lt;br /&gt;
&lt;br /&gt;
* This script uses a dedicated proxy account which must exist in your LDAP tree and has appropriate permissions (ACL settings) to search for users and read their &amp;lt;tt&amp;gt;uid,givenname,sn,mail&amp;lt;/tt&amp;gt; attributes.&lt;br /&gt;
* It gets this proxy accounts&#039; password from a file inside the repository configuration. this file needs to have read permissions for the user your webserver runs as (e.g. &amp;lt;tt&amp;gt;www-data&amp;lt;/tt&amp;gt; on Debian).  Use file system permissions to protect this (e.g. &amp;lt;tt&amp;gt;chmod 400 ldap.passwd&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* It changes the flow of &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; a little to only check for local &#039;&#039;admin&#039;&#039; accounts (no users or editors; we have them all in our LDAP tree) and only when no user is found for ldap authentication. This allows you to have your admins in LDAP (if you want) but still use the local admin for &amp;quot;promoting&amp;quot; other users to admins, among other things (which could also be done with a simple SQL &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; directly in the RDBMS). If you don&#039;t need the local admin, remove those lines and just &amp;lt;tt&amp;gt;return 0&amp;lt;/tt&amp;gt; since no user was found in LDAP.&lt;br /&gt;
* you could change the default role for generated user accounts from &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt;, if you really wanted.&lt;br /&gt;
&lt;br /&gt;
=== possible enhancements ===&lt;br /&gt;
&lt;br /&gt;
Currently this script does not remove local eprints accounts from the database: when accounts get deleted from the LDAP database the corresponding local EPrints accounts sit around forever. But since login isn&#039;t possible anymore this is not a risk or of high priority.&lt;br /&gt;
&lt;br /&gt;
Depending on your situation it may be enough to run some kind of cleanup script, e.g. once a year, that get&#039;s a list of all local EPrints accounts, loops over them and &amp;lt;code&amp;gt;$user-&amp;gt;remove&amp;lt;/code&amp;gt;s all those, which cannot be found in LDAP anymore (except for those where &amp;lt;code&amp;gt;$user_type eq &#039;admin&#039;&amp;lt;/code&amp;gt;, so you don&#039;t risk losing your local admins).&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP_user_login.pl&amp;diff=4273</id>
		<title>LDAP user login.pl</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP_user_login.pl&amp;diff=4273"/>
		<updated>2007-04-24T22:52:24Z</updated>

		<summary type="html">&lt;p&gt;Sp: bootstrapping admins: use SQL&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== LDAP Authentication and Provisioning example ==&lt;br /&gt;
Here&#039;s an example of a customized &amp;lt;tt&amp;gt;/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/user_login.pl&amp;lt;/tt&amp;gt;&lt;br /&gt;
* allowing LDAP accounts to login, using the &amp;quot;Advanced LDAP Configuration&amp;quot; example&lt;br /&gt;
* allowing the local eprints admin account to login w/ database authentication&lt;br /&gt;
* creating eprints accounts for all successfully authenticated LDAP users &#039;&#039;on the fly&#039;&#039;&lt;br /&gt;
Most of the code is from the default &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; and from the [http://files.eprints.org/27/1/update_users update_users] script.&lt;br /&gt;
&lt;br /&gt;
Be sure to only use this over [[HTTPS]]!&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{check_user_password} = sub {&lt;br /&gt;
    my( $session, $username, $password ) = @_;&lt;br /&gt;
    &lt;br /&gt;
    # LDAP authentication for &amp;quot;user&amp;quot;, &amp;quot;editor&amp;quot; and &amp;quot;admin&amp;quot; types (roles)&lt;br /&gt;
    &lt;br /&gt;
    use Net::LDAP; # IO::Socket::SSL also required&lt;br /&gt;
    &lt;br /&gt;
    # LDAP tunables&lt;br /&gt;
    my $ldap_host = &amp;quot;ldap.example.org&amp;quot;;&lt;br /&gt;
    my $base      = &amp;quot;dc=example,dc=org&amp;quot;;&lt;br /&gt;
    my $dn        = &amp;quot;cn=someProxyAccount,ou=accounts,$base&amp;quot;;&lt;br /&gt;
    &lt;br /&gt;
    my $ldap      = Net::LDAP-&amp;gt;new ( $ldap_host, version =&amp;gt; 3 );&lt;br /&gt;
    unless( $ldap )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Start secure connection (not needed if using LDAPS)&lt;br /&gt;
    my $ssl = $ldap-&amp;gt;start_tls();&lt;br /&gt;
    if( $ssl-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Get password for the search-bind-account&lt;br /&gt;
    my $repository = $session-&amp;gt;get_repository;&lt;br /&gt;
    my $id         = $repository-&amp;gt;get_id;&lt;br /&gt;
    my $ldappass   = `cat /opt/eprints3/archives/$id/cfg/ldap.passwd`;&lt;br /&gt;
    chomp($ldappass);&lt;br /&gt;
    &lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $dn, password=&amp;gt;$password );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP Bind error: &amp;quot; . $mesg-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Distinguished name (and attribues needed later on) for this user&lt;br /&gt;
    my $result = $ldap-&amp;gt;search (&lt;br /&gt;
        base    =&amp;gt; &amp;quot;$base&amp;quot;,&lt;br /&gt;
        scope   =&amp;gt; &amp;quot;sub&amp;quot;,&lt;br /&gt;
        filter  =&amp;gt; &amp;quot;(&amp;amp;(uid=$username)(objectclass=inetOrgPerson))&amp;quot;,&lt;br /&gt;
        attrs   =&amp;gt;  [&#039;1.1&#039;, &#039;uid&#039;, &#039;sn&#039;, &#039;givenname&#039;, &#039;mail&#039;],&lt;br /&gt;
        sizelimit=&amp;gt;1&lt;br /&gt;
    );&lt;br /&gt;
    my $entr = $result-&amp;gt;pop_entry;&lt;br /&gt;
    unless( defined $entr )&lt;br /&gt;
    {&lt;br /&gt;
        # Allow local EPrints authentication for admins (accounts not found in LDAP)&lt;br /&gt;
        my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
        return 0 unless $user;&lt;br /&gt;
        &lt;br /&gt;
        my $user_type = $user-&amp;gt;get_type;&lt;br /&gt;
        if( $user_type eq &amp;quot;admin&amp;quot; )&lt;br /&gt;
        {&lt;br /&gt;
            # internal authentication for &amp;quot;admin&amp;quot; type&lt;br /&gt;
            return $session-&amp;gt;get_database-&amp;gt;valid_login( $username, $password );&lt;br /&gt;
        }&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    my $ldap_dn = $entr-&amp;gt;dn;&lt;br /&gt;
    &lt;br /&gt;
    # Check password&lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $ldap_dn, password =&amp;gt; $password );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Does account already exist?&lt;br /&gt;
    my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
    if( !defined $user )&lt;br /&gt;
    {&lt;br /&gt;
        # New account&lt;br /&gt;
        $user = EPrints::DataObj::User::create( $session, &amp;quot;user&amp;quot; );&lt;br /&gt;
        $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Set metadata&lt;br /&gt;
    my $name = {};&lt;br /&gt;
    $name-&amp;gt;{family} = $entr-&amp;gt;get_value( &amp;quot;sn&amp;quot; );&lt;br /&gt;
    $name-&amp;gt;{given} = $entr-&amp;gt;get_value( &amp;quot;givenName&amp;quot; );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;name&amp;quot;, $name );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;email&amp;quot;, $entr-&amp;gt;get_value( &amp;quot;mail&amp;quot; ) );&lt;br /&gt;
    $user-&amp;gt;commit();&lt;br /&gt;
    &lt;br /&gt;
    $ldap-&amp;gt;unbind if $ldap;&lt;br /&gt;
    &lt;br /&gt;
    return 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== things to note ==&lt;br /&gt;
* This script uses a dedicated proxy account which must exist in your LDAP tree and has appropriate permissions (ACL settings) to search for users and read their &amp;lt;tt&amp;gt;uid,givenname,sn,mail&amp;lt;/tt&amp;gt; attributes.&lt;br /&gt;
* It get&#039;s this proxy accounts&#039; password from a file inside the repository configuration. this file needs to have read permissions for the user your webserver runs as (e.g. &amp;lt;tt&amp;gt;www-data&amp;lt;/tt&amp;gt; on Debian).  Use file system permissions to protect this (e.g. &amp;lt;tt&amp;gt;chmod 400 ldap.passwd&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* It changes the flow of &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; a little to only check for local &#039;&#039;admin&#039;&#039; accounts (no users or editors; we have them all in our LDAP tree) and only when no user is found for ldap authentication. This allows you to have your admins in LDAP (if you want) but still use the local admin for &amp;quot;promoting&amp;quot; other users to admins, among other things (which could also be done with a simple SQL &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; directly in the RDBMS). If you don&#039;t need the local admin, remove those lines and just &amp;lt;tt&amp;gt;return 0&amp;lt;/tt&amp;gt; since no user was found in LDAP.&lt;br /&gt;
* you could change the default role for generated user accounts from &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt;, if you really wanted.&lt;br /&gt;
&lt;br /&gt;
== possible enhancements ==&lt;br /&gt;
=== removing stale accounts ===&lt;br /&gt;
Currently this script does not remove local eprints accounts from the database: when accounts get deleted from the LDAP database the corresponding local EPrints accounts sit around forever. But since login isn&#039;t possible anymore this is not a risk or of high priority.&lt;br /&gt;
&lt;br /&gt;
Depending on your situation it may be enough to run some kind of cleanup script, e.g. once a year, that get&#039;s a list of all local EPrints accounts, loops over them and &amp;lt;code&amp;gt;$user-&amp;gt;remove&amp;lt;/code&amp;gt;s all those, which cannot be found in LDAP anymore (except for those where &amp;lt;code&amp;gt;$user_type eq &#039;admin&#039;&amp;lt;/code&amp;gt;, so you don&#039;t risk losing your local admins).&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP_user_login.pl&amp;diff=4272</id>
		<title>LDAP user login.pl</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP_user_login.pl&amp;diff=4272"/>
		<updated>2007-04-24T22:48:44Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* possible enhancements */ more relevant use case&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== LDAP Authentication and Provisioning example ==&lt;br /&gt;
Here&#039;s an example of a customized &amp;lt;tt&amp;gt;/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/user_login.pl&amp;lt;/tt&amp;gt;&lt;br /&gt;
* allowing LDAP accounts to login, using the &amp;quot;Advanced LDAP Configuration&amp;quot; example&lt;br /&gt;
* allowing the local eprints admin account to login w/ database authentication&lt;br /&gt;
* creating eprints accounts for all successfully authenticated LDAP users &#039;&#039;on the fly&#039;&#039;&lt;br /&gt;
Most of the code is from the default &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; and from the [http://files.eprints.org/27/1/update_users update_users] script.&lt;br /&gt;
&lt;br /&gt;
Be sure to only use this over [[HTTPS]]!&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{check_user_password} = sub {&lt;br /&gt;
    my( $session, $username, $password ) = @_;&lt;br /&gt;
    &lt;br /&gt;
    # LDAP authentication for &amp;quot;user&amp;quot;, &amp;quot;editor&amp;quot; and &amp;quot;admin&amp;quot; types (roles)&lt;br /&gt;
    &lt;br /&gt;
    use Net::LDAP; # IO::Socket::SSL also required&lt;br /&gt;
    &lt;br /&gt;
    # LDAP tunables&lt;br /&gt;
    my $ldap_host = &amp;quot;ldap.example.org&amp;quot;;&lt;br /&gt;
    my $base      = &amp;quot;dc=example,dc=org&amp;quot;;&lt;br /&gt;
    my $dn        = &amp;quot;cn=someProxyAccount,ou=accounts,$base&amp;quot;;&lt;br /&gt;
    &lt;br /&gt;
    my $ldap      = Net::LDAP-&amp;gt;new ( $ldap_host, version =&amp;gt; 3 );&lt;br /&gt;
    unless( $ldap )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Start secure connection (not needed if using LDAPS)&lt;br /&gt;
    my $ssl = $ldap-&amp;gt;start_tls();&lt;br /&gt;
    if( $ssl-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Get password for the search-bind-account&lt;br /&gt;
    my $repository = $session-&amp;gt;get_repository;&lt;br /&gt;
    my $id         = $repository-&amp;gt;get_id;&lt;br /&gt;
    my $ldappass   = `cat /opt/eprints3/archives/$id/cfg/ldap.passwd`;&lt;br /&gt;
    chomp($ldappass);&lt;br /&gt;
    &lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $dn, password=&amp;gt;$password );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP Bind error: &amp;quot; . $mesg-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Distinguished name (and attribues needed later on) for this user&lt;br /&gt;
    my $result = $ldap-&amp;gt;search (&lt;br /&gt;
        base    =&amp;gt; &amp;quot;$base&amp;quot;,&lt;br /&gt;
        scope   =&amp;gt; &amp;quot;sub&amp;quot;,&lt;br /&gt;
        filter  =&amp;gt; &amp;quot;(&amp;amp;(uid=$username)(objectclass=inetOrgPerson))&amp;quot;,&lt;br /&gt;
        attrs   =&amp;gt;  [&#039;1.1&#039;, &#039;uid&#039;, &#039;sn&#039;, &#039;givenname&#039;, &#039;mail&#039;],&lt;br /&gt;
        sizelimit=&amp;gt;1&lt;br /&gt;
    );&lt;br /&gt;
    my $entr = $result-&amp;gt;pop_entry;&lt;br /&gt;
    unless( defined $entr )&lt;br /&gt;
    {&lt;br /&gt;
        # Allow local EPrints authentication for admins (accounts not found in LDAP)&lt;br /&gt;
        my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
        return 0 unless $user;&lt;br /&gt;
        &lt;br /&gt;
        my $user_type = $user-&amp;gt;get_type;&lt;br /&gt;
        if( $user_type eq &amp;quot;admin&amp;quot; )&lt;br /&gt;
        {&lt;br /&gt;
            # internal authentication for &amp;quot;admin&amp;quot; type&lt;br /&gt;
            return $session-&amp;gt;get_database-&amp;gt;valid_login( $username, $password );&lt;br /&gt;
        }&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    my $ldap_dn = $entr-&amp;gt;dn;&lt;br /&gt;
    &lt;br /&gt;
    # Check password&lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $ldap_dn, password =&amp;gt; $password );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Does account already exist?&lt;br /&gt;
    my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
    if( !defined $user )&lt;br /&gt;
    {&lt;br /&gt;
        # New account&lt;br /&gt;
        $user = EPrints::DataObj::User::create( $session, &amp;quot;user&amp;quot; );&lt;br /&gt;
        $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Set metadata&lt;br /&gt;
    my $name = {};&lt;br /&gt;
    $name-&amp;gt;{family} = $entr-&amp;gt;get_value( &amp;quot;sn&amp;quot; );&lt;br /&gt;
    $name-&amp;gt;{given} = $entr-&amp;gt;get_value( &amp;quot;givenName&amp;quot; );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;name&amp;quot;, $name );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;email&amp;quot;, $entr-&amp;gt;get_value( &amp;quot;mail&amp;quot; ) );&lt;br /&gt;
    $user-&amp;gt;commit();&lt;br /&gt;
    &lt;br /&gt;
    $ldap-&amp;gt;unbind if $ldap;&lt;br /&gt;
    &lt;br /&gt;
    return 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== things to note ==&lt;br /&gt;
* This script uses a dedicated proxy account which must exist in your LDAP tree and has appropriate permissions (ACL settings) to search for users and read their &amp;lt;tt&amp;gt;uid,givenname,sn,mail&amp;lt;/tt&amp;gt; attributes.&lt;br /&gt;
* It get&#039;s this proxy accounts&#039; password from a file inside the repository configuration. this file needs to have read permissions for the user your webserver runs as (e.g. &amp;lt;tt&amp;gt;www-data&amp;lt;/tt&amp;gt; on Debian).  Use file system permissions to protect this (e.g. &amp;lt;tt&amp;gt;chmod 400 ldap.passwd&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* It changes the flow of &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; a little to only check for local &#039;&#039;admin&#039;&#039; accounts (no users or editors; we have them all in our LDAP tree) and only when no user is found for ldap authentication. This allows you to have your admins in LDAP (if you want) but still use the local admin for &amp;quot;promoting&amp;quot; other users to admins, among other things. If you don&#039;t need the local admin, remove those lines and just &amp;lt;tt&amp;gt;return 0&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* you could change the default role for generated user accounts from &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt;, if you really wanted.&lt;br /&gt;
&lt;br /&gt;
== possible enhancements ==&lt;br /&gt;
=== removing stale accounts ===&lt;br /&gt;
Currently this script does not remove local eprints accounts from the database: when accounts get deleted from the LDAP database the corresponding local EPrints accounts sit around forever. But since login isn&#039;t possible anymore this is not a risk or of high priority.&lt;br /&gt;
&lt;br /&gt;
Depending on your situation it may be enough to run some kind of cleanup script, e.g. once a year, that get&#039;s a list of all local EPrints accounts, loops over them and &amp;lt;code&amp;gt;$user-&amp;gt;remove&amp;lt;/code&amp;gt;s all those, which cannot be found in LDAP anymore (except for those where &amp;lt;code&amp;gt;$user_type eq &#039;admin&#039;&amp;lt;/code&amp;gt;, so you don&#039;t risk losing your local admins).&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Integrating_EPrints_with_LDAP&amp;diff=4271</id>
		<title>Integrating EPrints with LDAP</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Integrating_EPrints_with_LDAP&amp;diff=4271"/>
		<updated>2007-04-24T21:45:20Z</updated>

		<summary type="html">&lt;p&gt;Sp: eprints2 specific warning&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Note&#039;&#039;&#039;: some things on this page are specific to EPrints2. EPrints3 comes with example code in &amp;lt;tt&amp;gt;archives/ARCHIVEID/cfg/cfg.d/user_login.pl&amp;lt;/tt&amp;gt; that just needs to be uncommented (and maybe customised). See [[LDAP]] or [[LDAP_user_login.pl]] for examples.&lt;br /&gt;
You also do not &#039;&#039;have&#039;&#039; to create ldapuser, ldapeditor and ldapadmin, you may also use the plain variants if you plan on using &#039;&#039;only&#039;&#039; LDAP accounts.&lt;br /&gt;
&lt;br /&gt;
==Install Prerequisites==&lt;br /&gt;
&lt;br /&gt;
Install the &amp;lt;tt&amp;gt;Net::LDAP&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;IO::Socket::SSL&amp;lt;/tt&amp;gt; modules.&lt;br /&gt;
&lt;br /&gt;
==Determine LDAP Setup==&lt;br /&gt;
&lt;br /&gt;
The first step is to get Perl talking to your LDAP server. Determine the following parameters:&lt;br /&gt;
&lt;br /&gt;
* the LDAP server name&lt;br /&gt;
* if the server doesn&#039;t support anonymous binds, a distinguished name (e.g. &amp;lt;tt&amp;gt;OU=jsmith, OU=users, DC=somewhere, DC=edu&amp;lt;/tt&amp;gt;) and password to bind with&lt;br /&gt;
* the base name of user accounts (e.g. &amp;lt;tt&amp;gt;OU=users, DC=somewhere, DC=edu&amp;lt;/tt&amp;gt;)&lt;br /&gt;
* the name of the username field (e.g. &amp;lt;tt&amp;gt;samaccountname&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;cn&amp;lt;/tt&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;http://files.eprints.org/27/01/ldaplookup&amp;lt;/tt&amp;gt; script should get you started. Add your LDAP parameters to the script.&lt;br /&gt;
&lt;br /&gt;
When run with an username as its parameter, &amp;lt;tt&amp;gt;ldaplookup&amp;lt;/tt&amp;gt; should dump all the information associated with that account:&lt;br /&gt;
&lt;br /&gt;
 $ ./ldaplookup jsmith&lt;br /&gt;
 Using LDAP protocol version 3&lt;br /&gt;
 LDAP_EXTENSION_START_TLS supported&lt;br /&gt;
 ------------------------------------------------------------------------&lt;br /&gt;
 dn:CN=jsmith,OU=users,DC=somewhere,DC=edu&lt;br /&gt;
               objectClass: top&lt;br /&gt;
                            person&lt;br /&gt;
                            organizationalPerson&lt;br /&gt;
                            user&lt;br /&gt;
                        cn: jsmith&lt;br /&gt;
                        sn: Smith&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
You will probably need to tweak the LDAP parameters to suit your setup. See &amp;lt;tt&amp;gt;perldoc Net::LDAP&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Configure user authentication==&lt;br /&gt;
&lt;br /&gt;
The EPrints configuration lets you specify any number of user types (the defaults are &amp;quot;user&amp;quot;, &amp;quot;editor&amp;quot; and &amp;quot;admin&amp;quot;) each of which can be authorised in a different way. Suppose we want to have user, editor and admin accounts that are authorised by our LDAP server (i.e. internal staff) and also user, editor and admin accounts that are local to EPrints and authorised in the usual way (i.e. external users).&lt;br /&gt;
&lt;br /&gt;
==Create new user types==&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;tt&amp;gt;/opt/eprints2/archives/ARCHIVEID/cfg/metadata-types.xml&amp;lt;/tt&amp;gt;, copy and paste the existing user, editor, and admin types and change their names to ldapuser, ldapeditor and ldapadmin:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;dataset name=&amp;quot;user&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;type name=&amp;quot;ldapuser&amp;quot; &amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;password&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;username&amp;quot; staffonly=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
        ...&lt;br /&gt;
    &amp;lt;/type&amp;gt;&lt;br /&gt;
    &amp;lt;type name=&amp;quot;ldapeditor&amp;quot; &amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;password&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;username&amp;quot; staffonly=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
        ...&lt;br /&gt;
    &amp;lt;/type&amp;gt;&lt;br /&gt;
    &amp;lt;type name=&amp;quot;ldapadmin&amp;quot; &amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;password&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;usertype&amp;quot; staffonly=&amp;quot;yes&amp;quot; /&amp;gt;&lt;br /&gt;
        ...&lt;br /&gt;
    &amp;lt;/type&amp;gt;&lt;br /&gt;
    &amp;lt;type name=&amp;quot;user&amp;quot; &amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;password&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;usertype&amp;quot; staffonly=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
        ...&lt;br /&gt;
    &amp;lt;/type&amp;gt;&lt;br /&gt;
    &amp;lt;type name=&amp;quot;editor&amp;quot; &amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;password&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;usertype&amp;quot; staffonly=&amp;quot;yes&amp;quot; /&amp;gt;&lt;br /&gt;
        ...&lt;br /&gt;
    &amp;lt;/type&amp;gt;&lt;br /&gt;
    &amp;lt;type name=&amp;quot;admin&amp;quot; &amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;password&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;username&amp;quot; staffonly=&amp;quot;yes&amp;quot; /&amp;gt;&lt;br /&gt;
        ...&lt;br /&gt;
    &amp;lt;/type&amp;gt;&lt;br /&gt;
 &amp;lt;/dataset&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Define user citation styles==&lt;br /&gt;
&lt;br /&gt;
Define citation styles for the new user types in &amp;lt;tt&amp;gt;/opt/eprints2/archives/ARCHIVEID/cfg/citations-en.xml&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
Just copy and paste the citation types for user_user, user_editor and user_admin and rename them to user_ldapuser, user_ldapeditor and user_ldapadmin.&lt;br /&gt;
&lt;br /&gt;
==Define user typenames==&lt;br /&gt;
&lt;br /&gt;
Define typenames for the new user types in &amp;lt;tt&amp;gt;/opt/eprints2/archives/ARCHIVEID/cfg/phrases-en.xml&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
Just copy and paste the phrases for user_typename_user, user_typename_editor and user_typename_admin and rename them to user_typename_ldapuser, user_typename_ldapeditor and user_typename_ldapadmin. &lt;br /&gt;
&lt;br /&gt;
Then, adjust the three new phrases values, e.g., the phrase value for the user_typename_ldapuser could be changed from &amp;quot;User&amp;quot; to &amp;quot;LDAP User&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Configure user authentication==&lt;br /&gt;
&lt;br /&gt;
Now configure user authentication in &amp;lt;tt&amp;gt;/opt/eprints2/archives/ARCHIVEID/cfg/ArchiveConfig.pm&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 my $LDAP = { handler =&amp;gt; \&amp;amp;ldapauthen };&lt;br /&gt;
  &lt;br /&gt;
 $c-&amp;gt;{userauth} = {&lt;br /&gt;
    user =&amp;gt; {&lt;br /&gt;
        auth  =&amp;gt; $CRYPTED_DBI,&lt;br /&gt;
        priv  =&amp;gt;  [ &amp;quot;subscription&amp;quot;, &amp;quot;set-password&amp;quot;, &amp;quot;deposit&amp;quot;, &amp;quot;change-email&amp;quot;, &amp;quot;change-user&amp;quot; ] },&lt;br /&gt;
    editor =&amp;gt; {&lt;br /&gt;
        auth  =&amp;gt; $CRYPTED_DBI,&lt;br /&gt;
        priv  =&amp;gt;  [ &amp;quot;subscription&amp;quot;, &amp;quot;set-password&amp;quot;, &amp;quot;deposit&amp;quot;, &amp;quot;change-email&amp;quot;, &amp;quot;change-user&amp;quot;,&lt;br /&gt;
                &amp;quot;view-status&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;staff-view&amp;quot; ] },&lt;br /&gt;
    admin =&amp;gt; {&lt;br /&gt;
        auth  =&amp;gt; $CRYPTED_DBI,&lt;br /&gt;
        priv  =&amp;gt;  [ &amp;quot;subscription&amp;quot;, &amp;quot;set-password&amp;quot;, &amp;quot;deposit&amp;quot;, &amp;quot;change-email&amp;quot;, &amp;quot;change-user&amp;quot;,&lt;br /&gt;
                &amp;quot;view-status&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;staff-view&amp;quot;,&lt;br /&gt;
                &amp;quot;edit-subject&amp;quot;, &amp;quot;edit-user&amp;quot; ] },&lt;br /&gt;
    ldapuser =&amp;gt; {&lt;br /&gt;
        auth  =&amp;gt; $LDAP,&lt;br /&gt;
        priv  =&amp;gt;  [ &amp;quot;subscription&amp;quot;, &amp;quot;set-password&amp;quot;, &amp;quot;deposit&amp;quot;,  &amp;quot;change-user&amp;quot;,&amp;quot;no_edit_own_record&amp;quot; ] },&lt;br /&gt;
    ldapeditor =&amp;gt; {&lt;br /&gt;
        auth  =&amp;gt; $LDAP,&lt;br /&gt;
        priv  =&amp;gt;  [ &amp;quot;subscription&amp;quot;, &amp;quot;set-password&amp;quot;, &amp;quot;deposit&amp;quot;,  &amp;quot;change-user&amp;quot;,&amp;quot;no_edit_own_record&amp;quot;,&lt;br /&gt;
                &amp;quot;view-status&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;staff-view&amp;quot; ] },&lt;br /&gt;
    ldapadmin =&amp;gt; {&lt;br /&gt;
        auth  =&amp;gt; $LDAP,&lt;br /&gt;
        priv  =&amp;gt;  [ &amp;quot;subscription&amp;quot;, &amp;quot;set-password&amp;quot;, &amp;quot;deposit&amp;quot;, &amp;quot;change-user&amp;quot;,&lt;br /&gt;
                &amp;quot;view-status&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;staff-view&amp;quot;, &amp;quot;edit-user&amp;quot; ] },&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
Here, the default user, editor and admin user types are still authenticated using the usual &amp;lt;tt&amp;gt;$CRYPTED_DBI&amp;lt;/tt&amp;gt; construct, whereas ldapuser, ldapeditor and ldapadmin are authenticated by the &amp;lt;tt&amp;gt;$LDAP&amp;lt;/tt&amp;gt; construct that we defined.&lt;br /&gt;
&lt;br /&gt;
==Define LDAP authentication function==&lt;br /&gt;
&lt;br /&gt;
Add the &amp;lt;tt&amp;gt;ldapauthen&amp;lt;/tt&amp;gt; function to the end of &amp;lt;tt&amp;gt;ArchiveConfig.pm&amp;lt;/tt&amp;gt;, filling in your LDAP settings:&lt;br /&gt;
&lt;br /&gt;
 use Net::LDAP;&lt;br /&gt;
 BEGIN {&lt;br /&gt;
    eval &amp;quot;use Apache::Const &#039;:common&#039;&amp;quot; || eval &amp;quot;use Apache2::Const &#039;:common&#039;&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 sub ldapauthen&lt;br /&gt;
 {&lt;br /&gt;
    my ($r) = @_;&lt;br /&gt;
    my ($key, $val, $dbh);&lt;br /&gt;
  &lt;br /&gt;
    return OK unless $r-&amp;gt;is_initial_req; # only the first internal request&lt;br /&gt;
  &lt;br /&gt;
    my($res, $passwd_sent) = $r-&amp;gt;get_basic_auth_pw;&lt;br /&gt;
    return $res if $res; # e.g. HTTP_UNAUTHORIZED&lt;br /&gt;
  &lt;br /&gt;
    # get username&lt;br /&gt;
    my ($user_sent) = $r-&amp;gt;user;&lt;br /&gt;
  &lt;br /&gt;
    my $ldap = Net::LDAP-&amp;gt;new ( &amp;quot;ldap.host.name&amp;quot;, version=&amp;gt;3 );&lt;br /&gt;
    $ldap-&amp;gt;start_tls( sslversion=&amp;gt;&#039;sslv2&#039; );&lt;br /&gt;
  &lt;br /&gt;
    unless( $ldap )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;$@&amp;quot;;&lt;br /&gt;
        return SERVER_ERROR;&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    # If the distinguished name of the user is not&lt;br /&gt;
    # computable from the username, perform a lookup&lt;br /&gt;
    # to determine the distinguished name&lt;br /&gt;
  &lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind;&lt;br /&gt;
    # If your LDAP server doesn&#039;t allow anonymous binds&lt;br /&gt;
    # supply the dn/password of a valid account here&lt;br /&gt;
    # (e.g. an &#039;eprints&#039; account created specially for&lt;br /&gt;
    # this purpose)&lt;br /&gt;
    #my $dn = &amp;quot;&amp;quot;;&lt;br /&gt;
    #my $pword = &amp;quot;&amp;quot;;&lt;br /&gt;
    #my $mesg = $ldap-&amp;gt;bind( $dn, password=&amp;gt;$pword );&lt;br /&gt;
  &lt;br /&gt;
    my $base = &amp;quot;ou=user, dc=somewhere, dc=edu&amp;quot;;&lt;br /&gt;
    my $result = $ldap-&amp;gt;search (&lt;br /&gt;
                base    =&amp;gt; &amp;quot;$base&amp;quot;,&lt;br /&gt;
                scope   =&amp;gt; &amp;quot;sub&amp;quot;,&lt;br /&gt;
                filter  =&amp;gt; &amp;quot;cn=$user_sent&amp;quot;,&lt;br /&gt;
                attrs   =&amp;gt;  [&#039;DN&#039;],&lt;br /&gt;
                sizelimit=&amp;gt;1&lt;br /&gt;
              );&lt;br /&gt;
  &lt;br /&gt;
    my $entr = $result-&amp;gt;pop_entry;&lt;br /&gt;
    unless( defined $entr )&lt;br /&gt;
    {&lt;br /&gt;
        $r-&amp;gt;note_basic_auth_failure;&lt;br /&gt;
        return AUTH_REQUIRED;&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    # Bind with the distinguished name and password of the user&lt;br /&gt;
    # If the distinguished name of the user is computable, this&lt;br /&gt;
    # is the only step required&lt;br /&gt;
    my $mesg2 = $ldap-&amp;gt;bind( $entr-&amp;gt;dn, password=&amp;gt;$passwd_sent );&lt;br /&gt;
    if( $mesg2-&amp;gt;code )&lt;br /&gt;
    {&lt;br /&gt;
        $r-&amp;gt;note_basic_auth_failure;&lt;br /&gt;
        return AUTH_REQUIRED;&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    return OK;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Reload configuration==&lt;br /&gt;
&lt;br /&gt;
Restart the apache server to reload the new configuration.&lt;br /&gt;
&lt;br /&gt;
==Import user accounts from LDAP==&lt;br /&gt;
&lt;br /&gt;
The final step is to import existing user accounts from the LDAP server.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;http://files.eprints.org/27/01/update_users&amp;lt;/tt&amp;gt; script should get you started. Copy it to the &amp;lt;tt&amp;gt;/opt/eprints2/bin&amp;lt;/tt&amp;gt; directory and add your LDAP settings.&lt;br /&gt;
&lt;br /&gt;
Set &amp;lt;tt&amp;gt;$forreal&amp;lt;/tt&amp;gt; to 1 to make changes to the database.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
* If you see a &amp;quot;Sizelimit exceeded&amp;quot; error, you may need to import users in smaller batches, for example a faculty/dept at a time.&lt;br /&gt;
* &amp;lt;tt&amp;gt;update_users&amp;lt;/tt&amp;gt; should be scheduled regularly using &amp;lt;tt&amp;gt;cron&amp;lt;/tt&amp;gt; to keep EPrints in sync with the LDAP server&lt;br /&gt;
* For EPrints3 you will need to update two lines below;&lt;br /&gt;
*: &amp;lt;tt&amp;gt;Line 3:&amp;lt;/tt&amp;gt; use EPrints::DataObj::User; #use EPrints::User;&lt;br /&gt;
*: &amp;lt;tt&amp;gt;Line 77:&amp;lt;/tt&amp;gt; $user = EPrints::DataObj::User::create($session,&amp;quot;ldapuser&amp;quot;); #$user = EPrints::User::create_user( $session, &amp;quot;ldapuser&amp;quot; );&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP_user_login.pl&amp;diff=4270</id>
		<title>LDAP user login.pl</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP_user_login.pl&amp;diff=4270"/>
		<updated>2007-04-24T21:26:31Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* LDAP Authentication and Provisioning example */ $id probably has not trailing \n&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== LDAP Authentication and Provisioning example ==&lt;br /&gt;
Here&#039;s an example of a customized &amp;lt;tt&amp;gt;/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/user_login.pl&amp;lt;/tt&amp;gt;&lt;br /&gt;
* allowing LDAP accounts to login, using the &amp;quot;Advanced LDAP Configuration&amp;quot; example&lt;br /&gt;
* allowing the local eprints admin account to login w/ database authentication&lt;br /&gt;
* creating eprints accounts for all successfully authenticated LDAP users &#039;&#039;on the fly&#039;&#039;&lt;br /&gt;
Most of the code is from the default &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; and from the [http://files.eprints.org/27/1/update_users update_users] script.&lt;br /&gt;
&lt;br /&gt;
Be sure to only use this over [[HTTPS]]!&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{check_user_password} = sub {&lt;br /&gt;
    my( $session, $username, $password ) = @_;&lt;br /&gt;
    &lt;br /&gt;
    # LDAP authentication for &amp;quot;user&amp;quot;, &amp;quot;editor&amp;quot; and &amp;quot;admin&amp;quot; types (roles)&lt;br /&gt;
    &lt;br /&gt;
    use Net::LDAP; # IO::Socket::SSL also required&lt;br /&gt;
    &lt;br /&gt;
    # LDAP tunables&lt;br /&gt;
    my $ldap_host = &amp;quot;ldap.example.org&amp;quot;;&lt;br /&gt;
    my $base      = &amp;quot;dc=example,dc=org&amp;quot;;&lt;br /&gt;
    my $dn        = &amp;quot;cn=someProxyAccount,ou=accounts,$base&amp;quot;;&lt;br /&gt;
    &lt;br /&gt;
    my $ldap      = Net::LDAP-&amp;gt;new ( $ldap_host, version =&amp;gt; 3 );&lt;br /&gt;
    unless( $ldap )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Start secure connection (not needed if using LDAPS)&lt;br /&gt;
    my $ssl = $ldap-&amp;gt;start_tls();&lt;br /&gt;
    if( $ssl-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Get password for the search-bind-account&lt;br /&gt;
    my $repository = $session-&amp;gt;get_repository;&lt;br /&gt;
    my $id         = $repository-&amp;gt;get_id;&lt;br /&gt;
    my $ldappass   = `cat /opt/eprints3/archives/$id/cfg/ldap.passwd`;&lt;br /&gt;
    chomp($ldappass);&lt;br /&gt;
    &lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $dn, password=&amp;gt;$password );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP Bind error: &amp;quot; . $mesg-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Distinguished name (and attribues needed later on) for this user&lt;br /&gt;
    my $result = $ldap-&amp;gt;search (&lt;br /&gt;
        base    =&amp;gt; &amp;quot;$base&amp;quot;,&lt;br /&gt;
        scope   =&amp;gt; &amp;quot;sub&amp;quot;,&lt;br /&gt;
        filter  =&amp;gt; &amp;quot;(&amp;amp;(uid=$username)(objectclass=inetOrgPerson))&amp;quot;,&lt;br /&gt;
        attrs   =&amp;gt;  [&#039;1.1&#039;, &#039;uid&#039;, &#039;sn&#039;, &#039;givenname&#039;, &#039;mail&#039;],&lt;br /&gt;
        sizelimit=&amp;gt;1&lt;br /&gt;
    );&lt;br /&gt;
    my $entr = $result-&amp;gt;pop_entry;&lt;br /&gt;
    unless( defined $entr )&lt;br /&gt;
    {&lt;br /&gt;
        # Allow local EPrints authentication for admins (accounts not found in LDAP)&lt;br /&gt;
        my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
        return 0 unless $user;&lt;br /&gt;
        &lt;br /&gt;
        my $user_type = $user-&amp;gt;get_type;&lt;br /&gt;
        if( $user_type eq &amp;quot;admin&amp;quot; )&lt;br /&gt;
        {&lt;br /&gt;
            # internal authentication for &amp;quot;admin&amp;quot; type&lt;br /&gt;
            return $session-&amp;gt;get_database-&amp;gt;valid_login( $username, $password );&lt;br /&gt;
        }&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    my $ldap_dn = $entr-&amp;gt;dn;&lt;br /&gt;
    &lt;br /&gt;
    # Check password&lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $ldap_dn, password =&amp;gt; $password );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Does account already exist?&lt;br /&gt;
    my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
    if( !defined $user )&lt;br /&gt;
    {&lt;br /&gt;
        # New account&lt;br /&gt;
        $user = EPrints::DataObj::User::create( $session, &amp;quot;user&amp;quot; );&lt;br /&gt;
        $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Set metadata&lt;br /&gt;
    my $name = {};&lt;br /&gt;
    $name-&amp;gt;{family} = $entr-&amp;gt;get_value( &amp;quot;sn&amp;quot; );&lt;br /&gt;
    $name-&amp;gt;{given} = $entr-&amp;gt;get_value( &amp;quot;givenName&amp;quot; );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;name&amp;quot;, $name );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;email&amp;quot;, $entr-&amp;gt;get_value( &amp;quot;mail&amp;quot; ) );&lt;br /&gt;
    $user-&amp;gt;commit();&lt;br /&gt;
    &lt;br /&gt;
    $ldap-&amp;gt;unbind if $ldap;&lt;br /&gt;
    &lt;br /&gt;
    return 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== things to note ==&lt;br /&gt;
* This script uses a dedicated proxy account which must exist in your LDAP tree and has appropriate permissions (ACL settings) to search for users and read their &amp;lt;tt&amp;gt;uid,givenname,sn,mail&amp;lt;/tt&amp;gt; attributes.&lt;br /&gt;
* It get&#039;s this proxy accounts&#039; password from a file inside the repository configuration. this file needs to have read permissions for the user your webserver runs as (e.g. &amp;lt;tt&amp;gt;www-data&amp;lt;/tt&amp;gt; on Debian).  Use file system permissions to protect this (e.g. &amp;lt;tt&amp;gt;chmod 400 ldap.passwd&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* It changes the flow of &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; a little to only check for local &#039;&#039;admin&#039;&#039; accounts (no users or editors; we have them all in our LDAP tree) and only when no user is found for ldap authentication. This allows you to have your admins in LDAP (if you want) but still use the local admin for &amp;quot;promoting&amp;quot; other users to admins, among other things. If you don&#039;t need the local admin, remove those lines and just &amp;lt;tt&amp;gt;return 0&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* you could change the default role for generated user accounts from &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt;, if you really wanted.&lt;br /&gt;
&lt;br /&gt;
== possible enhancements ==&lt;br /&gt;
* Currently this script does not remove local eprints accounts from the database. If you limited login to EPrints with an LDAP attribute (e.g. &amp;lt;tt&amp;gt;allowedServices=eprints&amp;lt;/tt&amp;gt;) you could authenticate first (without filtering for this attribute) and in the case of successful authentication check for the existance of the &amp;lt;tt&amp;gt;allowedServices&amp;lt;/tt&amp;gt; attribute. If it&#039;s missing delete the local eprints user account (e.g. &amp;lt;tt&amp;gt;$user-&amp;gt;remove&amp;lt;/tt&amp;gt;) and &amp;lt;tt&amp;gt;return 0&amp;lt;/tt&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP&amp;diff=4269</id>
		<title>LDAP</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP&amp;diff=4269"/>
		<updated>2007-04-24T21:25:36Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* Introduction */ importing done, computers can be filtered&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See [[Integrating EPrints with LDAP]] for instructions for Eprints 2.*&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
I decided that importing all users from my LDAP repository was not a good idea, I run Samba and an import would mean setting up 75 computers with access to eprints (when not filtering these out). I now create each user that requires access and use LDAP for authentication. This means that my users still only need to remember one password.&lt;br /&gt;
&lt;br /&gt;
The recommendation for Eprints is not to allow users to alter email and passwords, as these changes are not at present written back to the LDAP database.&lt;br /&gt;
&lt;br /&gt;
==LDAP Configuration==&lt;br /&gt;
&lt;br /&gt;
All changes for LDAP authentication can be made in a single file, the file contains useful notes on configuration. Here is an example from my site, I have configured a standard Samba Domain using LDAP for authentication, if you have similar then this config may work for you :&lt;br /&gt;
&lt;br /&gt;
Edit the file :&lt;br /&gt;
&lt;br /&gt;
 vi /var/lib/eprints3/archives/yourarchivename/cfg/cfg.d/user_login.pl&lt;br /&gt;
&lt;br /&gt;
 # This function allows you to override the default username/password&lt;br /&gt;
 # authentication. For example, you could apply different authentication rules to &lt;br /&gt;
 # different types of user.&lt;br /&gt;
 #&lt;br /&gt;
 # Example: LDAP Authentication (Quick Start)&lt;br /&gt;
 #&lt;br /&gt;
 # Tip: use the test script to determine your LDAP parameters first!&lt;br /&gt;
 # Tip: remove the set-password priviledge from users and editors in&lt;br /&gt;
 # user_roles.pl. Also consider removing edit-own-record and &lt;br /&gt;
 # change-email.&lt;br /&gt;
 #&lt;br /&gt;
 $c-&amp;gt;{check_user_password} = sub {&lt;br /&gt;
         my( $session, $username, $password ) = @_;&lt;br /&gt;
         my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
         return 0 unless $user;&lt;br /&gt;
         my $user_type = $user-&amp;gt;get_type;&lt;br /&gt;
         if( $user_type eq &amp;quot;admin&amp;quot; )&lt;br /&gt;
        {&lt;br /&gt;
        #       internal authentication for &amp;quot;admin&amp;quot; type&lt;br /&gt;
        #       return EPrints::Apache::Login::valid_login( $session, $username, $password );&lt;br /&gt;
        return $session-&amp;gt;get_database-&amp;gt;valid_login( $username, $password );&lt;br /&gt;
        }&lt;br /&gt;
 # LDAP authentication for &amp;quot;user&amp;quot; and &amp;quot;editor&amp;quot; types&lt;br /&gt;
 #&lt;br /&gt;
 # LDAP hostname (and port if not the default)&lt;br /&gt;
        my $ldap_host = &amp;quot;ldap.yourdomain.ac.uk&amp;quot;;&lt;br /&gt;
 #       #my $ldap_host = &amp;quot;ldap.host.name:1234&amp;quot;;&lt;br /&gt;
 #       #my $ldap_host = &amp;quot;ldaps://ldap.host.name&amp;quot;; # if server supports LDAPS&lt;br /&gt;
 #&lt;br /&gt;
 # Distinguished name for this user&lt;br /&gt;
 # The distinguished name is a unique name for an LDAP entry.&lt;br /&gt;
 # e.g. &amp;quot;cn=John Smith, ou=staff, dc=eprints, dc=org&amp;quot;&lt;br /&gt;
 # You will need to derive this from the username or user metadata&lt;br /&gt;
         my $ldap_dn = &amp;quot;uid=$username,ou=People,dc=yourdomain,dc=ac,dc=uk&amp;quot;;&lt;br /&gt;
 #&lt;br /&gt;
         use Net::LDAP; # IO::Socket::SSL also required&lt;br /&gt;
 #&lt;br /&gt;
         my $ldap = Net::LDAP-&amp;gt;new ( $ldap_host, version =&amp;gt; 3 );&lt;br /&gt;
         unless( $ldap )&lt;br /&gt;
         {&lt;br /&gt;
                 print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
                 return 0;&lt;br /&gt;
         }&lt;br /&gt;
 #&lt;br /&gt;
 # Start secure connection (not needed if using LDAPS)&lt;br /&gt;
         my $ssl = $ldap-&amp;gt;start_tls( sslversion =&amp;gt; &amp;quot;sslv3&amp;quot; );&lt;br /&gt;
         if( $ssl-&amp;gt;code() )&lt;br /&gt;
         {&lt;br /&gt;
                 print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
                 return 0;&lt;br /&gt;
        }&lt;br /&gt;
 # Check password&lt;br /&gt;
        my $mesg = $ldap-&amp;gt;bind( $ldap_dn, password =&amp;gt; $password );&lt;br /&gt;
        if( $mesg-&amp;gt;code() )&lt;br /&gt;
        {&lt;br /&gt;
                return 0;&lt;br /&gt;
        }&lt;br /&gt;
        return 1;&lt;br /&gt;
 }&lt;br /&gt;
 # Advanced LDAP Configuration&lt;br /&gt;
 #&lt;br /&gt;
 # 1. It is also possible to define additional user types, each with a different&lt;br /&gt;
 # authentication mechanism. For example, you could keep the default user, &lt;br /&gt;
 # editor and admin types and add ldapuser, ldapeditor and ldapadmin types with&lt;br /&gt;
 # LDAP authentication - this would suit an arrangement where internal staff are &lt;br /&gt;
 # authenticated against the LDAP server but user accounts can still be granted &lt;br /&gt;
 # to external users.&lt;br /&gt;
 #&lt;br /&gt;
 # 2. Sometimes the distinguished name of the user is not computable from the &lt;br /&gt;
 # username. You may need to use values from the user metadata (e.g. name_given,&lt;br /&gt;
 # name_family):&lt;br /&gt;
 #&lt;br /&gt;
 #       my $name = $user-&amp;gt;get_value( &amp;quot;name&amp;quot; );&lt;br /&gt;
 #       my $ldap_dn = $name-&amp;gt;{family} . &amp;quot;, &amp;quot; . $name-&amp;gt;{given} .&amp;quot;, ou=yourorg, dc=yourdomain&amp;quot;;&lt;br /&gt;
 #&lt;br /&gt;
 # or perform an LDAP lookup to determine it (more complicated):&lt;br /&gt;
 #&lt;br /&gt;
 #       my $base = &amp;quot;ou=yourorg, dc=yourdomain&amp;quot;;&lt;br /&gt;
 #       my $result = $ldap-&amp;gt;search (&lt;br /&gt;
 #               base    =&amp;gt; &amp;quot;$base&amp;quot;,&lt;br /&gt;
 #               scope   =&amp;gt; &amp;quot;sub&amp;quot;,&lt;br /&gt;
 #               filter  =&amp;gt; &amp;quot;cn=$username&amp;quot;,&lt;br /&gt;
 #               attrs   =&amp;gt;  [&#039;DN&#039;],&lt;br /&gt;
 #               sizelimit=&amp;gt;1&lt;br /&gt;
 #       );&lt;br /&gt;
 #&lt;br /&gt;
 #       my $entr = $result-&amp;gt;pop_entry;&lt;br /&gt;
 #       unless( defined $entr )&lt;br /&gt;
 #       {&lt;br /&gt;
 #               return 0;&lt;br /&gt;
 #       }&lt;br /&gt;
 #       my $ldap_dn = $entr-&amp;gt;dn&lt;br /&gt;
 #&lt;br /&gt;
 # Alternatively, you could store the distinguished name as part of the user &lt;br /&gt;
 # metadata when the user account is imported              print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
After editing restart Apache.&lt;br /&gt;
&lt;br /&gt;
==LDAP and User Roles==&lt;br /&gt;
&lt;br /&gt;
It is recommended that certain user rights are removed when using LDAP for login. The user should not be allowed to change their password or their email address. It is also suggested that the user not be allowed to edit their profile, however I have found certain fields that I would like the user to edit. To set the rights edit the file : &lt;br /&gt;
&lt;br /&gt;
 vi /var/lib/eprints3/archives/yourarchivename/cfg/cfg.d/user_roles.pl&lt;br /&gt;
&lt;br /&gt;
 ######################################################################&lt;br /&gt;
 #&lt;br /&gt;
 # User Roles&lt;br /&gt;
 #&lt;br /&gt;
 #  Here you can configure which different types of user are &lt;br /&gt;
 #  parts of the system they are allowed to use.&lt;br /&gt;
 #&lt;br /&gt;
 ######################################################################&lt;br /&gt;
 $c-&amp;gt;{user_roles}-&amp;gt;{user} = [qw/&lt;br /&gt;
        general&lt;br /&gt;
        edit-own-record&lt;br /&gt;
        saved-searches&lt;br /&gt;
        deposit&lt;br /&gt;
 /],&lt;br /&gt;
 $c-&amp;gt;{user_roles}-&amp;gt;{editor} = [qw/&lt;br /&gt;
        general&lt;br /&gt;
        edit-own-record&lt;br /&gt;
        saved-searches&lt;br /&gt;
        deposit&lt;br /&gt;
        editor&lt;br /&gt;
        view-status&lt;br /&gt;
        staff-view&lt;br /&gt;
 /],&lt;br /&gt;
 $c-&amp;gt;{user_roles}-&amp;gt;{admin} = [qw/&lt;br /&gt;
        general&lt;br /&gt;
        edit-own-record&lt;br /&gt;
        saved-searches&lt;br /&gt;
        set-password&lt;br /&gt;
        deposit&lt;br /&gt;
        change-email&lt;br /&gt;
        editor&lt;br /&gt;
        view-status&lt;br /&gt;
        staff-view&lt;br /&gt;
        admin&lt;br /&gt;
 /],&lt;br /&gt;
 #$c-&amp;gt;{user_roles}-&amp;gt;{minuser} = [qw/&lt;br /&gt;
 #       saved-searches&lt;br /&gt;
 #       set-password&lt;br /&gt;
 #       change-email&lt;br /&gt;
 #       change-user&lt;br /&gt;
 #       no_edit_own_record&lt;br /&gt;
 #       lock-username-to-email&lt;br /&gt;
 #/];&lt;br /&gt;
&lt;br /&gt;
After editing restart Apache.&lt;br /&gt;
&lt;br /&gt;
==LDAP Import==&lt;br /&gt;
&lt;br /&gt;
[[LDAP_user_login.pl]] automagically creates eprints accounts on demand (i.e. after login), but you could also just use the [http://files.eprints.org/27/1/update_users update_users script] and apply the following patch to make it work with eprints3:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- update_users.orig   2007-04-23 16:22:26.000000000 +0200&lt;br /&gt;
+++ update_users    2007-04-24 21:16:40.000000000 +0200&lt;br /&gt;
@@ -1,6 +1,6 @@&lt;br /&gt;
-#!/usr/bin/perl -w -I/opt/eprints2/perl_lib&lt;br /&gt;
+#!/usr/bin/perl -w -I/opt/eprints3/perl_lib&lt;br /&gt;
&lt;br /&gt;
-use EPrints::User;&lt;br /&gt;
+use EPrints::DataObj::User;&lt;br /&gt;
 use EPrints::Session;&lt;br /&gt;
 use Net::LDAP;&lt;br /&gt;
 use strict;&lt;br /&gt;
@@ -16,6 +16,7 @@&lt;br /&gt;
&lt;br /&gt;
 # Start connection&lt;br /&gt;
 my $ldap = Net::LDAP-&amp;gt;new( &amp;quot;ldap.host.name&amp;quot;, version =&amp;gt; 3 );&lt;br /&gt;
+$ldap-&amp;gt;start_tls();&lt;br /&gt;
 unless( $ldap )&lt;br /&gt;
 {&lt;br /&gt;
    print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
@@ -74,7 +75,7 @@&lt;br /&gt;
        # New account&lt;br /&gt;
        if( $forreal )&lt;br /&gt;
        {&lt;br /&gt;
-           $user = EPrints::User::create_user( $session, &amp;quot;ldapuser&amp;quot; );&lt;br /&gt;
+           $user = EPrints::DataObj::User::create( $session, &amp;quot;user&amp;quot; );&lt;br /&gt;
            $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
            print &amp;quot;CREATING: $username\n&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
@@ -118,7 +119,7 @@&lt;br /&gt;
        print &amp;quot;FAMILY = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;sn&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        print &amp;quot;GIVEN = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;givenName&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        print &amp;quot;EMAIL = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;mail&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
-       print &amp;quot;DN = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;distinguishedName&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
+       print &amp;quot;DN = &amp;quot; . $entr-&amp;gt;dn . &amp;quot;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP_user_login.pl&amp;diff=4268</id>
		<title>LDAP user login.pl</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP_user_login.pl&amp;diff=4268"/>
		<updated>2007-04-24T19:18:54Z</updated>

		<summary type="html">&lt;p&gt;Sp: https!&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== LDAP Authentication and Provisioning example ==&lt;br /&gt;
Here&#039;s an example of a customized &amp;lt;tt&amp;gt;/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/user_login.pl&amp;lt;/tt&amp;gt;&lt;br /&gt;
* allowing LDAP accounts to login, using the &amp;quot;Advanced LDAP Configuration&amp;quot; example&lt;br /&gt;
* allowing the local eprints admin account to login w/ database authentication&lt;br /&gt;
* creating eprints accounts for all successfully authenticated LDAP users &#039;&#039;on the fly&#039;&#039;&lt;br /&gt;
Most of the code is from the default &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; and from the [http://files.eprints.org/27/1/update_users update_users] script.&lt;br /&gt;
&lt;br /&gt;
Be sure to only use this over [[HTTPS]]!&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{check_user_password} = sub {&lt;br /&gt;
    my( $session, $username, $password ) = @_;&lt;br /&gt;
    &lt;br /&gt;
    # LDAP authentication for &amp;quot;user&amp;quot;, &amp;quot;editor&amp;quot; and &amp;quot;admin&amp;quot; types (roles)&lt;br /&gt;
    &lt;br /&gt;
    use Net::LDAP; # IO::Socket::SSL also required&lt;br /&gt;
    &lt;br /&gt;
    # LDAP tunables&lt;br /&gt;
    my $ldap_host = &amp;quot;ldap.example.org&amp;quot;;&lt;br /&gt;
    my $base      = &amp;quot;dc=example,dc=org&amp;quot;;&lt;br /&gt;
    my $dn        = &amp;quot;cn=someProxyAccount,ou=accounts,$base&amp;quot;;&lt;br /&gt;
    &lt;br /&gt;
    my $ldap      = Net::LDAP-&amp;gt;new ( $ldap_host, version =&amp;gt; 3 );&lt;br /&gt;
    unless( $ldap )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Start secure connection (not needed if using LDAPS)&lt;br /&gt;
    my $ssl = $ldap-&amp;gt;start_tls();&lt;br /&gt;
    if( $ssl-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Get password for the search-bind-account&lt;br /&gt;
    my $repository = $session-&amp;gt;get_repository;&lt;br /&gt;
    my $id         = $repository-&amp;gt;get_id;&lt;br /&gt;
    chomp($id);&lt;br /&gt;
    my $ldappass   = `cat /opt/eprints3/archives/$id/cfg/ldap.passwd`;&lt;br /&gt;
    chomp($ldappass);&lt;br /&gt;
    &lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $dn, password=&amp;gt;$password );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP Bind error: &amp;quot; . $mesg-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Distinguished name (and attribues needed later on) for this user&lt;br /&gt;
    my $result = $ldap-&amp;gt;search (&lt;br /&gt;
        base    =&amp;gt; &amp;quot;$base&amp;quot;,&lt;br /&gt;
        scope   =&amp;gt; &amp;quot;sub&amp;quot;,&lt;br /&gt;
        filter  =&amp;gt; &amp;quot;(&amp;amp;(uid=$username)(objectclass=inetOrgPerson))&amp;quot;,&lt;br /&gt;
        attrs   =&amp;gt;  [&#039;1.1&#039;, &#039;uid&#039;, &#039;sn&#039;, &#039;givenname&#039;, &#039;mail&#039;],&lt;br /&gt;
        sizelimit=&amp;gt;1&lt;br /&gt;
    );&lt;br /&gt;
    my $entr = $result-&amp;gt;pop_entry;&lt;br /&gt;
    unless( defined $entr )&lt;br /&gt;
    {&lt;br /&gt;
        # Allow local EPrints authentication for admins (accounts not found in LDAP)&lt;br /&gt;
        my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
        return 0 unless $user;&lt;br /&gt;
        &lt;br /&gt;
        my $user_type = $user-&amp;gt;get_type;&lt;br /&gt;
        if( $user_type eq &amp;quot;admin&amp;quot; )&lt;br /&gt;
        {&lt;br /&gt;
            # internal authentication for &amp;quot;admin&amp;quot; type&lt;br /&gt;
            return $session-&amp;gt;get_database-&amp;gt;valid_login( $username, $password );&lt;br /&gt;
        }&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    my $ldap_dn = $entr-&amp;gt;dn;&lt;br /&gt;
    &lt;br /&gt;
    # Check password&lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $ldap_dn, password =&amp;gt; $password );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Does account already exist?&lt;br /&gt;
    my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
    if( !defined $user )&lt;br /&gt;
    {&lt;br /&gt;
        # New account&lt;br /&gt;
        $user = EPrints::DataObj::User::create( $session, &amp;quot;user&amp;quot; );&lt;br /&gt;
        $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Set metadata&lt;br /&gt;
    my $name = {};&lt;br /&gt;
    $name-&amp;gt;{family} = $entr-&amp;gt;get_value( &amp;quot;sn&amp;quot; );&lt;br /&gt;
    $name-&amp;gt;{given} = $entr-&amp;gt;get_value( &amp;quot;givenName&amp;quot; );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;name&amp;quot;, $name );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;email&amp;quot;, $entr-&amp;gt;get_value( &amp;quot;mail&amp;quot; ) );&lt;br /&gt;
    $user-&amp;gt;commit();&lt;br /&gt;
    &lt;br /&gt;
    $ldap-&amp;gt;unbind if $ldap;&lt;br /&gt;
    &lt;br /&gt;
    return 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== things to note ==&lt;br /&gt;
* This script uses a dedicated proxy account which must exist in your LDAP tree and has appropriate permissions (ACL settings) to search for users and read their &amp;lt;tt&amp;gt;uid,givenname,sn,mail&amp;lt;/tt&amp;gt; attributes.&lt;br /&gt;
* It get&#039;s this proxy accounts&#039; password from a file inside the repository configuration. this file needs to have read permissions for the user your webserver runs as (e.g. &amp;lt;tt&amp;gt;www-data&amp;lt;/tt&amp;gt; on Debian).  Use file system permissions to protect this (e.g. &amp;lt;tt&amp;gt;chmod 400 ldap.passwd&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* It changes the flow of &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; a little to only check for local &#039;&#039;admin&#039;&#039; accounts (no users or editors; we have them all in our LDAP tree) and only when no user is found for ldap authentication. This allows you to have your admins in LDAP (if you want) but still use the local admin for &amp;quot;promoting&amp;quot; other users to admins, among other things. If you don&#039;t need the local admin, remove those lines and just &amp;lt;tt&amp;gt;return 0&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* you could change the default role for generated user accounts from &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt;, if you really wanted.&lt;br /&gt;
&lt;br /&gt;
== possible enhancements ==&lt;br /&gt;
* Currently this script does not remove local eprints accounts from the database. If you limited login to EPrints with an LDAP attribute (e.g. &amp;lt;tt&amp;gt;allowedServices=eprints&amp;lt;/tt&amp;gt;) you could authenticate first (without filtering for this attribute) and in the case of successful authentication check for the existance of the &amp;lt;tt&amp;gt;allowedServices&amp;lt;/tt&amp;gt; attribute. If it&#039;s missing delete the local eprints user account (e.g. &amp;lt;tt&amp;gt;$user-&amp;gt;remove&amp;lt;/tt&amp;gt;) and &amp;lt;tt&amp;gt;return 0&amp;lt;/tt&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP&amp;diff=4266</id>
		<title>LDAP</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP&amp;diff=4266"/>
		<updated>2007-04-24T19:14:51Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* LDAP Import */ patching update_users for eprints3&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See [[Integrating EPrints with LDAP]] for instructions for Eprints 2.*&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
I am hoping that someone will add to this document regarding the importing of users. I decided that importing all users from my LDAP repository was not a good idea, I run Samba and an import would mean setting up 75 computers with access to eprints. I now create each user that requires access and use LDAP for authentication. This means that my users still only need to remember one password.&lt;br /&gt;
&lt;br /&gt;
The recommendation for Eprints is not to allow users to alter email and passwords, as these changes are not at present written back to the LDAP database.&lt;br /&gt;
&lt;br /&gt;
==LDAP Configuration==&lt;br /&gt;
&lt;br /&gt;
All changes for LDAP authentication can be made in a single file, the file contains useful notes on configuration. Here is an example from my site, I have configured a standard Samba Domain using LDAP for authentication, if you have similar then this config may work for you :&lt;br /&gt;
&lt;br /&gt;
Edit the file :&lt;br /&gt;
&lt;br /&gt;
 vi /var/lib/eprints3/archives/yourarchivename/cfg/cfg.d/user_login.pl&lt;br /&gt;
&lt;br /&gt;
 # This function allows you to override the default username/password&lt;br /&gt;
 # authentication. For example, you could apply different authentication rules to &lt;br /&gt;
 # different types of user.&lt;br /&gt;
 #&lt;br /&gt;
 # Example: LDAP Authentication (Quick Start)&lt;br /&gt;
 #&lt;br /&gt;
 # Tip: use the test script to determine your LDAP parameters first!&lt;br /&gt;
 # Tip: remove the set-password priviledge from users and editors in&lt;br /&gt;
 # user_roles.pl. Also consider removing edit-own-record and &lt;br /&gt;
 # change-email.&lt;br /&gt;
 #&lt;br /&gt;
 $c-&amp;gt;{check_user_password} = sub {&lt;br /&gt;
         my( $session, $username, $password ) = @_;&lt;br /&gt;
         my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
         return 0 unless $user;&lt;br /&gt;
         my $user_type = $user-&amp;gt;get_type;&lt;br /&gt;
         if( $user_type eq &amp;quot;admin&amp;quot; )&lt;br /&gt;
        {&lt;br /&gt;
        #       internal authentication for &amp;quot;admin&amp;quot; type&lt;br /&gt;
        #       return EPrints::Apache::Login::valid_login( $session, $username, $password );&lt;br /&gt;
        return $session-&amp;gt;get_database-&amp;gt;valid_login( $username, $password );&lt;br /&gt;
        }&lt;br /&gt;
 # LDAP authentication for &amp;quot;user&amp;quot; and &amp;quot;editor&amp;quot; types&lt;br /&gt;
 #&lt;br /&gt;
 # LDAP hostname (and port if not the default)&lt;br /&gt;
        my $ldap_host = &amp;quot;ldap.yourdomain.ac.uk&amp;quot;;&lt;br /&gt;
 #       #my $ldap_host = &amp;quot;ldap.host.name:1234&amp;quot;;&lt;br /&gt;
 #       #my $ldap_host = &amp;quot;ldaps://ldap.host.name&amp;quot;; # if server supports LDAPS&lt;br /&gt;
 #&lt;br /&gt;
 # Distinguished name for this user&lt;br /&gt;
 # The distinguished name is a unique name for an LDAP entry.&lt;br /&gt;
 # e.g. &amp;quot;cn=John Smith, ou=staff, dc=eprints, dc=org&amp;quot;&lt;br /&gt;
 # You will need to derive this from the username or user metadata&lt;br /&gt;
         my $ldap_dn = &amp;quot;uid=$username,ou=People,dc=yourdomain,dc=ac,dc=uk&amp;quot;;&lt;br /&gt;
 #&lt;br /&gt;
         use Net::LDAP; # IO::Socket::SSL also required&lt;br /&gt;
 #&lt;br /&gt;
         my $ldap = Net::LDAP-&amp;gt;new ( $ldap_host, version =&amp;gt; 3 );&lt;br /&gt;
         unless( $ldap )&lt;br /&gt;
         {&lt;br /&gt;
                 print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
                 return 0;&lt;br /&gt;
         }&lt;br /&gt;
 #&lt;br /&gt;
 # Start secure connection (not needed if using LDAPS)&lt;br /&gt;
         my $ssl = $ldap-&amp;gt;start_tls( sslversion =&amp;gt; &amp;quot;sslv3&amp;quot; );&lt;br /&gt;
         if( $ssl-&amp;gt;code() )&lt;br /&gt;
         {&lt;br /&gt;
                 print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
                 return 0;&lt;br /&gt;
        }&lt;br /&gt;
 # Check password&lt;br /&gt;
        my $mesg = $ldap-&amp;gt;bind( $ldap_dn, password =&amp;gt; $password );&lt;br /&gt;
        if( $mesg-&amp;gt;code() )&lt;br /&gt;
        {&lt;br /&gt;
                return 0;&lt;br /&gt;
        }&lt;br /&gt;
        return 1;&lt;br /&gt;
 }&lt;br /&gt;
 # Advanced LDAP Configuration&lt;br /&gt;
 #&lt;br /&gt;
 # 1. It is also possible to define additional user types, each with a different&lt;br /&gt;
 # authentication mechanism. For example, you could keep the default user, &lt;br /&gt;
 # editor and admin types and add ldapuser, ldapeditor and ldapadmin types with&lt;br /&gt;
 # LDAP authentication - this would suit an arrangement where internal staff are &lt;br /&gt;
 # authenticated against the LDAP server but user accounts can still be granted &lt;br /&gt;
 # to external users.&lt;br /&gt;
 #&lt;br /&gt;
 # 2. Sometimes the distinguished name of the user is not computable from the &lt;br /&gt;
 # username. You may need to use values from the user metadata (e.g. name_given,&lt;br /&gt;
 # name_family):&lt;br /&gt;
 #&lt;br /&gt;
 #       my $name = $user-&amp;gt;get_value( &amp;quot;name&amp;quot; );&lt;br /&gt;
 #       my $ldap_dn = $name-&amp;gt;{family} . &amp;quot;, &amp;quot; . $name-&amp;gt;{given} .&amp;quot;, ou=yourorg, dc=yourdomain&amp;quot;;&lt;br /&gt;
 #&lt;br /&gt;
 # or perform an LDAP lookup to determine it (more complicated):&lt;br /&gt;
 #&lt;br /&gt;
 #       my $base = &amp;quot;ou=yourorg, dc=yourdomain&amp;quot;;&lt;br /&gt;
 #       my $result = $ldap-&amp;gt;search (&lt;br /&gt;
 #               base    =&amp;gt; &amp;quot;$base&amp;quot;,&lt;br /&gt;
 #               scope   =&amp;gt; &amp;quot;sub&amp;quot;,&lt;br /&gt;
 #               filter  =&amp;gt; &amp;quot;cn=$username&amp;quot;,&lt;br /&gt;
 #               attrs   =&amp;gt;  [&#039;DN&#039;],&lt;br /&gt;
 #               sizelimit=&amp;gt;1&lt;br /&gt;
 #       );&lt;br /&gt;
 #&lt;br /&gt;
 #       my $entr = $result-&amp;gt;pop_entry;&lt;br /&gt;
 #       unless( defined $entr )&lt;br /&gt;
 #       {&lt;br /&gt;
 #               return 0;&lt;br /&gt;
 #       }&lt;br /&gt;
 #       my $ldap_dn = $entr-&amp;gt;dn&lt;br /&gt;
 #&lt;br /&gt;
 # Alternatively, you could store the distinguished name as part of the user &lt;br /&gt;
 # metadata when the user account is imported              print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
After editing restart Apache.&lt;br /&gt;
&lt;br /&gt;
==LDAP and User Roles==&lt;br /&gt;
&lt;br /&gt;
It is recommended that certain user rights are removed when using LDAP for login. The user should not be allowed to change their password or their email address. It is also suggested that the user not be allowed to edit their profile, however I have found certain fields that I would like the user to edit. To set the rights edit the file : &lt;br /&gt;
&lt;br /&gt;
 vi /var/lib/eprints3/archives/yourarchivename/cfg/cfg.d/user_roles.pl&lt;br /&gt;
&lt;br /&gt;
 ######################################################################&lt;br /&gt;
 #&lt;br /&gt;
 # User Roles&lt;br /&gt;
 #&lt;br /&gt;
 #  Here you can configure which different types of user are &lt;br /&gt;
 #  parts of the system they are allowed to use.&lt;br /&gt;
 #&lt;br /&gt;
 ######################################################################&lt;br /&gt;
 $c-&amp;gt;{user_roles}-&amp;gt;{user} = [qw/&lt;br /&gt;
        general&lt;br /&gt;
        edit-own-record&lt;br /&gt;
        saved-searches&lt;br /&gt;
        deposit&lt;br /&gt;
 /],&lt;br /&gt;
 $c-&amp;gt;{user_roles}-&amp;gt;{editor} = [qw/&lt;br /&gt;
        general&lt;br /&gt;
        edit-own-record&lt;br /&gt;
        saved-searches&lt;br /&gt;
        deposit&lt;br /&gt;
        editor&lt;br /&gt;
        view-status&lt;br /&gt;
        staff-view&lt;br /&gt;
 /],&lt;br /&gt;
 $c-&amp;gt;{user_roles}-&amp;gt;{admin} = [qw/&lt;br /&gt;
        general&lt;br /&gt;
        edit-own-record&lt;br /&gt;
        saved-searches&lt;br /&gt;
        set-password&lt;br /&gt;
        deposit&lt;br /&gt;
        change-email&lt;br /&gt;
        editor&lt;br /&gt;
        view-status&lt;br /&gt;
        staff-view&lt;br /&gt;
        admin&lt;br /&gt;
 /],&lt;br /&gt;
 #$c-&amp;gt;{user_roles}-&amp;gt;{minuser} = [qw/&lt;br /&gt;
 #       saved-searches&lt;br /&gt;
 #       set-password&lt;br /&gt;
 #       change-email&lt;br /&gt;
 #       change-user&lt;br /&gt;
 #       no_edit_own_record&lt;br /&gt;
 #       lock-username-to-email&lt;br /&gt;
 #/];&lt;br /&gt;
&lt;br /&gt;
After editing restart Apache.&lt;br /&gt;
&lt;br /&gt;
==LDAP Import==&lt;br /&gt;
&lt;br /&gt;
[[LDAP_user_login.pl]] automagically creates eprints accounts on demand (i.e. after login), but you could also just use the [http://files.eprints.org/27/1/update_users update_users script] and apply the following patch to make it work with eprints3:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- update_users.orig   2007-04-23 16:22:26.000000000 +0200&lt;br /&gt;
+++ update_users    2007-04-24 21:16:40.000000000 +0200&lt;br /&gt;
@@ -1,6 +1,6 @@&lt;br /&gt;
-#!/usr/bin/perl -w -I/opt/eprints2/perl_lib&lt;br /&gt;
+#!/usr/bin/perl -w -I/opt/eprints3/perl_lib&lt;br /&gt;
&lt;br /&gt;
-use EPrints::User;&lt;br /&gt;
+use EPrints::DataObj::User;&lt;br /&gt;
 use EPrints::Session;&lt;br /&gt;
 use Net::LDAP;&lt;br /&gt;
 use strict;&lt;br /&gt;
@@ -16,6 +16,7 @@&lt;br /&gt;
&lt;br /&gt;
 # Start connection&lt;br /&gt;
 my $ldap = Net::LDAP-&amp;gt;new( &amp;quot;ldap.host.name&amp;quot;, version =&amp;gt; 3 );&lt;br /&gt;
+$ldap-&amp;gt;start_tls();&lt;br /&gt;
 unless( $ldap )&lt;br /&gt;
 {&lt;br /&gt;
    print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
@@ -74,7 +75,7 @@&lt;br /&gt;
        # New account&lt;br /&gt;
        if( $forreal )&lt;br /&gt;
        {&lt;br /&gt;
-           $user = EPrints::User::create_user( $session, &amp;quot;ldapuser&amp;quot; );&lt;br /&gt;
+           $user = EPrints::DataObj::User::create( $session, &amp;quot;user&amp;quot; );&lt;br /&gt;
            $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
            print &amp;quot;CREATING: $username\n&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
@@ -118,7 +119,7 @@&lt;br /&gt;
        print &amp;quot;FAMILY = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;sn&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        print &amp;quot;GIVEN = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;givenName&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        print &amp;quot;EMAIL = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;mail&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
-       print &amp;quot;DN = &amp;quot; . $entr-&amp;gt;get_value( &amp;quot;distinguishedName&amp;quot; ) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
+       print &amp;quot;DN = &amp;quot; . $entr-&amp;gt;dn . &amp;quot;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP_user_login.pl&amp;diff=4265</id>
		<title>LDAP user login.pl</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=LDAP_user_login.pl&amp;diff=4265"/>
		<updated>2007-04-24T19:06:25Z</updated>

		<summary type="html">&lt;p&gt;Sp: example from vienna university&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== LDAP Authentication and Provisioning example ==&lt;br /&gt;
Here&#039;s an example of a customized &amp;lt;tt&amp;gt;/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/user_login.pl&amp;lt;/tt&amp;gt;&lt;br /&gt;
* allowing LDAP accounts to login, using the &amp;quot;Advanced LDAP Configuration&amp;quot; example&lt;br /&gt;
* allowing the local eprints admin account to login w/ database authentication&lt;br /&gt;
* creating eprints accounts for all successfully authenticated LDAP users &#039;&#039;on the fly&#039;&#039;&lt;br /&gt;
Most of the code is from the default &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; and from the [http://files.eprints.org/27/1/update_users update_users] script.&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{check_user_password} = sub {&lt;br /&gt;
    my( $session, $username, $password ) = @_;&lt;br /&gt;
    &lt;br /&gt;
    # LDAP authentication for &amp;quot;user&amp;quot;, &amp;quot;editor&amp;quot; and &amp;quot;admin&amp;quot; types (roles)&lt;br /&gt;
    &lt;br /&gt;
    use Net::LDAP; # IO::Socket::SSL also required&lt;br /&gt;
    &lt;br /&gt;
    # LDAP tunables&lt;br /&gt;
    my $ldap_host = &amp;quot;ldap.example.org&amp;quot;;&lt;br /&gt;
    my $base      = &amp;quot;dc=example,dc=org&amp;quot;;&lt;br /&gt;
    my $dn        = &amp;quot;cn=someProxyAccount,ou=accounts,$base&amp;quot;;&lt;br /&gt;
    &lt;br /&gt;
    my $ldap      = Net::LDAP-&amp;gt;new ( $ldap_host, version =&amp;gt; 3 );&lt;br /&gt;
    unless( $ldap )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP error: $@\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Start secure connection (not needed if using LDAPS)&lt;br /&gt;
    my $ssl = $ldap-&amp;gt;start_tls();&lt;br /&gt;
    if( $ssl-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP SSL error: &amp;quot; . $ssl-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Get password for the search-bind-account&lt;br /&gt;
    my $repository = $session-&amp;gt;get_repository;&lt;br /&gt;
    my $id         = $repository-&amp;gt;get_id;&lt;br /&gt;
    chomp($id);&lt;br /&gt;
    my $ldappass   = `cat /opt/eprints3/archives/$id/cfg/ldap.passwd`;&lt;br /&gt;
    chomp($ldappass);&lt;br /&gt;
    &lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $dn, password=&amp;gt;$password );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        print STDERR &amp;quot;LDAP Bind error: &amp;quot; . $mesg-&amp;gt;error() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Distinguished name (and attribues needed later on) for this user&lt;br /&gt;
    my $result = $ldap-&amp;gt;search (&lt;br /&gt;
        base    =&amp;gt; &amp;quot;$base&amp;quot;,&lt;br /&gt;
        scope   =&amp;gt; &amp;quot;sub&amp;quot;,&lt;br /&gt;
        filter  =&amp;gt; &amp;quot;(&amp;amp;(uid=$username)(objectclass=inetOrgPerson))&amp;quot;,&lt;br /&gt;
        attrs   =&amp;gt;  [&#039;1.1&#039;, &#039;uid&#039;, &#039;sn&#039;, &#039;givenname&#039;, &#039;mail&#039;],&lt;br /&gt;
        sizelimit=&amp;gt;1&lt;br /&gt;
    );&lt;br /&gt;
    my $entr = $result-&amp;gt;pop_entry;&lt;br /&gt;
    unless( defined $entr )&lt;br /&gt;
    {&lt;br /&gt;
        # Allow local EPrints authentication for admins (accounts not found in LDAP)&lt;br /&gt;
        my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
        return 0 unless $user;&lt;br /&gt;
        &lt;br /&gt;
        my $user_type = $user-&amp;gt;get_type;&lt;br /&gt;
        if( $user_type eq &amp;quot;admin&amp;quot; )&lt;br /&gt;
        {&lt;br /&gt;
            # internal authentication for &amp;quot;admin&amp;quot; type&lt;br /&gt;
            return $session-&amp;gt;get_database-&amp;gt;valid_login( $username, $password );&lt;br /&gt;
        }&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    my $ldap_dn = $entr-&amp;gt;dn;&lt;br /&gt;
    &lt;br /&gt;
    # Check password&lt;br /&gt;
    my $mesg = $ldap-&amp;gt;bind( $ldap_dn, password =&amp;gt; $password );&lt;br /&gt;
    if( $mesg-&amp;gt;code() )&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Does account already exist?&lt;br /&gt;
    my $user = EPrints::DataObj::User::user_with_username( $session, $username );&lt;br /&gt;
    if( !defined $user )&lt;br /&gt;
    {&lt;br /&gt;
        # New account&lt;br /&gt;
        $user = EPrints::DataObj::User::create( $session, &amp;quot;user&amp;quot; );&lt;br /&gt;
        $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # Set metadata&lt;br /&gt;
    my $name = {};&lt;br /&gt;
    $name-&amp;gt;{family} = $entr-&amp;gt;get_value( &amp;quot;sn&amp;quot; );&lt;br /&gt;
    $name-&amp;gt;{given} = $entr-&amp;gt;get_value( &amp;quot;givenName&amp;quot; );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;name&amp;quot;, $name );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;username&amp;quot;, $username );&lt;br /&gt;
    $user-&amp;gt;set_value( &amp;quot;email&amp;quot;, $entr-&amp;gt;get_value( &amp;quot;mail&amp;quot; ) );&lt;br /&gt;
    $user-&amp;gt;commit();&lt;br /&gt;
    &lt;br /&gt;
    $ldap-&amp;gt;unbind if $ldap;&lt;br /&gt;
    &lt;br /&gt;
    return 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== things to note ==&lt;br /&gt;
* This script uses a dedicated proxy account which must exist in your LDAP tree and has appropriate permissions (ACL settings) to search for users and read their &amp;lt;tt&amp;gt;uid,givenname,sn,mail&amp;lt;/tt&amp;gt; attributes.&lt;br /&gt;
* It get&#039;s this proxy accounts&#039; password from a file inside the repository configuration. this file needs to have read permissions for the user your webserver runs as (e.g. &amp;lt;tt&amp;gt;www-data&amp;lt;/tt&amp;gt; on Debian).  Use file system permissions to protect this (e.g. &amp;lt;tt&amp;gt;chmod 400 ldap.passwd&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* It changes the flow of &amp;lt;tt&amp;gt;user_login.pl&amp;lt;/tt&amp;gt; a little to only check for local &#039;&#039;admin&#039;&#039; accounts (no users or editors; we have them all in our LDAP tree) and only when no user is found for ldap authentication. This allows you to have your admins in LDAP (if you want) but still use the local admin for &amp;quot;promoting&amp;quot; other users to admins, among other things. If you don&#039;t need the local admin, remove those lines and just &amp;lt;tt&amp;gt;return 0&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* you could change the default role for generated user accounts from &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt;, if you really wanted.&lt;br /&gt;
&lt;br /&gt;
== possible enhancements ==&lt;br /&gt;
* Currently this script does not remove local eprints accounts from the database. If you limited login to EPrints with an LDAP attribute (e.g. &amp;lt;tt&amp;gt;allowedServices=eprints&amp;lt;/tt&amp;gt;) you could authenticate first (without filtering for this attribute) and in the case of successful authentication check for the existance of the &amp;lt;tt&amp;gt;allowedServices&amp;lt;/tt&amp;gt; attribute. If it&#039;s missing delete the local eprints user account (e.g. &amp;lt;tt&amp;gt;$user-&amp;gt;remove&amp;lt;/tt&amp;gt;) and &amp;lt;tt&amp;gt;return 0&amp;lt;/tt&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Installing_GDOME&amp;diff=4257</id>
		<title>Installing GDOME</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Installing_GDOME&amp;diff=4257"/>
		<updated>2007-04-12T18:46:42Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{manual}}&lt;br /&gt;
&lt;br /&gt;
Since EPrints 2.2 you may use either XML::DOM or XML::GDOME. XML::GDOME is recommended as it&#039;s faster and uses much less RAM, but it does require you to install a whole lot of extra libraries and perl modules. If you are running a pilot or demonstration service then XML::DOM is fine, and you can always switch over later by installing the required tools and setting the GDOME flag in perl_lib/EPrints/SystemSettings.pm&lt;br /&gt;
&lt;br /&gt;
===Addional Libraries Required for GDOME support===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 libxml2&lt;br /&gt;
 libxml2-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
either get the tarball from: ftp://ftp.gnome.org/pub/GNOME/sources/libxml2/&lt;br /&gt;
&lt;br /&gt;
or the RPMs (but we have had problems with complex RPM dependencies):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 http://rpmfind.net/linux/rpm2html/search.php?query=libxml2&lt;br /&gt;
 http://rpmfind.net/linux/rpm2html/search.php?query=libxml2-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
===The GDOME Library===&lt;br /&gt;
Obtain this from&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 http://gdome2.cs.unibo.it/#downloads&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
You may either use the RPMs (gdome2 and gdome2-devel) or the tarball.&lt;br /&gt;
&lt;br /&gt;
===Additional Perl Modules Required for GDOME support===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 XML-LibXML-Common&lt;br /&gt;
 XML-NamespaceSupport&lt;br /&gt;
 XML-GDOME&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
All of which are in http://www.cpan.org/modules/by-module/XML/&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
&lt;br /&gt;
*[[Installing GDOME on Redhat 7]]&lt;br /&gt;
*[[Installing GDOME on Fedora Core 3]]&lt;br /&gt;
*[[Installing GDOME on Debian]]&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=User:Sp&amp;diff=3968</id>
		<title>User:Sp</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=User:Sp&amp;diff=3968"/>
		<updated>2007-02-14T18:08:40Z</updated>

		<summary type="html">&lt;p&gt;Sp: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Peter Schober, UNIX Sysadmin&amp;lt;br&amp;gt;&lt;br /&gt;
University of Vienna, Austria&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Autocompletion&amp;diff=3959</id>
		<title>Autocompletion</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Autocompletion&amp;diff=3959"/>
		<updated>2007-02-13T23:53:07Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* The autocompletion instructions */ typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{reference}}&lt;br /&gt;
&lt;br /&gt;
For a how-to, please see [[Autocompletion and Authority Files (Romeo Autocomplete)]]&lt;br /&gt;
&lt;br /&gt;
Autocompletion in EPrints 3 consists of serveral stages.&lt;br /&gt;
&lt;br /&gt;
* A field in the workflow is configured to say what autocompletion URL to use, plus any additional parameters to pass to the script. This URL must be on the same server (eg. foo.eprints.org) but does not have to be part of the EPrints system. &lt;br /&gt;
* The autocomplete script takes the text typed so far (and maybe the additional parameters) and returns a chunk of XML describing possible autocomplete options. This XML consists of a number of rows (how many is up to the script). &lt;br /&gt;
* Each row contains some HTML to show the person viewing plus a magic &amp;lt;nowiki&amp;gt;&amp;lt;ul&amp;gt;&amp;lt;/nowiki&amp;gt; block which is hidden from display, but is used by the autocomplete javascript to autocomplete the page.&lt;br /&gt;
&lt;br /&gt;
== Autocomplete Scripts ==&lt;br /&gt;
&lt;br /&gt;
EPrints autocomplete scripts live in /opt/eprints3/cgi/users/lookup/ you can add your own here, or maybe elsewhere if, for example, you needed to use PHP.&lt;br /&gt;
&lt;br /&gt;
There are several kinds of autocomplete scripts:&lt;br /&gt;
* thoses that just use the existing data in your repository  (these are dead easy as they work out of the box)&lt;br /&gt;
* ones which use a file which you place in your repositories cfg/autocomplete/ directory.&lt;br /&gt;
* more clever ones.&lt;br /&gt;
&lt;br /&gt;
You may be able to find new autocomplete scripts and authority files on http://files.eprints.org/&lt;br /&gt;
&lt;br /&gt;
Scripts are in (rough) order of complexity to use...&lt;br /&gt;
&lt;br /&gt;
=== journal_by_name ===&lt;br /&gt;
&lt;br /&gt;
Can only be used on the &amp;quot;publication&amp;quot; field. Looks up the publication in the existing publications in the repository and autocompletes the publication. If ISSN and/or publisher exist in the same input component as the journal field they will also be completed if data is available.&lt;br /&gt;
&lt;br /&gt;
=== journal_by_issn ===&lt;br /&gt;
&lt;br /&gt;
As above, but attached to the ISSN field.&lt;br /&gt;
&lt;br /&gt;
=== event_by_name ===&lt;br /&gt;
&lt;br /&gt;
Similar to journal_by_name. Is attached to the event_title field and autocompletes from existing repository data. If they are in the same (multi) input component it will also try and autocomplete event_location, event_dates and event_type.&lt;br /&gt;
&lt;br /&gt;
=== name ===&lt;br /&gt;
&lt;br /&gt;
Attached to a multiple compound name/id field (eg. creators) looks up the name in the existing list in the repository. Can match on any id or given or family. Populates all parts of the current row it can. &lt;br /&gt;
&lt;br /&gt;
=== title_duplicates ===&lt;br /&gt;
&lt;br /&gt;
This is a slightly odd script as it doesn&#039;t actually provide any autocomplete data. What it does is search the list of existing titles to see if there is a match. It only searches if there are 5 or more characters entered so far.&lt;br /&gt;
&lt;br /&gt;
If it finds any matches it lists them with a warning that they might be a problem, but does not assist autocompletion. If many matches are made then a short title only is shown, if the list is only 4 or lest then a full citation is shown.&lt;br /&gt;
&lt;br /&gt;
This is set to &amp;quot;on&amp;quot; by default in the hope that it will reduce duplicate submissions.&lt;br /&gt;
&lt;br /&gt;
=== simple_file ===&lt;br /&gt;
&lt;br /&gt;
File needs an additional parameter to be passed to it. This is configured in the workflow. This parameter is the name of a file in the cfg/autocompete directory. This file contains a list of values which are searched (case insensitively) and matches returned. A second parameter of &amp;quot;mode=prefix&amp;quot; can be set to only match values which start with the text being typed, rather than contain it.&lt;br /&gt;
&lt;br /&gt;
=== simple_sql ===&lt;br /&gt;
&lt;br /&gt;
Similar to simple_file but gets its values from a database table.&lt;br /&gt;
&lt;br /&gt;
The table must be in the eprints database used by this repository and start with &amp;quot;ac_&amp;quot;. The script needs a param. passed from workflow to indicate the name of the table WITHOUT the ac_ prefix. Eg. if the table was &amp;quot;ac_badgers&amp;quot; the parameter would be &amp;quot;table=badgers&amp;quot;. The only field used is &amp;quot;value&amp;quot; which works like the lines in the text file. If you want this to be blindingly fast you can make sure &amp;quot;value&amp;quot; is indexed, and set mode=prefix. With those set autocompleting from a dictionary of half a million words worked cheerfully.&lt;br /&gt;
&lt;br /&gt;
=== romeo ===&lt;br /&gt;
&lt;br /&gt;
(not included in 3.0, expected in 3.1) This script uses the EPrints/Romeo data to provide journal autocomplete data. Should be attached to the publication field. This is almost identical to file, but inserts the required Powered by Sherpa note.&lt;br /&gt;
&lt;br /&gt;
=== url_name_value ===&lt;br /&gt;
&lt;br /&gt;
This works like simple_sql except for the fact it uses three columns. url, name and value. It searches and autocompletes using value, but the human-readable description is supplied by &amp;quot;name&amp;quot; and if url is set then a (more info) link is shown. The link opens a new window to avoid mid-form trauma.&lt;br /&gt;
&lt;br /&gt;
=== file ===&lt;br /&gt;
&lt;br /&gt;
This is for more complex autocompletion authority files. It works like simple_file except that the file format is more complicated.&lt;br /&gt;
&lt;br /&gt;
The file constists of lines which contan: &lt;br /&gt;
* a value to search, (eg. &amp;quot;African Journal of Agricultural Research&amp;quot;)&lt;br /&gt;
* a tab&lt;br /&gt;
* a &amp;lt;nowiki&amp;gt;&amp;lt;li&amp;gt;&amp;lt;/nowiki&amp;gt; autocomplete chunk. (with no line breaks) eg. &lt;br /&gt;
 &amp;lt;nowiki&amp;gt; &amp;lt;li style=&#039;border-right: solid 50px #30FF30&#039; &amp;gt;&amp;amp;quot;African Journal of Agricultural &lt;br /&gt;
 Research&amp;amp;quot; published by &amp;amp;quot;Academic Publishers&amp;amp;quot;&amp;lt;br /&amp;gt;&amp;lt;small&amp;gt;(a Green &lt;br /&gt;
 publisher)&amp;lt;/small&amp;gt;ISSN: 1991-637X&amp;lt;ul&amp;gt;&amp;lt;li id=&amp;quot;for:value:component:_publication&amp;quot;&amp;gt;African &lt;br /&gt;
 Journal of Agricultural Research&amp;lt;/li&amp;gt;&amp;lt;li id=&amp;quot;for:value:component:_publisher&amp;quot;&amp;gt;Academic &lt;br /&gt;
 Publishers&amp;lt;/li&amp;gt;&amp;lt;li id=&amp;quot;for:value:component:_issn&amp;quot;&amp;gt;1991-637X&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See below for more information on the meaning of this arcane chunk!&lt;br /&gt;
&lt;br /&gt;
=== sql ===&lt;br /&gt;
&lt;br /&gt;
As for simple_sql except that a second column named &amp;quot;xml&amp;quot; is used to provide the actual results returned (value is still searched).&lt;br /&gt;
&lt;br /&gt;
The xml column contains data in the autocomplete &amp;lt;nowiki&amp;gt;&amp;lt;li&amp;gt;&amp;lt;/nowiki&amp;gt; format described below.&lt;br /&gt;
&lt;br /&gt;
= Making a custom script =&lt;br /&gt;
&lt;br /&gt;
Autocompletion scripts are configured to eprint fields within the workflow. If the field is multiple then the same script is attached to each input row. &lt;br /&gt;
&lt;br /&gt;
The only parameter you need to look at is &amp;quot;q&amp;quot; which contains the text being autocompleted. For simple fields (eg. text), that is ones which only have one input-box per value. Not names, compound or pagerange etc.. the response should be of the format:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li class=&amp;quot;ep_first&amp;quot;&amp;gt;Human Friendly Text &amp;lt;ul&amp;gt;&amp;lt;li id=&#039;for:value:relative:&#039;&amp;gt;text-to-insert&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Human Friendly Text &amp;lt;ul&amp;gt;&amp;lt;li id=&#039;for:value:relative:&#039;&amp;gt;text-to-insert&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Human Friendly Text &amp;lt;ul&amp;gt;&amp;lt;li id=&#039;for:value:relative:&#039;&amp;gt;text-to-insert&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Human Friendly Text &amp;lt;ul&amp;gt;&amp;lt;li id=&#039;for:value:relative:&#039;&amp;gt;text-to-insert&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;li&amp;gt;&lt;br /&gt;
  etc.&lt;br /&gt;
 &amp;lt;/ul&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ep_first isn&#039;t really needed, but it makes the rendering look a little nicer.&lt;br /&gt;
&lt;br /&gt;
== Other useful CGI parameters ==&lt;br /&gt;
&lt;br /&gt;
All parts of the field (or field row in multiple fields) get sent as CGI parameters. The name of these parameters is the ID of the HTML input element itself, but with the relative prefix removed (phew!).&lt;br /&gt;
&lt;br /&gt;
Simple example: title field. One single value. It&#039;s not relevant, just use &amp;quot;q&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
More complex example: pagerange field. While you were typing in the &amp;quot;to&amp;quot; box (the second one). It would send &amp;quot;?q=45&amp;amp;_from=12&amp;amp;_to=45&amp;quot;. Obviously the numbers are made up. q= will always be the same as one of the values. &lt;br /&gt;
&lt;br /&gt;
Even more complex example: creators field. Which is a multiple compound field. Parts sent would be q, _id, _name_given and _name_family.&lt;br /&gt;
&lt;br /&gt;
For an explanation of how the id&#039;s are generated, and what a relative prefix is, see [[Understanding IDs in Workflow Forms]].&lt;br /&gt;
&lt;br /&gt;
== The autocompletion instructions ==&lt;br /&gt;
&lt;br /&gt;
The instructions for &#039;&#039;what&#039;&#039; to autocomplete if the row is selected is contained in the &amp;amp;lt;ul&amp;amp;gt; list inside the &amp;amp;lt;li&amp;amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Each item in the list is a single instruction.&lt;br /&gt;
&lt;br /&gt;
Each item in the list has an id attribute containing instructions on what to autocomplete. (yes that means repeated id values which is bad XML and we&#039;ll fix it in a later version...)&lt;br /&gt;
&lt;br /&gt;
The value inside the item describes what to insert, the id describes where and how.&lt;br /&gt;
&lt;br /&gt;
The id looks like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;quot;for:&amp;quot; + (&amp;quot;block&amp;quot; or &amp;quot;value&amp;quot;) + &amp;quot;:&amp;quot; + (&amp;quot;relative&amp;quot; or &amp;quot;component&amp;quot; or &amp;quot;absolute&amp;quot;) + &amp;quot;:&amp;quot; + freetext&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&lt;br /&gt;
 id=&amp;quot;for:value:relative:&amp;quot;&lt;br /&gt;
 id=&amp;quot;for:value:relative:_name_family&amp;quot;&lt;br /&gt;
 id=&amp;quot;for:value:component:_issn&amp;quot;&lt;br /&gt;
 id=&amp;quot;for:block:absolute:my_special_id&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;value&amp;quot; means insert the value into an &amp;amp;lt;input&amp;amp;gt; element (with the indicated id). &lt;br /&gt;
&lt;br /&gt;
&amp;quot;block&amp;quot; means replace the block with the indicated id.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;component&amp;quot; means that the freetext is the ID to modify, but missing the component prefix. For example &amp;quot;_issn&amp;quot; gives &amp;quot;id7_issn&amp;quot; (assuming id7 is the current component)&lt;br /&gt;
&lt;br /&gt;
&amp;quot;relative&amp;quot; means the freetext is the ID to modify but missing the row prefix. For example in a multiple text field (foo) using &amp;quot;&amp;quot; for the free text would give an id of something like &amp;quot;id3_foo_4&amp;quot;. For a single date field (birthday) a freetext of &amp;quot;_year&amp;quot; would give an id looking something like &amp;quot;id2_birthday_year&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;absolute&amp;quot; means that the freetext is the ID to modify. Absolute is a bit risky, as you can&#039;t rely on getting the same component prefix every time. It does, however, give you the chance to do Cool Stuff&amp;lt;sup&amp;gt;TM&amp;lt;/sup&amp;gt;. For example add a XHTML input compontent just containing: &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;div id=&amp;quot;special_comments&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt; and then make part of the autocomplete &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;li id=&amp;quot;for:block:absolute:special_comments&amp;quot;&amp;gt;&amp;lt;p&amp;gt;Hi Mom!&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt; (but something more relevant, obviously)&lt;br /&gt;
&lt;br /&gt;
=== How are these ID&#039;s generated anyway? ===&lt;br /&gt;
&lt;br /&gt;
See [[Understanding IDs in Workflow Forms]].&lt;br /&gt;
&lt;br /&gt;
=== What happens if the ID doesn&#039;t exist? ===&lt;br /&gt;
&lt;br /&gt;
Nothing, the autocompleter does not raise an error. It just autocompletes all the things it can. This is handy if the workflow changes slightly, but makes debugging a bit trickier.&lt;br /&gt;
&lt;br /&gt;
=== Some examples ===&lt;br /&gt;
&lt;br /&gt;
Please note these examples have line breaks in which is illegal in the &amp;quot;file&amp;quot; script files (but not in SQL or in custom scripts).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;lt;li style=&#039;border-right: solid 50px #30FF30&#039;&amp;gt;&lt;br /&gt;
  &amp;amp;quot;African Journal of Biotechnology&amp;amp;quot; published by &amp;amp;quot;Academic Publishers&amp;amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
  &amp;lt;small&amp;gt;(a Green publisher)&amp;lt;/small&amp;gt;ISSN: 1684-5315&lt;br /&gt;
  &amp;lt;ul&amp;gt;&lt;br /&gt;
    &amp;lt;li id=&amp;quot;for:value:component:_publication&amp;quot;&amp;gt;African Journal of Biotechnology&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li id=&amp;quot;for:value:component:_publisher&amp;quot;&amp;gt;Academic Publishers&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li id=&amp;quot;for:value:component:_issn&amp;quot;&amp;gt;1684-5315&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example autocompletes the issn, publication and publisher (text) fields in the current component.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;lt;li&amp;gt;&lt;br /&gt;
  B. Draut&lt;br /&gt;
  &amp;lt;small&amp;gt;(author of 3 items in this repository)&amp;lt;/small&amp;gt;&lt;br /&gt;
  &amp;lt;ul&amp;gt;&lt;br /&gt;
    &amp;lt;li id=&amp;quot;for:value:relative:_name_family&amp;quot;&amp;gt;Draut&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li id=&amp;quot;for:value:relative:_name_given&amp;quot;&amp;gt;B.&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li id=&amp;quot;for:value:relative:_name_honourific&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;li id=&amp;quot;for:value:relative:_name_lineage&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;li id=&amp;quot;for:value:relative:_id&amp;quot;&amp;gt;434533X&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This completes relative to the current row of a compound field the compound is a name field (called name) and a text field (called id). This is the config. for the creators and editors fields by default. Note that it tries to autocomplete the honourific field even though it doesn&#039;t exist and it&#039;s got no value to autocomplete. This means that if it happens to exist, this autocompletion will remove any text from the field.&lt;br /&gt;
&lt;br /&gt;
= Don&#039;t Forget to Share! =&lt;br /&gt;
&lt;br /&gt;
If you write a really useful autocomplete script, or a useful data file for &amp;quot;file&amp;quot; or &amp;quot;simple_file&amp;quot;, why not upload it to http://files.eprints.org/ so lots more people can benefit!&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3958</id>
		<title>Frequently Asked Questions</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3958"/>
		<updated>2007-02-13T23:43:08Z</updated>

		<summary type="html">&lt;p&gt;Sp: even more style...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This all needs sorting out, it&#039;s just being grabbed from the old wiki for now.&lt;br /&gt;
&lt;br /&gt;
* [[Copyright and License FAQ]]&lt;br /&gt;
* [[Metadata FAQ]]&lt;br /&gt;
* [[Searching FAQ]]&lt;br /&gt;
* [[OAI FAQ]]&lt;br /&gt;
* [[BOAI Self-Archiving FAQ]]&lt;br /&gt;
* [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== What operating systems can we use? ==&lt;br /&gt;
&lt;br /&gt;
EPrints should work on any UNIX operating system. We use Redhat Enterprise Linux. It will work on OSX but that takes a bit more effort. Please refer to the [http://www.eprints.org/documentation/handbook/osx.php Mac OS X Installation Guide] for more information&lt;br /&gt;
&lt;br /&gt;
It will not run under Microsoft Windows and we have no plan to change this.&lt;br /&gt;
&lt;br /&gt;
== What computer do we need? ==&lt;br /&gt;
&lt;br /&gt;
Any new PC is easily powerful enough. Suggested minimum spec. for a live service: 1gig RAM, 20gig Harddrive, 1GHz+ processor.&lt;br /&gt;
&lt;br /&gt;
== How much will it cost to set up? ==&lt;br /&gt;
&lt;br /&gt;
Most of the costs are staff time. Equipment costs are a PC, an internet connection and a BACKUP STRATEGY. Please remember to budget for backups.&lt;br /&gt;
&lt;br /&gt;
EPrints, and all the other software required to make it work, are available for no cost. At some point in the future EPrints may offer some pay-services, but the core software will remain zero cost and freely available to all.&lt;br /&gt;
&lt;br /&gt;
See [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== How much diskspace will we need? ==&lt;br /&gt;
&lt;br /&gt;
Proabably about 2 megabytes per eprint. At the time of writing a 120GB drive costs 50 pounds. That drive would hold approximately 60000 eprints.&lt;br /&gt;
&lt;br /&gt;
See also: [[Detailed disk usage statistics]].&lt;br /&gt;
 &lt;br /&gt;
== Is it possible when depositing a document, to just point to an &amp;quot;alternative location&amp;quot; rather than have the full text copied and held in the eprint archive? ==&lt;br /&gt;
&lt;br /&gt;
Yes, just don&#039;t assign any value to required_formats in ArchiveConfigure.pm, like so&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{required_formats} = [];&lt;br /&gt;
&lt;br /&gt;
If you are doing this it would also be clever to change the ArchiveRender routines so that on the abstract page &amp;quot;Full text available as&amp;quot; is replaced by &amp;quot;Full text available via &amp;lt;link to alternative location&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This keeps the key link to follow (to the full text) at the top of the screen.&lt;br /&gt;
&lt;br /&gt;
== I need to run apache as a user other than &amp;quot;eprints&amp;quot;, what do I do to make EPrints work in this situation? ==&lt;br /&gt;
&lt;br /&gt;
Example, apache is running as user &amp;quot;apache&amp;quot;.&lt;br /&gt;
* Make all the eprints files owned by &amp;quot;apache&amp;quot; instead of &amp;quot;eprints&amp;quot;&lt;br /&gt;
* Edit SystemSettings?.pm to tell eprints to run as user &amp;quot;apache&amp;quot;&lt;br /&gt;
* You&#039;ll need to run all command line scripts as user &amp;quot;apache&amp;quot;&lt;br /&gt;
* All eprints cron jobs should be owned by user &amp;quot;apache&amp;quot; &lt;br /&gt;
&lt;br /&gt;
If you are installing a new copy of eprints, you can specify the user and group to use when you run &#039;configure&#039;. Do&lt;br /&gt;
&lt;br /&gt;
 ./configure --help &lt;br /&gt;
&lt;br /&gt;
for details.&lt;br /&gt;
&lt;br /&gt;
== How do I get the body HTML of a page without the template around it? ==&lt;br /&gt;
&lt;br /&gt;
This is handy for dymnamically linking eprints content into other sites.&lt;br /&gt;
&lt;br /&gt;
For &amp;quot;view&amp;quot; pages you need to add the option include=&amp;gt;1 to the view configuration. This will cause generate_views to make a .include page in addition to the .html page. The .include page will have no template around it.&lt;br /&gt;
&lt;br /&gt;
For dynamic pages, those under /perl/, you can add the cgi parameter mainonly=yes&lt;br /&gt;
&lt;br /&gt;
eg. http://eprints.ecs.soton.ac.uk/perl/latest?mainonly=yes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I get statistics on number of deposits per month? ==&lt;br /&gt;
&lt;br /&gt;
This rather grim bit of SQL should work, although datestamp is the last modified date, not the submission OR creation date, it should still give a good indication.&lt;br /&gt;
&lt;br /&gt;
 select count(*), year(datestamp), month(datestamp)&lt;br /&gt;
 from archive&lt;br /&gt;
 group by year(datestamp),month(datestamp)&lt;br /&gt;
 order by year(datestamp),month(datestamp);&lt;br /&gt;
&lt;br /&gt;
== I&#039;ve edited the template (or other config file) but nothing seems to have changed - why? ==&lt;br /&gt;
&lt;br /&gt;
See [[HowEPrintsGeneratesWebPages]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
= Installation Related Questions =&lt;br /&gt;
 &lt;br /&gt;
== What platforms will GNU EPrints run on? ==&lt;br /&gt;
&lt;br /&gt;
In theory any UNIX like platform: Linux, Solaris, BSD etc. even OSX! If you don&#039;t care then we recommend the RedHat Linux distribution.&lt;br /&gt;
&lt;br /&gt;
== When running a script I get the error; &amp;quot;Insecure dependency in mkdir while running with -T switch&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
This usually indicates you are running an eprints script as root. Don&#039;t do that; become user &#039;eprints&#039; instead.&lt;br /&gt;
&lt;br /&gt;
== Errors with import_subjects when installing Eprints 2.3.3 with MySQL 4 ==&lt;br /&gt;
&lt;br /&gt;
MySQL 4 does not grant permission to create temporary tables with &amp;lt;tt&amp;gt;GRANT ALL&amp;lt;/tt&amp;gt;. Do (at the mysql prompt):&lt;br /&gt;
 GRANT CREATE TEMPORARY TABLES ON archive_name.* TO eprints@localhost IDENTIFIED BY &amp;quot;*******&amp;quot;;&lt;br /&gt;
replacing &amp;quot;archive_name&amp;quot; and &amp;quot;******&amp;quot; with your eprints mysql database name and user password. Then do:&lt;br /&gt;
 mysqladmin [-u root -p] reload&lt;br /&gt;
to reload the mysql security tables.&lt;br /&gt;
&lt;br /&gt;
== title and fulltext search returns no results, but date search does (EPrints 2.3) ==&lt;br /&gt;
&lt;br /&gt;
The indexer daemon is probably not running or is not working correctly.&lt;br /&gt;
&lt;br /&gt;
Syntax error on line 39 of /opt/eprints2/archives/eprintsOfGoat/cfg/auto-apache.conf:&lt;br /&gt;
order takes one argument, &#039;allow,deny&#039;, &#039;deny,allow&#039;, or &#039;mutual-failure&#039; on restart of Apache after initial installation&lt;br /&gt;
&lt;br /&gt;
There is a small error in the auto-apache.conf file, there is a space between &#039;deny, allow&#039; on line 39, remove this space to stop this error.&lt;br /&gt;
&lt;br /&gt;
== I don&#039;t want to give configure_archive my mysql root password. What is the alternative? ==&lt;br /&gt;
&lt;br /&gt;
(instructions acurate as of EP 2.3.12)&lt;br /&gt;
&lt;br /&gt;
Run configure_archive but say &amp;quot;no&amp;quot; to &amp;quot;create the database?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Log into the mysql client as root:&lt;br /&gt;
&lt;br /&gt;
 % mysql -u root -p&lt;br /&gt;
 Enter password: &lt;br /&gt;
&lt;br /&gt;
(and enter your password)&lt;br /&gt;
&lt;br /&gt;
This example creates a database for archive &amp;quot;foo&amp;quot; with user &amp;quot;foouser&amp;quot; and password &amp;quot;foopass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These values should match the values you gave to configure_archive. You can check them in /opt/eprints2/archives/foo.xml&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; CREATE DATABASE foo;&lt;br /&gt;
 Query OK, 1 row affected (0.06 sec)&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; GRANT ALL ON foo.* TO foouser@localhost;&lt;br /&gt;
 Query OK, 0 rows affected (0.52 sec)&lt;br /&gt;
&lt;br /&gt;
The last bit depends if you are running on a MySQL?&lt;br /&gt;
;version &amp;gt;= 4.1&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = OLD_PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
;version &amp;lt; 4.1&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
That&#039;s all &amp;lt;tt&amp;gt;configure_archive&amp;lt;/tt&amp;gt; would have done.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==  How do I get a value for a field of an eprint (without using any SQL)? ==&lt;br /&gt;
&lt;br /&gt;
(assuming the eprint is in the main archive, and has eprintid number 23)&lt;br /&gt;
&lt;br /&gt;
  my $ds = $session-&amp;gt;get_archive()-&amp;gt;get_dataset( &amp;quot;archive&amp;quot; );&lt;br /&gt;
  my $eprint = EPrints::EPrint?-&amp;gt;new( $session, 23, $ds );&lt;br /&gt;
  my $value = $eprint-&amp;gt;get_value( &#039;editors&#039; );&lt;br /&gt;
&lt;br /&gt;
== How can I get a utf8 string of the name of a subject, given its subjectid? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sub get_subject_name_string&lt;br /&gt;
  {&lt;br /&gt;
	my( $session, $subjectid ) = @_;&lt;br /&gt;
	my $subj = EPrints::Subject-&amp;gt;new( $session, $subjectid ); &lt;br /&gt;
	if( !defined $subj ) &lt;br /&gt;
	{&lt;br /&gt;
		return &amp;quot;errer, unknown subject: $subjectid&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	return EPrints::Utils::tree_to_utf8( $subj-&amp;gt;render_description() );&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using mod_perl2, pages with redirects (e.g. /perl/search) are blank. How do I fix this? ==&lt;br /&gt;
&lt;br /&gt;
In perl_lib/EPrints/Session.pm change&lt;br /&gt;
&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status_line( &amp;quot;302 Moved&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
to&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status(302);&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3957</id>
		<title>Frequently Asked Questions</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3957"/>
		<updated>2007-02-13T23:33:29Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* When running a script I get the error; &amp;quot;Insecure dependency in mkdir while running with -T switch&amp;quot; */ style&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This all needs sorting out, it&#039;s just being grabbed from the old wiki for now.&lt;br /&gt;
&lt;br /&gt;
* [[Copyright and License FAQ]]&lt;br /&gt;
* [[Metadata FAQ]]&lt;br /&gt;
* [[Searching FAQ]]&lt;br /&gt;
* [[OAI FAQ]]&lt;br /&gt;
* [[BOAI Self-Archiving FAQ]]&lt;br /&gt;
* [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== What operating systems can we use? ==&lt;br /&gt;
&lt;br /&gt;
EPrints should work on any UNIX operating system. We use Redhat Enterprise Linux. It will work on OSX but that takes a bit more effort. Please refer to the [http://www.eprints.org/documentation/handbook/osx.php Mac OS X Installation Guide] for more information&lt;br /&gt;
&lt;br /&gt;
It will not run under Microsoft Windows and we have no plan to change this.&lt;br /&gt;
&lt;br /&gt;
== What computer do we need? ==&lt;br /&gt;
&lt;br /&gt;
Any new PC is easily powerful enough. Suggested minimum spec. for a live service: 1gig RAM, 20gig Harddrive, 1GHz+ processor.&lt;br /&gt;
&lt;br /&gt;
== How much will it cost to set up? ==&lt;br /&gt;
&lt;br /&gt;
Most of the costs are staff time. Equipment costs are a PC, an internet connection and a BACKUP STRATEGY. Please remember to budget for backups.&lt;br /&gt;
&lt;br /&gt;
EPrints, and all the other software required to make it work, are available for no cost. At some point in the future EPrints may offer some pay-services, but the core software will remain zero cost and freely available to all.&lt;br /&gt;
&lt;br /&gt;
See [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== How much diskspace will we need? ==&lt;br /&gt;
&lt;br /&gt;
Proabably about 2 megabytes per eprint. At the time of writing a 120GB drive costs 50 pounds. That drive would hold approximately 60000 eprints.&lt;br /&gt;
&lt;br /&gt;
See also: [[Detailed disk usage statistics]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Is it possible when depositing a document, to just point to an &amp;quot;alternative location&amp;quot; rather than have the full text copied and held in the eprint archive? ==&lt;br /&gt;
&lt;br /&gt;
Yes, just don&#039;t assign any value to required_formats in ArchiveConfigure.pm, like so&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{required_formats} = [];&lt;br /&gt;
&lt;br /&gt;
If you are doing this it would also be clever to change the ArchiveRender routines so that on the abstract page &amp;quot;Full text available as&amp;quot; is replaced by &amp;quot;Full text available via &amp;lt;link to alternative location&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This keeps the key link to follow (to the full text) at the top of the screen.&lt;br /&gt;
&lt;br /&gt;
== I need to run apache as a user other than &amp;quot;eprints&amp;quot;, what do I do to make EPrints work in this situation? ==&lt;br /&gt;
&lt;br /&gt;
Example, apache is running as user &amp;quot;apache&amp;quot;.&lt;br /&gt;
* Make all the eprints files owned by &amp;quot;apache&amp;quot; instead of &amp;quot;eprints&amp;quot;&lt;br /&gt;
* Edit SystemSettings?.pm to tell eprints to run as user &amp;quot;apache&amp;quot;&lt;br /&gt;
* You&#039;ll need to run all command line scripts as user &amp;quot;apache&amp;quot;&lt;br /&gt;
* All eprints cron jobs should be owned by user &amp;quot;apache&amp;quot; &lt;br /&gt;
&lt;br /&gt;
If you are installing a new copy of eprints, you can specify the user and group to use when you run &#039;configure&#039;. Do&lt;br /&gt;
&lt;br /&gt;
 ./configure --help &lt;br /&gt;
&lt;br /&gt;
for details.&lt;br /&gt;
&lt;br /&gt;
== How do I get the body HTML of a page without the template around it? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is handy for dymnamically linking eprints content into other sites.&lt;br /&gt;
&lt;br /&gt;
For &amp;quot;view&amp;quot; pages you need to add the option include=&amp;gt;1 to the view configuration. This will cause generate_views to make a .include page in addition to the .html page. The .include page will have no template around it.&lt;br /&gt;
&lt;br /&gt;
For dynamic pages, those under /perl/, you can add the cgi parameter mainonly=yes&lt;br /&gt;
&lt;br /&gt;
eg.&lt;br /&gt;
&lt;br /&gt;
http://eprints.ecs.soton.ac.uk/perl/latest?mainonly=yes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I get statistics on number of deposits per month? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This rather grim bit of SQL should work, although datestamp is the last modified date, not the submission OR creation date, it should still give a good indication.&lt;br /&gt;
&lt;br /&gt;
 select count(*), year(datestamp), month(datestamp)&lt;br /&gt;
 from archive&lt;br /&gt;
 group by year(datestamp),month(datestamp)&lt;br /&gt;
 order by year(datestamp),month(datestamp);&lt;br /&gt;
&lt;br /&gt;
== I&#039;ve edited the template (or other config file) but nothing seems to have changed - why? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See [[HowEPrintsGeneratesWebPages]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Installation Related Questions =&lt;br /&gt;
 &lt;br /&gt;
== What platforms will GNU EPrints run on? ==&lt;br /&gt;
&lt;br /&gt;
In theory any UNIX like platform: Linux, Solaris, BSD etc. even OSX! If you don&#039;t care then we recommend the RedHat Linux distribution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== When running a script I get the error; &amp;quot;Insecure dependency in mkdir while running with -T switch&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
This usually indicates you are running an eprints script as root. Don&#039;t do that; become user &#039;eprints&#039; instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Errors with import_subjects when installing Eprints 2.3.3 with MySQL 4 ==&lt;br /&gt;
&lt;br /&gt;
MySQL 4 does not grant permission to create temporary tables with &amp;lt;tt&amp;gt;GRANT ALL&amp;lt;/tt&amp;gt;. Do (at the mysql prompt):&lt;br /&gt;
 GRANT CREATE TEMPORARY TABLES ON archive_name.* TO eprints@localhost IDENTIFIED BY &amp;quot;*******&amp;quot;;&lt;br /&gt;
replacing &amp;quot;archive_name&amp;quot; and &amp;quot;******&amp;quot; with your eprints mysql database name and user password. Then do:&lt;br /&gt;
 mysqladmin [-u root -p] reload&lt;br /&gt;
to reload the mysql security tables.&lt;br /&gt;
&lt;br /&gt;
== title and fulltext search returns no results, but date search does (EPrints 2.3) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The indexer daemon is probably not running or is not working correctly.&lt;br /&gt;
&lt;br /&gt;
Syntax error on line 39 of /opt/eprints2/archives/eprintsOfGoat/cfg/auto-apache.conf:&lt;br /&gt;
order takes one argument, &#039;allow,deny&#039;, &#039;deny,allow&#039;, or &#039;mutual-failure&#039; on restart of Apache after initial installation&lt;br /&gt;
&lt;br /&gt;
There is a small error in the auto-apache.conf file, there is a space between &#039;deny, allow&#039; on line 39, remove this space to stop this error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== I don\&#039;t want to give configure_archive my mysql root password. What is the alternative? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(instructions acurate as of EP 2.3.12)&lt;br /&gt;
&lt;br /&gt;
Run configure_archive but say &amp;quot;no&amp;quot; to &amp;quot;create the database?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Log into the mysql client as root:&lt;br /&gt;
&lt;br /&gt;
 % mysql -u root -p&lt;br /&gt;
 Enter password: &lt;br /&gt;
&lt;br /&gt;
(and enter your password)&lt;br /&gt;
&lt;br /&gt;
This example creates a database for archive &amp;quot;foo&amp;quot; with user &amp;quot;foouser&amp;quot; and password &amp;quot;foopass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These values should match the values you gave to configure_archive. You can check them in /opt/eprints2/archives/foo.xml&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; CREATE DATABASE foo;&lt;br /&gt;
 Query OK, 1 row affected (0.06 sec)&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; GRANT ALL ON foo.* TO foouser@localhost;&lt;br /&gt;
 Query OK, 0 rows affected (0.52 sec)&lt;br /&gt;
&lt;br /&gt;
The last bit depends if you are running on a MySQL? version equal of greater than 4.1&lt;br /&gt;
&lt;br /&gt;
4.1+:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = OLD_PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
pre 4.1:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
That&#039;s all configure_archive would have done.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  How do I get a value for a field of an eprint (without using any SQL)? ==&lt;br /&gt;
&lt;br /&gt;
(assuming the eprint is in the main archive, and has eprintid number 23)&lt;br /&gt;
&lt;br /&gt;
  my $ds = $session-&amp;gt;get_archive()-&amp;gt;get_dataset( &amp;quot;archive&amp;quot; );&lt;br /&gt;
  my $eprint = EPrints::EPrint?-&amp;gt;new( $session, 23, $ds );&lt;br /&gt;
  my $value = $eprint-&amp;gt;get_value( &#039;editors&#039; );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How can I get a utf8 string of the name of a subject, given its subjectid? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sub get_subject_name_string&lt;br /&gt;
  {&lt;br /&gt;
	my( $session, $subjectid ) = @_;&lt;br /&gt;
	my $subj = EPrints::Subject-&amp;gt;new( $session, $subjectid ); &lt;br /&gt;
	if( !defined $subj ) &lt;br /&gt;
	{&lt;br /&gt;
		return &amp;quot;errer, unknown subject: $subjectid&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	return EPrints::Utils::tree_to_utf8( $subj-&amp;gt;render_description() );&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using mod_perl2, pages with redirects (e.g. /perl/search) are blank. How do I fix this? ==&lt;br /&gt;
&lt;br /&gt;
In perl_lib/EPrints/Session.pm change&lt;br /&gt;
&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status_line( &amp;quot;302 Moved&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
to&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status(302);&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3956</id>
		<title>Frequently Asked Questions</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3956"/>
		<updated>2007-02-13T23:28:18Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* I\&amp;#039;ve edited the template (or other config file) but nothing seems to have changed - why? */ style&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This all needs sorting out, it&#039;s just being grabbed from the old wiki for now.&lt;br /&gt;
&lt;br /&gt;
* [[Copyright and License FAQ]]&lt;br /&gt;
* [[Metadata FAQ]]&lt;br /&gt;
* [[Searching FAQ]]&lt;br /&gt;
* [[OAI FAQ]]&lt;br /&gt;
* [[BOAI Self-Archiving FAQ]]&lt;br /&gt;
* [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== What operating systems can we use? ==&lt;br /&gt;
&lt;br /&gt;
EPrints should work on any UNIX operating system. We use Redhat Enterprise Linux. It will work on OSX but that takes a bit more effort. Please refer to the [http://www.eprints.org/documentation/handbook/osx.php Mac OS X Installation Guide] for more information&lt;br /&gt;
&lt;br /&gt;
It will not run under Microsoft Windows and we have no plan to change this.&lt;br /&gt;
&lt;br /&gt;
== What computer do we need? ==&lt;br /&gt;
&lt;br /&gt;
Any new PC is easily powerful enough. Suggested minimum spec. for a live service: 1gig RAM, 20gig Harddrive, 1GHz+ processor.&lt;br /&gt;
&lt;br /&gt;
== How much will it cost to set up? ==&lt;br /&gt;
&lt;br /&gt;
Most of the costs are staff time. Equipment costs are a PC, an internet connection and a BACKUP STRATEGY. Please remember to budget for backups.&lt;br /&gt;
&lt;br /&gt;
EPrints, and all the other software required to make it work, are available for no cost. At some point in the future EPrints may offer some pay-services, but the core software will remain zero cost and freely available to all.&lt;br /&gt;
&lt;br /&gt;
See [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== How much diskspace will we need? ==&lt;br /&gt;
&lt;br /&gt;
Proabably about 2 megabytes per eprint. At the time of writing a 120GB drive costs 50 pounds. That drive would hold approximately 60000 eprints.&lt;br /&gt;
&lt;br /&gt;
See also: [[Detailed disk usage statistics]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Is it possible when depositing a document, to just point to an &amp;quot;alternative location&amp;quot; rather than have the full text copied and held in the eprint archive? ==&lt;br /&gt;
&lt;br /&gt;
Yes, just don&#039;t assign any value to required_formats in ArchiveConfigure.pm, like so&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{required_formats} = [];&lt;br /&gt;
&lt;br /&gt;
If you are doing this it would also be clever to change the ArchiveRender routines so that on the abstract page &amp;quot;Full text available as&amp;quot; is replaced by &amp;quot;Full text available via &amp;lt;link to alternative location&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This keeps the key link to follow (to the full text) at the top of the screen.&lt;br /&gt;
&lt;br /&gt;
== I need to run apache as a user other than &amp;quot;eprints&amp;quot;, what do I do to make EPrints work in this situation? ==&lt;br /&gt;
&lt;br /&gt;
Example, apache is running as user &amp;quot;apache&amp;quot;.&lt;br /&gt;
* Make all the eprints files owned by &amp;quot;apache&amp;quot; instead of &amp;quot;eprints&amp;quot;&lt;br /&gt;
* Edit SystemSettings?.pm to tell eprints to run as user &amp;quot;apache&amp;quot;&lt;br /&gt;
* You&#039;ll need to run all command line scripts as user &amp;quot;apache&amp;quot;&lt;br /&gt;
* All eprints cron jobs should be owned by user &amp;quot;apache&amp;quot; &lt;br /&gt;
&lt;br /&gt;
If you are installing a new copy of eprints, you can specify the user and group to use when you run &#039;configure&#039;. Do&lt;br /&gt;
&lt;br /&gt;
 ./configure --help &lt;br /&gt;
&lt;br /&gt;
for details.&lt;br /&gt;
&lt;br /&gt;
== How do I get the body HTML of a page without the template around it? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is handy for dymnamically linking eprints content into other sites.&lt;br /&gt;
&lt;br /&gt;
For &amp;quot;view&amp;quot; pages you need to add the option include=&amp;gt;1 to the view configuration. This will cause generate_views to make a .include page in addition to the .html page. The .include page will have no template around it.&lt;br /&gt;
&lt;br /&gt;
For dynamic pages, those under /perl/, you can add the cgi parameter mainonly=yes&lt;br /&gt;
&lt;br /&gt;
eg.&lt;br /&gt;
&lt;br /&gt;
http://eprints.ecs.soton.ac.uk/perl/latest?mainonly=yes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I get statistics on number of deposits per month? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This rather grim bit of SQL should work, although datestamp is the last modified date, not the submission OR creation date, it should still give a good indication.&lt;br /&gt;
&lt;br /&gt;
 select count(*), year(datestamp), month(datestamp)&lt;br /&gt;
 from archive&lt;br /&gt;
 group by year(datestamp),month(datestamp)&lt;br /&gt;
 order by year(datestamp),month(datestamp);&lt;br /&gt;
&lt;br /&gt;
== I&#039;ve edited the template (or other config file) but nothing seems to have changed - why? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See [[HowEPrintsGeneratesWebPages]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Installation Related Questions =&lt;br /&gt;
 &lt;br /&gt;
== What platforms will GNU EPrints run on? ==&lt;br /&gt;
&lt;br /&gt;
In theory any UNIX like platform: Linux, Solaris, BSD etc. even OSX! If you don&#039;t care then we recommend the RedHat Linux distribution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== When running a script I get the error; &amp;quot;Insecure dependency in mkdir while running with -T switch&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
This usually indicates you are running an eprints script as root. Don&#039;t do that; become user &#039;eprints&#039; instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Errors with import_subjects when installing Eprints 2.3.3 with MySQL? 4&lt;br /&gt;
MySQL? ==&lt;br /&gt;
&lt;br /&gt;
4 does not grant permission to create temporary tables with GRANT ALL. Do (at the mysql prompt): GRANT CREATE TEMPORARY TABLES ON archive_name.* TO eprints@localhost IDENTIFIED BY &amp;quot;*******&amp;quot;; Then do: mysqladmin -u root -p reload to reload the mysql security tables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== title and fulltext search returns no results, but date search does (EPrints 2.3) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The indexer daemon is probably not running or is not working correctly.&lt;br /&gt;
&lt;br /&gt;
Syntax error on line 39 of /opt/eprints2/archives/eprintsOfGoat/cfg/auto-apache.conf:&lt;br /&gt;
order takes one argument, &#039;allow,deny&#039;, &#039;deny,allow&#039;, or &#039;mutual-failure&#039; on restart of Apache after initial installation&lt;br /&gt;
&lt;br /&gt;
There is a small error in the auto-apache.conf file, there is a space between &#039;deny, allow&#039; on line 39, remove this space to stop this error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== I don\&#039;t want to give configure_archive my mysql root password. What is the alternative? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(instructions acurate as of EP 2.3.12)&lt;br /&gt;
&lt;br /&gt;
Run configure_archive but say &amp;quot;no&amp;quot; to &amp;quot;create the database?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Log into the mysql client as root:&lt;br /&gt;
&lt;br /&gt;
 % mysql -u root -p&lt;br /&gt;
 Enter password: &lt;br /&gt;
&lt;br /&gt;
(and enter your password)&lt;br /&gt;
&lt;br /&gt;
This example creates a database for archive &amp;quot;foo&amp;quot; with user &amp;quot;foouser&amp;quot; and password &amp;quot;foopass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These values should match the values you gave to configure_archive. You can check them in /opt/eprints2/archives/foo.xml&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; CREATE DATABASE foo;&lt;br /&gt;
 Query OK, 1 row affected (0.06 sec)&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; GRANT ALL ON foo.* TO foouser@localhost;&lt;br /&gt;
 Query OK, 0 rows affected (0.52 sec)&lt;br /&gt;
&lt;br /&gt;
The last bit depends if you are running on a MySQL? version equal of greater than 4.1&lt;br /&gt;
&lt;br /&gt;
4.1+:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = OLD_PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
pre 4.1:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
That&#039;s all configure_archive would have done.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  How do I get a value for a field of an eprint (without using any SQL)? ==&lt;br /&gt;
&lt;br /&gt;
(assuming the eprint is in the main archive, and has eprintid number 23)&lt;br /&gt;
&lt;br /&gt;
  my $ds = $session-&amp;gt;get_archive()-&amp;gt;get_dataset( &amp;quot;archive&amp;quot; );&lt;br /&gt;
  my $eprint = EPrints::EPrint?-&amp;gt;new( $session, 23, $ds );&lt;br /&gt;
  my $value = $eprint-&amp;gt;get_value( &#039;editors&#039; );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How can I get a utf8 string of the name of a subject, given its subjectid? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sub get_subject_name_string&lt;br /&gt;
  {&lt;br /&gt;
	my( $session, $subjectid ) = @_;&lt;br /&gt;
	my $subj = EPrints::Subject-&amp;gt;new( $session, $subjectid ); &lt;br /&gt;
	if( !defined $subj ) &lt;br /&gt;
	{&lt;br /&gt;
		return &amp;quot;errer, unknown subject: $subjectid&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	return EPrints::Utils::tree_to_utf8( $subj-&amp;gt;render_description() );&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using mod_perl2, pages with redirects (e.g. /perl/search) are blank. How do I fix this? ==&lt;br /&gt;
&lt;br /&gt;
In perl_lib/EPrints/Session.pm change&lt;br /&gt;
&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status_line( &amp;quot;302 Moved&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
to&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status(302);&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3955</id>
		<title>Frequently Asked Questions</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3955"/>
		<updated>2007-02-13T23:27:38Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* How do I get statistics on number of deposits per month? */ style&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This all needs sorting out, it&#039;s just being grabbed from the old wiki for now.&lt;br /&gt;
&lt;br /&gt;
* [[Copyright and License FAQ]]&lt;br /&gt;
* [[Metadata FAQ]]&lt;br /&gt;
* [[Searching FAQ]]&lt;br /&gt;
* [[OAI FAQ]]&lt;br /&gt;
* [[BOAI Self-Archiving FAQ]]&lt;br /&gt;
* [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== What operating systems can we use? ==&lt;br /&gt;
&lt;br /&gt;
EPrints should work on any UNIX operating system. We use Redhat Enterprise Linux. It will work on OSX but that takes a bit more effort. Please refer to the [http://www.eprints.org/documentation/handbook/osx.php Mac OS X Installation Guide] for more information&lt;br /&gt;
&lt;br /&gt;
It will not run under Microsoft Windows and we have no plan to change this.&lt;br /&gt;
&lt;br /&gt;
== What computer do we need? ==&lt;br /&gt;
&lt;br /&gt;
Any new PC is easily powerful enough. Suggested minimum spec. for a live service: 1gig RAM, 20gig Harddrive, 1GHz+ processor.&lt;br /&gt;
&lt;br /&gt;
== How much will it cost to set up? ==&lt;br /&gt;
&lt;br /&gt;
Most of the costs are staff time. Equipment costs are a PC, an internet connection and a BACKUP STRATEGY. Please remember to budget for backups.&lt;br /&gt;
&lt;br /&gt;
EPrints, and all the other software required to make it work, are available for no cost. At some point in the future EPrints may offer some pay-services, but the core software will remain zero cost and freely available to all.&lt;br /&gt;
&lt;br /&gt;
See [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== How much diskspace will we need? ==&lt;br /&gt;
&lt;br /&gt;
Proabably about 2 megabytes per eprint. At the time of writing a 120GB drive costs 50 pounds. That drive would hold approximately 60000 eprints.&lt;br /&gt;
&lt;br /&gt;
See also: [[Detailed disk usage statistics]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Is it possible when depositing a document, to just point to an &amp;quot;alternative location&amp;quot; rather than have the full text copied and held in the eprint archive? ==&lt;br /&gt;
&lt;br /&gt;
Yes, just don&#039;t assign any value to required_formats in ArchiveConfigure.pm, like so&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{required_formats} = [];&lt;br /&gt;
&lt;br /&gt;
If you are doing this it would also be clever to change the ArchiveRender routines so that on the abstract page &amp;quot;Full text available as&amp;quot; is replaced by &amp;quot;Full text available via &amp;lt;link to alternative location&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This keeps the key link to follow (to the full text) at the top of the screen.&lt;br /&gt;
&lt;br /&gt;
== I need to run apache as a user other than &amp;quot;eprints&amp;quot;, what do I do to make EPrints work in this situation? ==&lt;br /&gt;
&lt;br /&gt;
Example, apache is running as user &amp;quot;apache&amp;quot;.&lt;br /&gt;
* Make all the eprints files owned by &amp;quot;apache&amp;quot; instead of &amp;quot;eprints&amp;quot;&lt;br /&gt;
* Edit SystemSettings?.pm to tell eprints to run as user &amp;quot;apache&amp;quot;&lt;br /&gt;
* You&#039;ll need to run all command line scripts as user &amp;quot;apache&amp;quot;&lt;br /&gt;
* All eprints cron jobs should be owned by user &amp;quot;apache&amp;quot; &lt;br /&gt;
&lt;br /&gt;
If you are installing a new copy of eprints, you can specify the user and group to use when you run &#039;configure&#039;. Do&lt;br /&gt;
&lt;br /&gt;
 ./configure --help &lt;br /&gt;
&lt;br /&gt;
for details.&lt;br /&gt;
&lt;br /&gt;
== How do I get the body HTML of a page without the template around it? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is handy for dymnamically linking eprints content into other sites.&lt;br /&gt;
&lt;br /&gt;
For &amp;quot;view&amp;quot; pages you need to add the option include=&amp;gt;1 to the view configuration. This will cause generate_views to make a .include page in addition to the .html page. The .include page will have no template around it.&lt;br /&gt;
&lt;br /&gt;
For dynamic pages, those under /perl/, you can add the cgi parameter mainonly=yes&lt;br /&gt;
&lt;br /&gt;
eg.&lt;br /&gt;
&lt;br /&gt;
http://eprints.ecs.soton.ac.uk/perl/latest?mainonly=yes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I get statistics on number of deposits per month? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This rather grim bit of SQL should work, although datestamp is the last modified date, not the submission OR creation date, it should still give a good indication.&lt;br /&gt;
&lt;br /&gt;
 select count(*), year(datestamp), month(datestamp)&lt;br /&gt;
 from archive&lt;br /&gt;
 group by year(datestamp),month(datestamp)&lt;br /&gt;
 order by year(datestamp),month(datestamp);&lt;br /&gt;
&lt;br /&gt;
== I\&#039;ve edited the template (or other config file) but nothing seems to have changed - why? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See HowEPrintsGeneratesWebPages&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Installation Related Questions =&lt;br /&gt;
 &lt;br /&gt;
== What platforms will GNU EPrints run on? ==&lt;br /&gt;
&lt;br /&gt;
In theory any UNIX like platform: Linux, Solaris, BSD etc. even OSX! If you don&#039;t care then we recommend the RedHat Linux distribution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== When running a script I get the error; &amp;quot;Insecure dependency in mkdir while running with -T switch&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
This usually indicates you are running an eprints script as root. Don&#039;t do that; become user &#039;eprints&#039; instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Errors with import_subjects when installing Eprints 2.3.3 with MySQL? 4&lt;br /&gt;
MySQL? ==&lt;br /&gt;
&lt;br /&gt;
4 does not grant permission to create temporary tables with GRANT ALL. Do (at the mysql prompt): GRANT CREATE TEMPORARY TABLES ON archive_name.* TO eprints@localhost IDENTIFIED BY &amp;quot;*******&amp;quot;; Then do: mysqladmin -u root -p reload to reload the mysql security tables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== title and fulltext search returns no results, but date search does (EPrints 2.3) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The indexer daemon is probably not running or is not working correctly.&lt;br /&gt;
&lt;br /&gt;
Syntax error on line 39 of /opt/eprints2/archives/eprintsOfGoat/cfg/auto-apache.conf:&lt;br /&gt;
order takes one argument, &#039;allow,deny&#039;, &#039;deny,allow&#039;, or &#039;mutual-failure&#039; on restart of Apache after initial installation&lt;br /&gt;
&lt;br /&gt;
There is a small error in the auto-apache.conf file, there is a space between &#039;deny, allow&#039; on line 39, remove this space to stop this error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== I don\&#039;t want to give configure_archive my mysql root password. What is the alternative? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(instructions acurate as of EP 2.3.12)&lt;br /&gt;
&lt;br /&gt;
Run configure_archive but say &amp;quot;no&amp;quot; to &amp;quot;create the database?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Log into the mysql client as root:&lt;br /&gt;
&lt;br /&gt;
 % mysql -u root -p&lt;br /&gt;
 Enter password: &lt;br /&gt;
&lt;br /&gt;
(and enter your password)&lt;br /&gt;
&lt;br /&gt;
This example creates a database for archive &amp;quot;foo&amp;quot; with user &amp;quot;foouser&amp;quot; and password &amp;quot;foopass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These values should match the values you gave to configure_archive. You can check them in /opt/eprints2/archives/foo.xml&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; CREATE DATABASE foo;&lt;br /&gt;
 Query OK, 1 row affected (0.06 sec)&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; GRANT ALL ON foo.* TO foouser@localhost;&lt;br /&gt;
 Query OK, 0 rows affected (0.52 sec)&lt;br /&gt;
&lt;br /&gt;
The last bit depends if you are running on a MySQL? version equal of greater than 4.1&lt;br /&gt;
&lt;br /&gt;
4.1+:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = OLD_PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
pre 4.1:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
That&#039;s all configure_archive would have done.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  How do I get a value for a field of an eprint (without using any SQL)? ==&lt;br /&gt;
&lt;br /&gt;
(assuming the eprint is in the main archive, and has eprintid number 23)&lt;br /&gt;
&lt;br /&gt;
  my $ds = $session-&amp;gt;get_archive()-&amp;gt;get_dataset( &amp;quot;archive&amp;quot; );&lt;br /&gt;
  my $eprint = EPrints::EPrint?-&amp;gt;new( $session, 23, $ds );&lt;br /&gt;
  my $value = $eprint-&amp;gt;get_value( &#039;editors&#039; );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How can I get a utf8 string of the name of a subject, given its subjectid? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sub get_subject_name_string&lt;br /&gt;
  {&lt;br /&gt;
	my( $session, $subjectid ) = @_;&lt;br /&gt;
	my $subj = EPrints::Subject-&amp;gt;new( $session, $subjectid ); &lt;br /&gt;
	if( !defined $subj ) &lt;br /&gt;
	{&lt;br /&gt;
		return &amp;quot;errer, unknown subject: $subjectid&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	return EPrints::Utils::tree_to_utf8( $subj-&amp;gt;render_description() );&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using mod_perl2, pages with redirects (e.g. /perl/search) are blank. How do I fix this? ==&lt;br /&gt;
&lt;br /&gt;
In perl_lib/EPrints/Session.pm change&lt;br /&gt;
&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status_line( &amp;quot;302 Moved&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
to&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status(302);&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3954</id>
		<title>Frequently Asked Questions</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3954"/>
		<updated>2007-02-13T23:25:47Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* I need to run apache as a user other than &amp;quot;eprints&amp;quot;, what do I do to make EPrints work in this situation? */ style&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This all needs sorting out, it&#039;s just being grabbed from the old wiki for now.&lt;br /&gt;
&lt;br /&gt;
* [[Copyright and License FAQ]]&lt;br /&gt;
* [[Metadata FAQ]]&lt;br /&gt;
* [[Searching FAQ]]&lt;br /&gt;
* [[OAI FAQ]]&lt;br /&gt;
* [[BOAI Self-Archiving FAQ]]&lt;br /&gt;
* [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== What operating systems can we use? ==&lt;br /&gt;
&lt;br /&gt;
EPrints should work on any UNIX operating system. We use Redhat Enterprise Linux. It will work on OSX but that takes a bit more effort. Please refer to the [http://www.eprints.org/documentation/handbook/osx.php Mac OS X Installation Guide] for more information&lt;br /&gt;
&lt;br /&gt;
It will not run under Microsoft Windows and we have no plan to change this.&lt;br /&gt;
&lt;br /&gt;
== What computer do we need? ==&lt;br /&gt;
&lt;br /&gt;
Any new PC is easily powerful enough. Suggested minimum spec. for a live service: 1gig RAM, 20gig Harddrive, 1GHz+ processor.&lt;br /&gt;
&lt;br /&gt;
== How much will it cost to set up? ==&lt;br /&gt;
&lt;br /&gt;
Most of the costs are staff time. Equipment costs are a PC, an internet connection and a BACKUP STRATEGY. Please remember to budget for backups.&lt;br /&gt;
&lt;br /&gt;
EPrints, and all the other software required to make it work, are available for no cost. At some point in the future EPrints may offer some pay-services, but the core software will remain zero cost and freely available to all.&lt;br /&gt;
&lt;br /&gt;
See [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== How much diskspace will we need? ==&lt;br /&gt;
&lt;br /&gt;
Proabably about 2 megabytes per eprint. At the time of writing a 120GB drive costs 50 pounds. That drive would hold approximately 60000 eprints.&lt;br /&gt;
&lt;br /&gt;
See also: [[Detailed disk usage statistics]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Is it possible when depositing a document, to just point to an &amp;quot;alternative location&amp;quot; rather than have the full text copied and held in the eprint archive? ==&lt;br /&gt;
&lt;br /&gt;
Yes, just don&#039;t assign any value to required_formats in ArchiveConfigure.pm, like so&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{required_formats} = [];&lt;br /&gt;
&lt;br /&gt;
If you are doing this it would also be clever to change the ArchiveRender routines so that on the abstract page &amp;quot;Full text available as&amp;quot; is replaced by &amp;quot;Full text available via &amp;lt;link to alternative location&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This keeps the key link to follow (to the full text) at the top of the screen.&lt;br /&gt;
&lt;br /&gt;
== I need to run apache as a user other than &amp;quot;eprints&amp;quot;, what do I do to make EPrints work in this situation? ==&lt;br /&gt;
&lt;br /&gt;
Example, apache is running as user &amp;quot;apache&amp;quot;.&lt;br /&gt;
* Make all the eprints files owned by &amp;quot;apache&amp;quot; instead of &amp;quot;eprints&amp;quot;&lt;br /&gt;
* Edit SystemSettings?.pm to tell eprints to run as user &amp;quot;apache&amp;quot;&lt;br /&gt;
* You&#039;ll need to run all command line scripts as user &amp;quot;apache&amp;quot;&lt;br /&gt;
* All eprints cron jobs should be owned by user &amp;quot;apache&amp;quot; &lt;br /&gt;
&lt;br /&gt;
If you are installing a new copy of eprints, you can specify the user and group to use when you run &#039;configure&#039;. Do&lt;br /&gt;
&lt;br /&gt;
 ./configure --help &lt;br /&gt;
&lt;br /&gt;
for details.&lt;br /&gt;
&lt;br /&gt;
== How do I get the body HTML of a page without the template around it? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is handy for dymnamically linking eprints content into other sites.&lt;br /&gt;
&lt;br /&gt;
For &amp;quot;view&amp;quot; pages you need to add the option include=&amp;gt;1 to the view configuration. This will cause generate_views to make a .include page in addition to the .html page. The .include page will have no template around it.&lt;br /&gt;
&lt;br /&gt;
For dynamic pages, those under /perl/, you can add the cgi parameter mainonly=yes&lt;br /&gt;
&lt;br /&gt;
eg.&lt;br /&gt;
&lt;br /&gt;
http://eprints.ecs.soton.ac.uk/perl/latest?mainonly=yes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I get statistics on number of deposits per month? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This rather grim bit of SQL should work, although datestamp is the last modified date, not the submission OR creation date, it should still give a good indication.&lt;br /&gt;
&lt;br /&gt;
select count(*),year(datestamp), month(datestamp) from archive group by year(datestamp),month(datestamp) order by year(datestamp),month(datestamp);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== I\&#039;ve edited the template (or other config file) but nothing seems to have changed - why? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See HowEPrintsGeneratesWebPages&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Installation Related Questions =&lt;br /&gt;
 &lt;br /&gt;
== What platforms will GNU EPrints run on? ==&lt;br /&gt;
&lt;br /&gt;
In theory any UNIX like platform: Linux, Solaris, BSD etc. even OSX! If you don&#039;t care then we recommend the RedHat Linux distribution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== When running a script I get the error; &amp;quot;Insecure dependency in mkdir while running with -T switch&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
This usually indicates you are running an eprints script as root. Don&#039;t do that; become user &#039;eprints&#039; instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Errors with import_subjects when installing Eprints 2.3.3 with MySQL? 4&lt;br /&gt;
MySQL? ==&lt;br /&gt;
&lt;br /&gt;
4 does not grant permission to create temporary tables with GRANT ALL. Do (at the mysql prompt): GRANT CREATE TEMPORARY TABLES ON archive_name.* TO eprints@localhost IDENTIFIED BY &amp;quot;*******&amp;quot;; Then do: mysqladmin -u root -p reload to reload the mysql security tables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== title and fulltext search returns no results, but date search does (EPrints 2.3) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The indexer daemon is probably not running or is not working correctly.&lt;br /&gt;
&lt;br /&gt;
Syntax error on line 39 of /opt/eprints2/archives/eprintsOfGoat/cfg/auto-apache.conf:&lt;br /&gt;
order takes one argument, &#039;allow,deny&#039;, &#039;deny,allow&#039;, or &#039;mutual-failure&#039; on restart of Apache after initial installation&lt;br /&gt;
&lt;br /&gt;
There is a small error in the auto-apache.conf file, there is a space between &#039;deny, allow&#039; on line 39, remove this space to stop this error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== I don\&#039;t want to give configure_archive my mysql root password. What is the alternative? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(instructions acurate as of EP 2.3.12)&lt;br /&gt;
&lt;br /&gt;
Run configure_archive but say &amp;quot;no&amp;quot; to &amp;quot;create the database?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Log into the mysql client as root:&lt;br /&gt;
&lt;br /&gt;
 % mysql -u root -p&lt;br /&gt;
 Enter password: &lt;br /&gt;
&lt;br /&gt;
(and enter your password)&lt;br /&gt;
&lt;br /&gt;
This example creates a database for archive &amp;quot;foo&amp;quot; with user &amp;quot;foouser&amp;quot; and password &amp;quot;foopass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These values should match the values you gave to configure_archive. You can check them in /opt/eprints2/archives/foo.xml&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; CREATE DATABASE foo;&lt;br /&gt;
 Query OK, 1 row affected (0.06 sec)&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; GRANT ALL ON foo.* TO foouser@localhost;&lt;br /&gt;
 Query OK, 0 rows affected (0.52 sec)&lt;br /&gt;
&lt;br /&gt;
The last bit depends if you are running on a MySQL? version equal of greater than 4.1&lt;br /&gt;
&lt;br /&gt;
4.1+:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = OLD_PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
pre 4.1:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
That&#039;s all configure_archive would have done.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  How do I get a value for a field of an eprint (without using any SQL)? ==&lt;br /&gt;
&lt;br /&gt;
(assuming the eprint is in the main archive, and has eprintid number 23)&lt;br /&gt;
&lt;br /&gt;
  my $ds = $session-&amp;gt;get_archive()-&amp;gt;get_dataset( &amp;quot;archive&amp;quot; );&lt;br /&gt;
  my $eprint = EPrints::EPrint?-&amp;gt;new( $session, 23, $ds );&lt;br /&gt;
  my $value = $eprint-&amp;gt;get_value( &#039;editors&#039; );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How can I get a utf8 string of the name of a subject, given its subjectid? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sub get_subject_name_string&lt;br /&gt;
  {&lt;br /&gt;
	my( $session, $subjectid ) = @_;&lt;br /&gt;
	my $subj = EPrints::Subject-&amp;gt;new( $session, $subjectid ); &lt;br /&gt;
	if( !defined $subj ) &lt;br /&gt;
	{&lt;br /&gt;
		return &amp;quot;errer, unknown subject: $subjectid&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	return EPrints::Utils::tree_to_utf8( $subj-&amp;gt;render_description() );&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using mod_perl2, pages with redirects (e.g. /perl/search) are blank. How do I fix this? ==&lt;br /&gt;
&lt;br /&gt;
In perl_lib/EPrints/Session.pm change&lt;br /&gt;
&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status_line( &amp;quot;302 Moved&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
to&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status(302);&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3953</id>
		<title>Frequently Asked Questions</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3953"/>
		<updated>2007-02-13T23:25:17Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* Is it possible when depositing a document, to just point to an &amp;quot;alternative location&amp;quot; rather than have the full text copied and held in the eprint archive? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This all needs sorting out, it&#039;s just being grabbed from the old wiki for now.&lt;br /&gt;
&lt;br /&gt;
* [[Copyright and License FAQ]]&lt;br /&gt;
* [[Metadata FAQ]]&lt;br /&gt;
* [[Searching FAQ]]&lt;br /&gt;
* [[OAI FAQ]]&lt;br /&gt;
* [[BOAI Self-Archiving FAQ]]&lt;br /&gt;
* [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== What operating systems can we use? ==&lt;br /&gt;
&lt;br /&gt;
EPrints should work on any UNIX operating system. We use Redhat Enterprise Linux. It will work on OSX but that takes a bit more effort. Please refer to the [http://www.eprints.org/documentation/handbook/osx.php Mac OS X Installation Guide] for more information&lt;br /&gt;
&lt;br /&gt;
It will not run under Microsoft Windows and we have no plan to change this.&lt;br /&gt;
&lt;br /&gt;
== What computer do we need? ==&lt;br /&gt;
&lt;br /&gt;
Any new PC is easily powerful enough. Suggested minimum spec. for a live service: 1gig RAM, 20gig Harddrive, 1GHz+ processor.&lt;br /&gt;
&lt;br /&gt;
== How much will it cost to set up? ==&lt;br /&gt;
&lt;br /&gt;
Most of the costs are staff time. Equipment costs are a PC, an internet connection and a BACKUP STRATEGY. Please remember to budget for backups.&lt;br /&gt;
&lt;br /&gt;
EPrints, and all the other software required to make it work, are available for no cost. At some point in the future EPrints may offer some pay-services, but the core software will remain zero cost and freely available to all.&lt;br /&gt;
&lt;br /&gt;
See [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== How much diskspace will we need? ==&lt;br /&gt;
&lt;br /&gt;
Proabably about 2 megabytes per eprint. At the time of writing a 120GB drive costs 50 pounds. That drive would hold approximately 60000 eprints.&lt;br /&gt;
&lt;br /&gt;
See also: [[Detailed disk usage statistics]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Is it possible when depositing a document, to just point to an &amp;quot;alternative location&amp;quot; rather than have the full text copied and held in the eprint archive? ==&lt;br /&gt;
&lt;br /&gt;
Yes, just don&#039;t assign any value to required_formats in ArchiveConfigure.pm, like so&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{required_formats} = [];&lt;br /&gt;
&lt;br /&gt;
If you are doing this it would also be clever to change the ArchiveRender routines so that on the abstract page &amp;quot;Full text available as&amp;quot; is replaced by &amp;quot;Full text available via &amp;lt;link to alternative location&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This keeps the key link to follow (to the full text) at the top of the screen.&lt;br /&gt;
&lt;br /&gt;
== I need to run apache as a user other than &amp;quot;eprints&amp;quot;, what do I do to make EPrints work in this situation? ==&lt;br /&gt;
&lt;br /&gt;
Example, apache is running as user &amp;quot;apache&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
    * Make all the eprints files owned by &amp;quot;apache&amp;quot; instead of &amp;quot;eprints&amp;quot;&lt;br /&gt;
    * Edit SystemSettings?.pm to tell eprints to run as user &amp;quot;apache&amp;quot;&lt;br /&gt;
    * You&#039;ll need to run all command line scripts as user &amp;quot;apache&amp;quot;&lt;br /&gt;
    * All eprints cron jobs should be owned by user &amp;quot;apache&amp;quot; &lt;br /&gt;
&lt;br /&gt;
If you are installing a new copy of eprints, you can specify the user and group to use when you run &#039;configure&#039;. Do&lt;br /&gt;
&lt;br /&gt;
 ./configure --help &lt;br /&gt;
&lt;br /&gt;
for details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I get the body HTML of a page without the template around it? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is handy for dymnamically linking eprints content into other sites.&lt;br /&gt;
&lt;br /&gt;
For &amp;quot;view&amp;quot; pages you need to add the option include=&amp;gt;1 to the view configuration. This will cause generate_views to make a .include page in addition to the .html page. The .include page will have no template around it.&lt;br /&gt;
&lt;br /&gt;
For dynamic pages, those under /perl/, you can add the cgi parameter mainonly=yes&lt;br /&gt;
&lt;br /&gt;
eg.&lt;br /&gt;
&lt;br /&gt;
http://eprints.ecs.soton.ac.uk/perl/latest?mainonly=yes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I get statistics on number of deposits per month? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This rather grim bit of SQL should work, although datestamp is the last modified date, not the submission OR creation date, it should still give a good indication.&lt;br /&gt;
&lt;br /&gt;
select count(*),year(datestamp), month(datestamp) from archive group by year(datestamp),month(datestamp) order by year(datestamp),month(datestamp);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== I\&#039;ve edited the template (or other config file) but nothing seems to have changed - why? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See HowEPrintsGeneratesWebPages&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Installation Related Questions =&lt;br /&gt;
 &lt;br /&gt;
== What platforms will GNU EPrints run on? ==&lt;br /&gt;
&lt;br /&gt;
In theory any UNIX like platform: Linux, Solaris, BSD etc. even OSX! If you don&#039;t care then we recommend the RedHat Linux distribution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== When running a script I get the error; &amp;quot;Insecure dependency in mkdir while running with -T switch&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
This usually indicates you are running an eprints script as root. Don&#039;t do that; become user &#039;eprints&#039; instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Errors with import_subjects when installing Eprints 2.3.3 with MySQL? 4&lt;br /&gt;
MySQL? ==&lt;br /&gt;
&lt;br /&gt;
4 does not grant permission to create temporary tables with GRANT ALL. Do (at the mysql prompt): GRANT CREATE TEMPORARY TABLES ON archive_name.* TO eprints@localhost IDENTIFIED BY &amp;quot;*******&amp;quot;; Then do: mysqladmin -u root -p reload to reload the mysql security tables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== title and fulltext search returns no results, but date search does (EPrints 2.3) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The indexer daemon is probably not running or is not working correctly.&lt;br /&gt;
&lt;br /&gt;
Syntax error on line 39 of /opt/eprints2/archives/eprintsOfGoat/cfg/auto-apache.conf:&lt;br /&gt;
order takes one argument, &#039;allow,deny&#039;, &#039;deny,allow&#039;, or &#039;mutual-failure&#039; on restart of Apache after initial installation&lt;br /&gt;
&lt;br /&gt;
There is a small error in the auto-apache.conf file, there is a space between &#039;deny, allow&#039; on line 39, remove this space to stop this error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== I don\&#039;t want to give configure_archive my mysql root password. What is the alternative? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(instructions acurate as of EP 2.3.12)&lt;br /&gt;
&lt;br /&gt;
Run configure_archive but say &amp;quot;no&amp;quot; to &amp;quot;create the database?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Log into the mysql client as root:&lt;br /&gt;
&lt;br /&gt;
 % mysql -u root -p&lt;br /&gt;
 Enter password: &lt;br /&gt;
&lt;br /&gt;
(and enter your password)&lt;br /&gt;
&lt;br /&gt;
This example creates a database for archive &amp;quot;foo&amp;quot; with user &amp;quot;foouser&amp;quot; and password &amp;quot;foopass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These values should match the values you gave to configure_archive. You can check them in /opt/eprints2/archives/foo.xml&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; CREATE DATABASE foo;&lt;br /&gt;
 Query OK, 1 row affected (0.06 sec)&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; GRANT ALL ON foo.* TO foouser@localhost;&lt;br /&gt;
 Query OK, 0 rows affected (0.52 sec)&lt;br /&gt;
&lt;br /&gt;
The last bit depends if you are running on a MySQL? version equal of greater than 4.1&lt;br /&gt;
&lt;br /&gt;
4.1+:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = OLD_PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
pre 4.1:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
That&#039;s all configure_archive would have done.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  How do I get a value for a field of an eprint (without using any SQL)? ==&lt;br /&gt;
&lt;br /&gt;
(assuming the eprint is in the main archive, and has eprintid number 23)&lt;br /&gt;
&lt;br /&gt;
  my $ds = $session-&amp;gt;get_archive()-&amp;gt;get_dataset( &amp;quot;archive&amp;quot; );&lt;br /&gt;
  my $eprint = EPrints::EPrint?-&amp;gt;new( $session, 23, $ds );&lt;br /&gt;
  my $value = $eprint-&amp;gt;get_value( &#039;editors&#039; );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How can I get a utf8 string of the name of a subject, given its subjectid? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sub get_subject_name_string&lt;br /&gt;
  {&lt;br /&gt;
	my( $session, $subjectid ) = @_;&lt;br /&gt;
	my $subj = EPrints::Subject-&amp;gt;new( $session, $subjectid ); &lt;br /&gt;
	if( !defined $subj ) &lt;br /&gt;
	{&lt;br /&gt;
		return &amp;quot;errer, unknown subject: $subjectid&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	return EPrints::Utils::tree_to_utf8( $subj-&amp;gt;render_description() );&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using mod_perl2, pages with redirects (e.g. /perl/search) are blank. How do I fix this? ==&lt;br /&gt;
&lt;br /&gt;
In perl_lib/EPrints/Session.pm change&lt;br /&gt;
&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status_line( &amp;quot;302 Moved&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
to&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status(302);&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3952</id>
		<title>Frequently Asked Questions</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Frequently_Asked_Questions&amp;diff=3952"/>
		<updated>2007-02-13T23:25:02Z</updated>

		<summary type="html">&lt;p&gt;Sp: /* Is it possible when depositing a document, to just point to an &amp;quot;alternative location&amp;quot; rather than have the full text copied and held in the eprint archive? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This all needs sorting out, it&#039;s just being grabbed from the old wiki for now.&lt;br /&gt;
&lt;br /&gt;
* [[Copyright and License FAQ]]&lt;br /&gt;
* [[Metadata FAQ]]&lt;br /&gt;
* [[Searching FAQ]]&lt;br /&gt;
* [[OAI FAQ]]&lt;br /&gt;
* [[BOAI Self-Archiving FAQ]]&lt;br /&gt;
* [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== What operating systems can we use? ==&lt;br /&gt;
&lt;br /&gt;
EPrints should work on any UNIX operating system. We use Redhat Enterprise Linux. It will work on OSX but that takes a bit more effort. Please refer to the [http://www.eprints.org/documentation/handbook/osx.php Mac OS X Installation Guide] for more information&lt;br /&gt;
&lt;br /&gt;
It will not run under Microsoft Windows and we have no plan to change this.&lt;br /&gt;
&lt;br /&gt;
== What computer do we need? ==&lt;br /&gt;
&lt;br /&gt;
Any new PC is easily powerful enough. Suggested minimum spec. for a live service: 1gig RAM, 20gig Harddrive, 1GHz+ processor.&lt;br /&gt;
&lt;br /&gt;
== How much will it cost to set up? ==&lt;br /&gt;
&lt;br /&gt;
Most of the costs are staff time. Equipment costs are a PC, an internet connection and a BACKUP STRATEGY. Please remember to budget for backups.&lt;br /&gt;
&lt;br /&gt;
EPrints, and all the other software required to make it work, are available for no cost. At some point in the future EPrints may offer some pay-services, but the core software will remain zero cost and freely available to all.&lt;br /&gt;
&lt;br /&gt;
See [[How much will it cost?]]&lt;br /&gt;
&lt;br /&gt;
== How much diskspace will we need? ==&lt;br /&gt;
&lt;br /&gt;
Proabably about 2 megabytes per eprint. At the time of writing a 120GB drive costs 50 pounds. That drive would hold approximately 60000 eprints.&lt;br /&gt;
&lt;br /&gt;
See also: [[Detailed disk usage statistics]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Is it possible when depositing a document, to just point to an &amp;quot;alternative location&amp;quot; rather than have the full text copied and held in the eprint archive? ==&lt;br /&gt;
&lt;br /&gt;
Yes, just don&#039;t assign any value to required_formats in ArchiveConfigure?.pm, like so&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{required_formats} = [];&lt;br /&gt;
&lt;br /&gt;
If you are doing this it would also be clever to change the ArchiveRender routines so that on the abstract page &amp;quot;Full text available as&amp;quot; is replaced by &amp;quot;Full text available via &amp;lt;link to alternative location&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This keeps the key link to follow (to the full text) at the top of the screen.&lt;br /&gt;
&lt;br /&gt;
== I need to run apache as a user other than &amp;quot;eprints&amp;quot;, what do I do to make EPrints work in this situation? ==&lt;br /&gt;
&lt;br /&gt;
Example, apache is running as user &amp;quot;apache&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
    * Make all the eprints files owned by &amp;quot;apache&amp;quot; instead of &amp;quot;eprints&amp;quot;&lt;br /&gt;
    * Edit SystemSettings?.pm to tell eprints to run as user &amp;quot;apache&amp;quot;&lt;br /&gt;
    * You&#039;ll need to run all command line scripts as user &amp;quot;apache&amp;quot;&lt;br /&gt;
    * All eprints cron jobs should be owned by user &amp;quot;apache&amp;quot; &lt;br /&gt;
&lt;br /&gt;
If you are installing a new copy of eprints, you can specify the user and group to use when you run &#039;configure&#039;. Do&lt;br /&gt;
&lt;br /&gt;
 ./configure --help &lt;br /&gt;
&lt;br /&gt;
for details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I get the body HTML of a page without the template around it? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is handy for dymnamically linking eprints content into other sites.&lt;br /&gt;
&lt;br /&gt;
For &amp;quot;view&amp;quot; pages you need to add the option include=&amp;gt;1 to the view configuration. This will cause generate_views to make a .include page in addition to the .html page. The .include page will have no template around it.&lt;br /&gt;
&lt;br /&gt;
For dynamic pages, those under /perl/, you can add the cgi parameter mainonly=yes&lt;br /&gt;
&lt;br /&gt;
eg.&lt;br /&gt;
&lt;br /&gt;
http://eprints.ecs.soton.ac.uk/perl/latest?mainonly=yes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I get statistics on number of deposits per month? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This rather grim bit of SQL should work, although datestamp is the last modified date, not the submission OR creation date, it should still give a good indication.&lt;br /&gt;
&lt;br /&gt;
select count(*),year(datestamp), month(datestamp) from archive group by year(datestamp),month(datestamp) order by year(datestamp),month(datestamp);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== I\&#039;ve edited the template (or other config file) but nothing seems to have changed - why? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See HowEPrintsGeneratesWebPages&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Installation Related Questions =&lt;br /&gt;
 &lt;br /&gt;
== What platforms will GNU EPrints run on? ==&lt;br /&gt;
&lt;br /&gt;
In theory any UNIX like platform: Linux, Solaris, BSD etc. even OSX! If you don&#039;t care then we recommend the RedHat Linux distribution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== When running a script I get the error; &amp;quot;Insecure dependency in mkdir while running with -T switch&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
This usually indicates you are running an eprints script as root. Don&#039;t do that; become user &#039;eprints&#039; instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Errors with import_subjects when installing Eprints 2.3.3 with MySQL? 4&lt;br /&gt;
MySQL? ==&lt;br /&gt;
&lt;br /&gt;
4 does not grant permission to create temporary tables with GRANT ALL. Do (at the mysql prompt): GRANT CREATE TEMPORARY TABLES ON archive_name.* TO eprints@localhost IDENTIFIED BY &amp;quot;*******&amp;quot;; Then do: mysqladmin -u root -p reload to reload the mysql security tables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== title and fulltext search returns no results, but date search does (EPrints 2.3) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The indexer daemon is probably not running or is not working correctly.&lt;br /&gt;
&lt;br /&gt;
Syntax error on line 39 of /opt/eprints2/archives/eprintsOfGoat/cfg/auto-apache.conf:&lt;br /&gt;
order takes one argument, &#039;allow,deny&#039;, &#039;deny,allow&#039;, or &#039;mutual-failure&#039; on restart of Apache after initial installation&lt;br /&gt;
&lt;br /&gt;
There is a small error in the auto-apache.conf file, there is a space between &#039;deny, allow&#039; on line 39, remove this space to stop this error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== I don\&#039;t want to give configure_archive my mysql root password. What is the alternative? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(instructions acurate as of EP 2.3.12)&lt;br /&gt;
&lt;br /&gt;
Run configure_archive but say &amp;quot;no&amp;quot; to &amp;quot;create the database?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Log into the mysql client as root:&lt;br /&gt;
&lt;br /&gt;
 % mysql -u root -p&lt;br /&gt;
 Enter password: &lt;br /&gt;
&lt;br /&gt;
(and enter your password)&lt;br /&gt;
&lt;br /&gt;
This example creates a database for archive &amp;quot;foo&amp;quot; with user &amp;quot;foouser&amp;quot; and password &amp;quot;foopass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These values should match the values you gave to configure_archive. You can check them in /opt/eprints2/archives/foo.xml&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; CREATE DATABASE foo;&lt;br /&gt;
 Query OK, 1 row affected (0.06 sec)&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; GRANT ALL ON foo.* TO foouser@localhost;&lt;br /&gt;
 Query OK, 0 rows affected (0.52 sec)&lt;br /&gt;
&lt;br /&gt;
The last bit depends if you are running on a MySQL? version equal of greater than 4.1&lt;br /&gt;
&lt;br /&gt;
4.1+:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = OLD_PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
pre 4.1:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR foouser@localhost = PASSWORD(&amp;quot;foopass&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
That&#039;s all configure_archive would have done.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  How do I get a value for a field of an eprint (without using any SQL)? ==&lt;br /&gt;
&lt;br /&gt;
(assuming the eprint is in the main archive, and has eprintid number 23)&lt;br /&gt;
&lt;br /&gt;
  my $ds = $session-&amp;gt;get_archive()-&amp;gt;get_dataset( &amp;quot;archive&amp;quot; );&lt;br /&gt;
  my $eprint = EPrints::EPrint?-&amp;gt;new( $session, 23, $ds );&lt;br /&gt;
  my $value = $eprint-&amp;gt;get_value( &#039;editors&#039; );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How can I get a utf8 string of the name of a subject, given its subjectid? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sub get_subject_name_string&lt;br /&gt;
  {&lt;br /&gt;
	my( $session, $subjectid ) = @_;&lt;br /&gt;
	my $subj = EPrints::Subject-&amp;gt;new( $session, $subjectid ); &lt;br /&gt;
	if( !defined $subj ) &lt;br /&gt;
	{&lt;br /&gt;
		return &amp;quot;errer, unknown subject: $subjectid&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	return EPrints::Utils::tree_to_utf8( $subj-&amp;gt;render_description() );&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using mod_perl2, pages with redirects (e.g. /perl/search) are blank. How do I fix this? ==&lt;br /&gt;
&lt;br /&gt;
In perl_lib/EPrints/Session.pm change&lt;br /&gt;
&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status_line( &amp;quot;302 Moved&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
to&lt;br /&gt;
       $self-&amp;gt;{&amp;quot;request&amp;quot;}-&amp;gt;status(302);&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=User:Sp&amp;diff=3948</id>
		<title>User:Sp</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=User:Sp&amp;diff=3948"/>
		<updated>2007-02-13T22:56:22Z</updated>

		<summary type="html">&lt;p&gt;Sp: whoami&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;UNIX Sysadmin&amp;lt;br&amp;gt;&lt;br /&gt;
University of Vienna, Austria&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
	<entry>
		<id>https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Installation&amp;diff=3947</id>
		<title>Installation</title>
		<link rel="alternate" type="text/html" href="https://wiki.ext-9.eprints-hosting.org/w/index.php?title=Installation&amp;diff=3947"/>
		<updated>2007-02-13T22:53:48Z</updated>

		<summary type="html">&lt;p&gt;Sp: formatting, apache.conf needs to be generated first&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{development}}&lt;br /&gt;
{{manual}}&lt;br /&gt;
==Installation==&lt;br /&gt;
(If you are upgrading an existing installation of eprints please see the section on upgrading elsewhere in this manual.)&lt;br /&gt;
&lt;br /&gt;
EPrints needs to be installed as the same user as the apache webserver runs as. We suggest you install it as user &amp;quot;eprints&amp;quot; and group &amp;quot;eprints&amp;quot;. Under some UNIX platforms, creating a user and group can be done using the &amp;quot;adduser&amp;quot; command. Otherwise refer to your operating system documentation.&lt;br /&gt;
&lt;br /&gt;
Unpack the eprints tar.gz file:&lt;br /&gt;
&lt;br /&gt;
 % gunzip eprints-3.something.tar.gz&lt;br /&gt;
 % tar xf eprints-3.something.tar&lt;br /&gt;
&lt;br /&gt;
Now run the &amp;quot;configure&amp;quot; script. This is a /bin/sh script which will attempt to locate various parts of your system such as the perl binary. It will also check your system for required components.&lt;br /&gt;
&lt;br /&gt;
 % cd eprints-3.something&lt;br /&gt;
 % ./configure&lt;br /&gt;
&lt;br /&gt;
By default the system installs as user and group &amp;quot;eprints&amp;quot;. You will need to change this if you are not installing as either &amp;quot;root&amp;quot; or &amp;quot;eprints&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The configure script accepts a number of options. All are optional. The most important are:&lt;br /&gt;
&lt;br /&gt;
; --help : List all the options (many are intended for compiled software and are ignored).&lt;br /&gt;
; --prefix=PREFIX : Where to install EPrints (or look for a version to upgrade). By default /opt/eprints3/&lt;br /&gt;
; --with-perl=[PATH] : Path of perl interpreter (in case configure can&#039;t find it, or you have more than one and want to use a specific one).&lt;br /&gt;
; --with-user=[USER] : Install eprints to run as USER. By default &amp;quot;eprints&amp;quot;.&lt;br /&gt;
; --with-group=[GROUP] : Install eprints to run as GROUP. By default &amp;quot;eprints&amp;quot;.&lt;br /&gt;
; --with-virtualhost=[VIRTUALHOST] : Use VIRTUALHOST rather than * for apache VirtualHost directives.&lt;br /&gt;
; --disable-diskfree : Disable disk free space calls. This will be automatically set if configure fails its tests for the df call.&lt;br /&gt;
; --with-toolpath=[PATH] : An alternate path to search for the required binaries.&lt;br /&gt;
&lt;br /&gt;
Once you are happy with your configuration you may install eprints by running install.pl:&lt;br /&gt;
&lt;br /&gt;
 % ./install.pl&lt;br /&gt;
&lt;br /&gt;
Now you should edit the configuration file for your copy of apache. This is often &amp;lt;tt&amp;gt;/usr/local/apache/conf/http.conf&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/httpd/conf/httpd.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this line: (If you didn&#039;t install eprints in &amp;lt;tt&amp;gt;/opt/eprints3/&amp;lt;/tt&amp;gt; replace that with the location on your system).&lt;br /&gt;
 Include /opt/eprints3/cfg/apache.conf&lt;br /&gt;
Note that this file is only available after you created your archive via &amp;lt;tt&amp;gt;epadmin create&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You may also wish to change the user and group apache runs as. The user &#039;&#039;must&#039;&#039; be the same as the user you installed eprints as. We recommend:&lt;br /&gt;
&lt;br /&gt;
 User eprints&lt;br /&gt;
 Group eprints&lt;/div&gt;</summary>
		<author><name>Sp</name></author>
	</entry>
</feed>