Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
8f4c4449
Commit
8f4c4449
authored
Apr 27, 2016
by
Cervinko Cera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add basic auth for feed sites
parent
f66d7ce2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
web.py
cps/web.py
+11
-10
No files found.
cps/web.py
View file @
8f4c4449
...
@@ -96,12 +96,13 @@ def authenticate():
...
@@ -96,12 +96,13 @@ def authenticate():
'You have to login with proper credentials'
,
401
,
'You have to login with proper credentials'
,
401
,
{
'WWW-Authenticate'
:
'Basic realm="Login Required"'
})
{
'WWW-Authenticate'
:
'Basic realm="Login Required"'
})
def
requires_basic_auth
(
f
):
def
requires_basic_auth
_if_no_ano
(
f
):
@
wraps
(
f
)
@
wraps
(
f
)
def
decorated
(
*
args
,
**
kwargs
):
def
decorated
(
*
args
,
**
kwargs
):
auth
=
request
.
authorization
auth
=
request
.
authorization
if
not
auth
or
not
check_auth
(
auth
.
username
,
auth
.
password
):
if
config
.
ANO_SHOW_BOOKS
!=
1
:
return
authenticate
()
if
not
auth
or
not
check_auth
(
auth
.
username
,
auth
.
password
):
return
authenticate
()
return
f
(
*
args
,
**
kwargs
)
return
f
(
*
args
,
**
kwargs
)
return
decorated
return
decorated
...
@@ -201,7 +202,7 @@ def before_request():
...
@@ -201,7 +202,7 @@ def before_request():
g
.
allow_upload
=
config
.
UPLOADING
g
.
allow_upload
=
config
.
UPLOADING
@
app
.
route
(
"/feed"
)
@
app
.
route
(
"/feed"
)
@
login_required
_if_no_ano
@
requires_basic_auth
_if_no_ano
def
feed_index
():
def
feed_index
():
xml
=
render_template
(
'index.xml'
)
xml
=
render_template
(
'index.xml'
)
response
=
make_response
(
xml
)
response
=
make_response
(
xml
)
...
@@ -209,7 +210,7 @@ def feed_index():
...
@@ -209,7 +210,7 @@ def feed_index():
return
response
return
response
@
app
.
route
(
"/feed/osd"
)
@
app
.
route
(
"/feed/osd"
)
@
login_required
_if_no_ano
@
requires_basic_auth
_if_no_ano
def
feed_osd
():
def
feed_osd
():
xml
=
render_template
(
'osd.xml'
)
xml
=
render_template
(
'osd.xml'
)
response
=
make_response
(
xml
)
response
=
make_response
(
xml
)
...
@@ -217,7 +218,7 @@ def feed_osd():
...
@@ -217,7 +218,7 @@ def feed_osd():
return
response
return
response
@
app
.
route
(
"/feed/search"
,
methods
=
[
"GET"
])
@
app
.
route
(
"/feed/search"
,
methods
=
[
"GET"
])
@
login_required
_if_no_ano
@
requires_basic_auth
_if_no_ano
def
feed_search
():
def
feed_search
():
term
=
request
.
args
.
get
(
"query"
)
term
=
request
.
args
.
get
(
"query"
)
if
term
:
if
term
:
...
@@ -231,7 +232,7 @@ def feed_search():
...
@@ -231,7 +232,7 @@ def feed_search():
return
response
return
response
@
app
.
route
(
"/feed/new"
)
@
app
.
route
(
"/feed/new"
)
@
login_required
_if_no_ano
@
requires_basic_auth
_if_no_ano
def
feed_new
():
def
feed_new
():
off
=
request
.
args
.
get
(
"start_index"
)
off
=
request
.
args
.
get
(
"start_index"
)
if
off
:
if
off
:
...
@@ -246,7 +247,7 @@ def feed_new():
...
@@ -246,7 +247,7 @@ def feed_new():
@
app
.
route
(
"/feed/discover"
)
@
app
.
route
(
"/feed/discover"
)
@
login_required
_if_no_ano
@
requires_basic_auth
_if_no_ano
def
feed_discover
():
def
feed_discover
():
off
=
request
.
args
.
get
(
"start_index"
)
off
=
request
.
args
.
get
(
"start_index"
)
if
off
:
if
off
:
...
@@ -260,7 +261,7 @@ def feed_discover():
...
@@ -260,7 +261,7 @@ def feed_discover():
return
response
return
response
@
app
.
route
(
"/feed/hot"
)
@
app
.
route
(
"/feed/hot"
)
@
login_required
_if_no_ano
@
requires_basic_auth
_if_no_ano
def
feed_hot
():
def
feed_hot
():
off
=
request
.
args
.
get
(
"start_index"
)
off
=
request
.
args
.
get
(
"start_index"
)
if
off
:
if
off
:
...
@@ -275,7 +276,7 @@ def feed_hot():
...
@@ -275,7 +276,7 @@ def feed_hot():
return
response
return
response
@
app
.
route
(
"/feed/download/<int:book_id>/<format>"
)
@
app
.
route
(
"/feed/download/<int:book_id>/<format>"
)
@
login_required
@
requires_basic_auth_if_no_ano
@
download_required
@
download_required
def
get_opds_download_link
(
book_id
,
format
):
def
get_opds_download_link
(
book_id
,
format
):
format
=
format
.
split
(
"."
)[
0
]
format
=
format
.
split
(
"."
)[
0
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment