Skip to content

Commit 84a7214

Browse files
Jyrki Launonenjapsu
authored andcommitted
Rename database arguments variable for better security.
1 parent 28ccaea commit 84a7214

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ AUTHENTICATION_BACKENDS = (
6868
)
6969

7070
PHPBB_AUTH_DB_MODULE = "psycopg2"
71-
PHPBB_AUTH_DB_PARAMS = {
71+
PHPBB_AUTH_DB_KEYS = {
7272
"user": "",
7373
"password": "",
7474
"database": "",

examples/hammertime/settings.py.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ AUTHENTICATION_BACKENDS = (
8888
)
8989

9090
PHPBB_AUTH_DB_MODULE = "psycopg2"
91-
PHPBB_AUTH_DB_PARAMS = {
91+
PHPBB_AUTH_DB_KEYS = {
9292
"user": "",
9393
"password": "",
9494
"database": "",

phpbb/auth/backends.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,22 @@
2222

2323
from phpbb.auth.auth_db import login_db
2424
from phpbb.auth.sql import setup, is_setup
25+
from django.views.decorators.debug import sensitive_variables
2526

27+
@sensitive_variables("db_settings")
2628
def connect_to_database():
2729
if is_setup():
2830
return
2931

3032
db_module = __import__(settings.PHPBB_AUTH_DB_MODULE, globals(), locals(), [], -1)
31-
conn = db_module.connect(**settings.PHPBB_AUTH_DB_PARAMS)
33+
34+
db_settings = getattr(settings, "PHPBB_AUTH_DB_KEYS", None)
35+
if db_settings is None:
36+
import warnings
37+
warnings.warn("PHPBB_AUTH_DB_PARAMS should be renamed to PHPBB_AUTH_DB_KEYS for better security!")
38+
db_settings = settings.PHPBB_AUTH_DB_PARAMS
39+
40+
conn = db_module.connect(**db_settings)
3241
setup(conn, param_style=settings.PHPBB_AUTH_DB_PARAM_STYLE, users_table=settings.PHPBB_AUTH_DB_USERS_TABLE)
3342

3443
class PhpbbBackend(object):

0 commit comments

Comments
 (0)