Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Taiko Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Taiko Web
Commits
1e7477dd
Commit
1e7477dd
authored
Mar 17, 2020
by
Bui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
anti-csrf
parent
873bd1a7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
2 deletions
+8
-2
app.py
app.py
+3
-1
public/src/js/account.js
public/src/js/account.js
+1
-0
templates/admin_song_detail.html
templates/admin_song_detail.html
+2
-0
templates/admin_song_new.html
templates/admin_song_new.html
+2
-1
No files found.
app.py
View file @
1e7477dd
...
@@ -14,6 +14,7 @@ from functools import wraps
...
@@ -14,6 +14,7 @@ from functools import wraps
from
flask
import
Flask
,
g
,
jsonify
,
render_template
,
request
,
abort
,
redirect
,
session
,
flash
from
flask
import
Flask
,
g
,
jsonify
,
render_template
,
request
,
abort
,
redirect
,
session
,
flash
from
flask_caching
import
Cache
from
flask_caching
import
Cache
from
flask_session
import
Session
from
flask_session
import
Session
from
flask_wtf.csrf
import
CSRFProtect
,
generate_csrf
from
ffmpy
import
FFmpeg
from
ffmpy
import
FFmpeg
from
pymongo
import
MongoClient
from
pymongo
import
MongoClient
...
@@ -26,6 +27,7 @@ app.config['SESSION_COOKIE_HTTPONLY'] = False
...
@@ -26,6 +27,7 @@ app.config['SESSION_COOKIE_HTTPONLY'] = False
app
.
cache
=
Cache
(
app
,
config
=
config
.
REDIS
)
app
.
cache
=
Cache
(
app
,
config
=
config
.
REDIS
)
sess
=
Session
()
sess
=
Session
()
sess
.
init_app
(
app
)
sess
.
init_app
(
app
)
csrf
=
CSRFProtect
(
app
)
db
=
client
[
config
.
MONGO
[
'database'
]]
db
=
client
[
config
.
MONGO
[
'database'
]]
db
.
users
.
create_index
(
'username'
,
unique
=
True
)
db
.
users
.
create_index
(
'username'
,
unique
=
True
)
...
@@ -106,6 +108,7 @@ def get_config():
...
@@ -106,6 +108,7 @@ def get_config():
config_out
[
'assets_baseurl'
]
=
''
.
join
([
request
.
host_url
,
'assets'
])
+
'/'
config_out
[
'assets_baseurl'
]
=
''
.
join
([
request
.
host_url
,
'assets'
])
+
'/'
config_out
[
'_version'
]
=
get_version
()
config_out
[
'_version'
]
=
get_version
()
config_out
[
'_csrf_token'
]
=
generate_csrf
()
return
config_out
return
config_out
...
@@ -126,7 +129,6 @@ def get_version():
...
@@ -126,7 +129,6 @@ def get_version():
@
app
.
route
(
'/'
)
@
app
.
route
(
'/'
)
@
app
.
cache
.
cached
(
timeout
=
15
)
def
route_index
():
def
route_index
():
version
=
get_version
()
version
=
get_version
()
return
render_template
(
'index.html'
,
version
=
version
,
config
=
get_config
())
return
render_template
(
'index.html'
,
version
=
version
,
config
=
get_config
())
...
...
public/src/js/account.js
View file @
1e7477dd
...
@@ -423,6 +423,7 @@ class Account{
...
@@ -423,6 +423,7 @@ class Account{
})
})
if
(
obj
){
if
(
obj
){
request
.
setRequestHeader
(
"
Content-Type
"
,
"
application/json;charset=UTF-8
"
)
request
.
setRequestHeader
(
"
Content-Type
"
,
"
application/json;charset=UTF-8
"
)
request
.
setRequestHeader
(
"
X-CSRFToken
"
,
gameConfig
.
_csrf_token
)
request
.
send
(
JSON
.
stringify
(
obj
))
request
.
send
(
JSON
.
stringify
(
obj
))
}
else
{
}
else
{
request
.
send
()
request
.
send
()
...
...
templates/admin_song_detail.html
View file @
1e7477dd
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
{% endfor %}
{% endfor %}
<div
class=
"song-form"
>
<div
class=
"song-form"
>
<form
method=
"post"
>
<form
method=
"post"
>
<input
type=
"hidden"
name=
"csrf_token"
value=
"{{ csrf_token() }}"
>
<div
class=
"form-field"
>
<div
class=
"form-field"
>
<span
class=
"checkbox"
><input
type=
"checkbox"
name=
"enabled"
id=
"enabled"
{%
if
song
.
enabled
%}
checked
{%
endif
%}{%
if
admin
.
user_level
<
100
%}
disabled
{%
endif
%}
><label
for=
"enabled"
>
Enabled
</label></span>
<span
class=
"checkbox"
><input
type=
"checkbox"
name=
"enabled"
id=
"enabled"
{%
if
song
.
enabled
%}
checked
{%
endif
%}{%
if
admin
.
user_level
<
100
%}
disabled
{%
endif
%}
><label
for=
"enabled"
>
Enabled
</label></span>
...
@@ -124,6 +125,7 @@
...
@@ -124,6 +125,7 @@
</form>
</form>
{% if admin.user_level >= 100 %}
{% if admin.user_level >= 100 %}
<form
class=
"delete-song"
method=
"post"
action=
"/admin/songs/{{song.id}}/delete"
onsubmit=
"return confirm('Are you sure you wish to delete this song?');"
>
<form
class=
"delete-song"
method=
"post"
action=
"/admin/songs/{{song.id}}/delete"
onsubmit=
"return confirm('Are you sure you wish to delete this song?');"
>
<input
type=
"hidden"
name=
"csrf_token"
value=
"{{ csrf_token() }}"
>
<button
type=
"submit"
>
Delete song
</button>
<button
type=
"submit"
>
Delete song
</button>
</form>
</form>
{% endif %}
{% endif %}
...
...
templates/admin_song_new.html
View file @
1e7477dd
...
@@ -6,9 +6,10 @@
...
@@ -6,9 +6,10 @@
{% endfor %}
{% endfor %}
<div
class=
"song-form"
>
<div
class=
"song-form"
>
<form
method=
"post"
>
<form
method=
"post"
>
<input
type=
"hidden"
name=
"csrf_token"
value=
"{{ csrf_token() }}"
>
<div
class=
"form-field"
>
<div
class=
"form-field"
>
<span
class=
"checkbox"
><input
type=
"checkbox"
name=
"enabled"
id=
"enabled"
checked
><label
for=
"enabled"
>
Enabled
</label></span>
<span
class=
"checkbox"
><input
type=
"checkbox"
name=
"enabled"
id=
"enabled"
><label
for=
"enabled"
>
Enabled
</label></span>
</div>
</div>
<div
class=
"form-field"
>
<div
class=
"form-field"
>
...
...
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