Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
7080efcb
Commit
7080efcb
authored
Apr 18, 2015
by
Paul Pacheco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create admin with a random password: Makes secure_db.py obsolete, and it is db independent
parent
e7ec1075
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
59 deletions
+15
-59
openshift/install.sh
openshift/install.sh
+0
-4
openshift/secure_db.py
openshift/secure_db.py
+0
-52
weblate/accounts/management/commands/createadmin.py
weblate/accounts/management/commands/createadmin.py
+15
-3
No files found.
openshift/install.sh
View file @
7080efcb
...
...
@@ -96,10 +96,6 @@ sh "python ${OPENSHIFT_REPO_DIR}/openshift/manage.py collectstatic --noinput"
if
[
!
-s
$OPENSHIFT_DATA_DIR
/.credentials
]
;
then
echo
"Generating Weblate admin credentials and writing them to
${
OPENSHIFT_DATA_DIR
}
/.credentials"
sh
"python
${
OPENSHIFT_REPO_DIR
}
/openshift/manage.py createadmin"
|
tee
${
OPENSHIFT_DATA_DIR
}
/.credentials
if
[
!
-s
$OPENSHIFT_DATA_DIR
/weblate.db
]
;
then
DJANGO_SETTINGS_MODULE
=
'weblate.settings_openshift'
sh
"python
${
OPENSHIFT_REPO_DIR
}
/openshift/secure_db.py | tee
${
OPENSHIFT_DATA_DIR
}
/.credentials"
fi
fi
if
find_script_dir
;
then
...
...
openshift/secure_db.py
deleted
100755 → 0
View file @
e7ec1075
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright © 2014 Daniel Tschan <tschan@puzzle.ch>
#
# This file is part of Weblate <http://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import
os
import
sqlite3
from
openshift.openshiftlibs
import
make_secure_key
,
get_openshift_secret_token
from
hashlib
import
sha256
from
django.contrib.auth.hashers
import
make_password
def
secure_db
():
new_pass
=
make_secure_key
({
'hash'
:
sha256
(
get_openshift_secret_token
()).
hexdigest
(),
'original'
:
'0'
*
12
,
'variable'
:
''
})
new_hash
=
make_password
(
new_pass
)
# Update admin password in database
conn
=
sqlite3
.
connect
(
os
.
environ
[
'OPENSHIFT_DATA_DIR'
]
+
'/weblate.db'
)
cursor
=
conn
.
cursor
()
cursor
.
execute
(
'UPDATE AUTH_USER SET password = ? WHERE username = ?'
,
[
new_hash
,
'admin'
]
)
conn
.
commit
()
cursor
.
close
()
conn
.
close
()
# Print the new password info
print
"Weblate admin credentials:
\
n
\
t
user: admin
\
n
\
t
password: "
+
new_pass
if
__name__
==
"__main__"
:
secure_db
()
weblate/accounts/management/commands/createadmin.py
View file @
7080efcb
...
...
@@ -20,11 +20,19 @@
from
django.core.management.base
import
BaseCommand
from
django.contrib.auth.models
import
User
import
string
import
os
import
random
class
Command
(
BaseCommand
):
help
=
'setups admin user with admin password (INSECURE!)'
def
make_password
(
self
,
length
)
:
chars
=
string
.
ascii_letters
+
string
.
digits
+
'!@#$%^&*()'
random
.
seed
=
(
os
.
urandom
(
1024
))
return
''
.
join
(
random
.
choice
(
chars
)
for
i
in
range
(
length
))
def
handle
(
self
,
*
args
,
**
options
):
'''
Create admin account with admin password.
...
...
@@ -32,9 +40,13 @@ class Command(BaseCommand):
This is useful mostly for setup inside appliances, when user wants
to be able to login remotely and change password then.
'''
self
.
stderr
.
write
(
'Warning: Creating user admin with password admin!'
)
self
.
stderr
.
write
(
'Please change password immediatelly!'
)
user
=
User
.
objects
.
create_user
(
'admin'
,
'admin@example.com'
,
'admin'
)
password
=
self
.
make_password
(
13
);
self
.
stdout
.
write
(
'Creating user admin with password '
+
password
)
user
=
User
.
objects
.
create_user
(
'admin'
,
'admin@example.com'
,
password
)
user
.
first_name
=
'Weblate Admin'
user
.
last_name
=
''
user
.
is_superuser
=
True
...
...
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