mirror of
https://github.com/standardebooks/web.git
synced 2025-07-16 11:26:37 -04:00
Create cookie-based login and authentication system
This commit is contained in:
parent
45221365b5
commit
0bc3dc3830
46 changed files with 528 additions and 195 deletions
|
@ -245,7 +245,7 @@ Define webroot /standardebooks.org/web
|
|||
RewriteRule ^/images/covers/(.+?)\-[a-z0-9]{8}\-(cover|hero)(@2x)?\.(jpg|avif)$ /images/covers/$1-$2$3.$4
|
||||
|
||||
RewriteRule ^/ebooks/([^\./]+?)$ /ebooks/author.php?url-path=$1 [QSA]
|
||||
RewriteRule ^/ebooks/([^\./]+?)/downloads$ /bulk-downloads/get.php?author=$1 [QSA]
|
||||
RewriteRule ^/ebooks/([^\./]+?)/downloads$ /bulk-downloads/get.php?author=$1 [QSA]
|
||||
RewriteRule ^/subjects/([^\./]+?)$ /ebooks/index.php?tags[]=$1 [QSA]
|
||||
RewriteRule ^/collections/([^\./]+?)$ /ebooks/index.php?collection=$1 [QSA]
|
||||
RewriteRule ^/collections/([^/]+?)/downloads$ /bulk-downloads/get.php?collection=$1
|
||||
|
@ -279,14 +279,14 @@ Define webroot /standardebooks.org/web
|
|||
RewriteCond %{QUERY_STRING} \bquery=
|
||||
RewriteRule ^/feeds/(opds|atom|rss)/all.xml$ /feeds/$1/search.php [QSA]
|
||||
|
||||
# Rewrite rules for bulk downloads
|
||||
RewriteRule ^/bulk-downloads/(.+\.zip)$ /bulk-downloads/download.php?path=$1
|
||||
|
||||
# Enable mod_authn_dbd
|
||||
DBDriver mysql
|
||||
DBDParams "dbname=se user=www-data"
|
||||
# HTTP Basic Auth configuration for:
|
||||
# /bulk-downloads
|
||||
# /feeds
|
||||
# /polls/votes (we will allow access to view results at /polls/votes/index.php further down)
|
||||
<DirectoryMatch "^${webroot}/www/(polls/votes|bulk-downloads|feeds/(opds|rss|atom))">
|
||||
# HTTP Basic Auth configuration for /feeds
|
||||
<DirectoryMatch "^${webroot}/www/feeds/(opds|rss|atom)">
|
||||
AuthType Basic
|
||||
AuthName "Enter your Patrons Circle email address and leave the password empty."
|
||||
Require valid-user
|
||||
|
@ -300,34 +300,14 @@ Define webroot /standardebooks.org/web
|
|||
# The hash is simply the hash of a blank password. We're only interested in the username/API key.
|
||||
# We have to do this tortured query instead of a cleaner one, because the AuthDBDUserPWQuery
|
||||
# function will only replace %s EXACTLY ONCE. We cannot have more than one %s in the query string.
|
||||
AuthDBDUserPWQuery "\
|
||||
select '$apr1$13q1pnGf$vQnIj94BXP1EPdL/4ISba.' from \
|
||||
( \
|
||||
select Email, Uuid from Patrons p inner join Users u using (UserId) where p.Ended is null \
|
||||
union \
|
||||
select Email, Uuid from ApiKeys fu inner join Users u using (UserId) where fu.Ended is null \
|
||||
) x where %s in (Email, Uuid) limit 1 \
|
||||
"
|
||||
AuthDBDUserPWQuery "select '$apr1$13q1pnGf$vQnIj94BXP1EPdL/4ISba.' from Users u inner join Benefits b using (UserId) where %s in (u.Email, u.Uuid) and b.CanAccessFeeds = true limit 1"
|
||||
</DirectoryMatch>
|
||||
|
||||
# Specific config for /bulk-downloads
|
||||
<DirectoryMatch "^${webroot}/www/bulk-downloads">
|
||||
<FilesMatch "\.php$">
|
||||
# Disable HTTP Basic auth for the index and 401 pages
|
||||
Require all granted
|
||||
</FilesMatch>
|
||||
|
||||
<FilesMatch "\.zip$">
|
||||
ErrorDocument 401 /bulk-downloads
|
||||
</FilesMatch>
|
||||
</DirectoryMatch>
|
||||
|
||||
# Specific config for /polls/votes
|
||||
<DirectoryMatch "^${webroot}/www/polls/votes">
|
||||
<FilesMatch "index.php$">
|
||||
# Disable HTTP Basic auth for the index page
|
||||
Require all granted
|
||||
</FilesMatch>
|
||||
<DirectoryMatch "${webroot}/www/bulk-downloads">
|
||||
# Both directives are required
|
||||
XSendFile on
|
||||
XSendFilePath /standardebooks.org/web/www/bulk-downloads
|
||||
</DirectoryMatch>
|
||||
|
||||
# Specific config for /feeds
|
||||
|
|
|
@ -227,7 +227,7 @@ Define webroot /standardebooks.org/web
|
|||
RewriteRule ^/images/covers/(.+?)\-[a-z0-9]{8}\-(cover|hero)(@2x)?\.(jpg|avif)$ /images/covers/$1-$2$3.$4
|
||||
|
||||
RewriteRule ^/ebooks/([^\./]+?)$ /ebooks/author.php?url-path=$1 [QSA]
|
||||
RewriteRule ^/ebooks/([^\./]+?)/downloads$ /bulk-downloads/get.php?author=$1 [QSA]
|
||||
RewriteRule ^/ebooks/([^\./]+?)/downloads$ /bulk-downloads/get.php?author=$1 [QSA]
|
||||
RewriteRule ^/subjects/([^\./]+?)$ /ebooks/index.php?tags[]=$1 [QSA]
|
||||
RewriteRule ^/collections/([^\./]+?)$ /ebooks/index.php?collection=$1 [QSA]
|
||||
RewriteRule ^/collections/([^/]+?)/downloads$ /bulk-downloads/get.php?collection=$1
|
||||
|
@ -261,14 +261,14 @@ Define webroot /standardebooks.org/web
|
|||
RewriteCond %{QUERY_STRING} \bquery=
|
||||
RewriteRule ^/feeds/(opds|atom|rss)/all.xml$ /feeds/$1/search.php [QSA]
|
||||
|
||||
# Rewrite rules for bulk downloads
|
||||
RewriteRule ^/bulk-downloads/(.+\.zip)$ /bulk-downloads/download.php?path=$1
|
||||
|
||||
# Enable mod_authn_dbd
|
||||
DBDriver mysql
|
||||
DBDParams "dbname=se user=www-data"
|
||||
# HTTP Basic Auth configuration for:
|
||||
# /bulk-downloads
|
||||
# /feeds
|
||||
# /polls/votes (we will allow access to view results at /polls/votes/index.php further down)
|
||||
<DirectoryMatch "^${webroot}/www/(polls/votes|bulk-downloads|feeds/(opds|rss|atom))">
|
||||
# HTTP Basic Auth configuration for /feeds
|
||||
<DirectoryMatch "^${webroot}/www/feeds/(opds|rss|atom)">
|
||||
AuthType Basic
|
||||
AuthName "Enter your Patrons Circle email address and leave the password empty."
|
||||
Require valid-user
|
||||
|
@ -282,34 +282,14 @@ Define webroot /standardebooks.org/web
|
|||
# The hash is simply the hash of a blank password. We're only interested in the username/API key.
|
||||
# We have to do this tortured query instead of a cleaner one, because the AuthDBDUserPWQuery
|
||||
# function will only replace %s EXACTLY ONCE. We cannot have more than one %s in the query string.
|
||||
AuthDBDUserPWQuery "\
|
||||
select '$apr1$13q1pnGf$vQnIj94BXP1EPdL/4ISba.' from \
|
||||
( \
|
||||
select Email, Uuid from Patrons p inner join Users u using (UserId) where p.Ended is null \
|
||||
union \
|
||||
select Email, Uuid from ApiKeys fu inner join Users u using (UserId) where fu.Ended is null \
|
||||
) x where %s in (Email, Uuid) limit 1 \
|
||||
"
|
||||
AuthDBDUserPWQuery "select '$apr1$13q1pnGf$vQnIj94BXP1EPdL/4ISba.' from Users u inner join Benefits b using (UserId) where %s in (u.Email, u.Uuid) and b.CanAccessFeeds = true limit 1"
|
||||
</DirectoryMatch>
|
||||
|
||||
# Specific config for /bulk-downloads
|
||||
<DirectoryMatch "^${webroot}/www/bulk-downloads">
|
||||
<FilesMatch "\.php$">
|
||||
# Disable HTTP Basic auth for the index and 401 pages
|
||||
Require all granted
|
||||
</FilesMatch>
|
||||
|
||||
<FilesMatch "\.zip$">
|
||||
ErrorDocument 401 /bulk-downloads
|
||||
</FilesMatch>
|
||||
</DirectoryMatch>
|
||||
|
||||
# Specific config for /polls/votes
|
||||
<DirectoryMatch "^${webroot}/www/polls/votes">
|
||||
<FilesMatch "index.php$">
|
||||
# Disable HTTP Basic auth for the index page
|
||||
Require all granted
|
||||
</FilesMatch>
|
||||
<DirectoryMatch "${webroot}/www/bulk-downloads">
|
||||
# Both directives are required
|
||||
XSendFile on
|
||||
XSendFilePath /standardebooks.org/web/www/bulk-downloads
|
||||
</DirectoryMatch>
|
||||
|
||||
# Specific config for /feeds
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue