Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
I
IA-Short
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
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
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
WWW
IA-Short
Commits
756ebdeb
Commit
756ebdeb
authored
Feb 24, 2019
by
132ikl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add redir_url config option and enforce admin password to start
parent
e8a56524
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
config.yml
config.yml
+7
-0
liteshort.py
liteshort.py
+6
-5
No files found.
config.yml
View file @
756ebdeb
...
...
@@ -44,9 +44,16 @@ site_name: 'liteshort'
# String: URL shown when finished generating shortlinks. Include the / at the end.
# If not set, it is automatically taken from the URL the shorten request is sent to.
# If you don't know, leave unset
# Default: unset
site_url
:
# String: URL to redirect to when link not found. Useful if using a reverse proxy with a subdomain for liteshort
# If not set, it is automatically taken from the base URL
# If you don't know, leave unset
# Default: unset
redir_url
:
# Boolean: Show link to project repository on GitHub at bottom right corner of page
# Default: true
show_github_link
:
true
liteshort.py
View file @
756ebdeb
...
...
@@ -21,13 +21,13 @@ def load_config():
req_options
=
{
'admin_username'
:
'admin'
,
'database_name'
:
"urls"
,
'random_length'
:
4
,
'allowed_chars'
:
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'
,
'random_gen_timeout'
:
5
,
'site_name'
:
'liteshort'
,
'site_url'
:
None
,
'show_github_link'
:
True
,
'secret_key'
:
None
,
'disable_api'
:
False
'secret_key'
:
None
,
'disable_api'
:
False
,
'redir_url'
:
None
}
config_types
=
{
'admin_username'
:
str
,
'database_name'
:
str
,
'random_length'
:
int
,
'allowed_chars'
:
str
,
'random_gen_timeout'
:
int
,
'site_name'
:
str
,
'site_url'
:
(
str
,
type
(
None
)),
'show_github_link'
:
bool
,
'secret_key'
:
str
,
'disable_api'
:
bool
'disable_api'
:
bool
,
'redir_url'
:
(
str
,
type
(
None
))
}
for
option
in
req_options
.
keys
():
...
...
@@ -45,9 +45,9 @@ def load_config():
if
not
matches
:
raise
TypeError
(
option
+
" is incorrect type"
)
if
not
new_config
[
'disable_api'
]:
if
'admin_hashed_password'
in
new_config
.
keys
()
:
# Sets config value to see if bcrypt is required to check password
if
'admin_hashed_password'
in
new_config
.
keys
()
and
new_config
[
'admin_hashed_password'
]:
new_config
[
'password_hashed'
]
=
True
elif
'admin_password'
in
new_config
.
keys
():
elif
'admin_password'
in
new_config
.
keys
()
and
new_config
[
'admin_password'
]
:
new_config
[
'password_hashed'
]
=
False
else
:
raise
TypeError
(
'admin_password or admin_hashed_password must be set in config.yml'
)
...
...
@@ -203,7 +203,8 @@ def main_redir(url):
if
long
:
return
redirect
(
long
,
301
)
flash
(
'Short URL "'
+
url
+
'" doesn
\'
t exist'
,
'error'
)
return
redirect
(
url_for
(
'main'
))
redirect_site
=
(
current_app
.
config
[
'redir_url'
]
or
url_for
(
'main'
))
return
redirect
(
redirect_site
)
@
app
.
route
(
'/'
,
methods
=
[
'POST'
])
...
...
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