mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
6c928801fa
commit
e2b7407e96
6
auth.py
6
auth.py
|
@ -13,7 +13,7 @@ import binascii
|
|||
import os
|
||||
import secrets
|
||||
import datetime
|
||||
from utils import isSystemAccount
|
||||
from utils import is_system_account
|
||||
from utils import has_users_path
|
||||
|
||||
|
||||
|
@ -103,7 +103,7 @@ def authorizeBasic(base_dir: str, path: str, authHeader: str,
|
|||
print('DEBUG: basic auth - this is not a users endpoint')
|
||||
return False
|
||||
nicknameFromPath = pathUsersSection.split('/')[0]
|
||||
if isSystemAccount(nicknameFromPath):
|
||||
if is_system_account(nicknameFromPath):
|
||||
print('basic auth - attempted login using system account ' +
|
||||
nicknameFromPath + ' in path')
|
||||
return False
|
||||
|
@ -116,7 +116,7 @@ def authorizeBasic(base_dir: str, path: str, authHeader: str,
|
|||
'separator for username:password')
|
||||
return False
|
||||
nickname = plain.split(':')[0]
|
||||
if isSystemAccount(nickname):
|
||||
if is_system_account(nickname):
|
||||
print('basic auth - attempted login using system account ' + nickname +
|
||||
' in Auth header')
|
||||
return False
|
||||
|
|
|
@ -282,7 +282,7 @@ from utils import getCSS
|
|||
from utils import firstParagraphFromString
|
||||
from utils import clearFromPostCaches
|
||||
from utils import containsInvalidChars
|
||||
from utils import isSystemAccount
|
||||
from utils import is_system_account
|
||||
from utils import setConfigParam
|
||||
from utils import get_config_param
|
||||
from utils import remove_id_ending
|
||||
|
@ -1584,7 +1584,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
tokenStr = tokenStr.split(';')[0].strip()
|
||||
if self.server.tokens_lookup.get(tokenStr):
|
||||
nickname = self.server.tokens_lookup[tokenStr]
|
||||
if not isSystemAccount(nickname):
|
||||
if not is_system_account(nickname):
|
||||
self.authorizedNickname = nickname
|
||||
# default to the inbox of the person
|
||||
if self.path == '/':
|
||||
|
@ -1679,7 +1679,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.last_login_time,
|
||||
self.server.domain)
|
||||
if loginNickname:
|
||||
if isSystemAccount(loginNickname):
|
||||
if is_system_account(loginNickname):
|
||||
print('Invalid username login: ' + loginNickname +
|
||||
' (system account)')
|
||||
self._clearLoginDetails(loginNickname, calling_domain)
|
||||
|
|
4
inbox.py
4
inbox.py
|
@ -19,7 +19,7 @@ from reaction import updateReactionCollection
|
|||
from reaction import validEmojiContent
|
||||
from utils import domainPermitted
|
||||
from utils import is_group_account
|
||||
from utils import isSystemAccount
|
||||
from utils import is_system_account
|
||||
from utils import invalid_ciphertext
|
||||
from utils import removeHtml
|
||||
from utils import fileLastModified
|
||||
|
@ -3911,7 +3911,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
|
|||
print('DEBUG: follow request does not contain a ' +
|
||||
'nickname for the account followed')
|
||||
return True
|
||||
if isSystemAccount(nicknameToFollow):
|
||||
if is_system_account(nicknameToFollow):
|
||||
if debug:
|
||||
print('DEBUG: Cannot follow system account - ' +
|
||||
nicknameToFollow)
|
||||
|
|
12
utils.py
12
utils.py
|
@ -486,7 +486,7 @@ def firstParagraphFromString(content: str) -> str:
|
|||
return removeHtml(paragraph)
|
||||
|
||||
|
||||
def isSystemAccount(nickname: str) -> bool:
|
||||
def is_system_account(nickname: str) -> bool:
|
||||
"""Returns true if the given nickname is a system account
|
||||
"""
|
||||
if nickname == 'news' or nickname == 'inbox':
|
||||
|
@ -505,7 +505,7 @@ def _create_config(base_dir: str) -> None:
|
|||
save_json(config_json, config_filename)
|
||||
|
||||
|
||||
def setConfigParam(base_dir: str, variableName: str, variableValue) -> None:
|
||||
def setConfigParam(base_dir: str, variable_name: str, variable_value) -> None:
|
||||
"""Sets a configuration value
|
||||
"""
|
||||
_create_config(base_dir)
|
||||
|
@ -513,19 +513,19 @@ def setConfigParam(base_dir: str, variableName: str, variableValue) -> None:
|
|||
configJson = {}
|
||||
if os.path.isfile(config_filename):
|
||||
configJson = load_json(config_filename)
|
||||
configJson[variableName] = variableValue
|
||||
configJson[variable_name] = variable_value
|
||||
save_json(configJson, config_filename)
|
||||
|
||||
|
||||
def get_config_param(base_dir: str, variableName: str):
|
||||
def get_config_param(base_dir: str, variable_name: str):
|
||||
"""Gets a configuration value
|
||||
"""
|
||||
_create_config(base_dir)
|
||||
config_filename = base_dir + '/config.json'
|
||||
configJson = load_json(config_filename)
|
||||
if configJson:
|
||||
if variableName in configJson:
|
||||
return configJson[variableName]
|
||||
if variable_name in configJson:
|
||||
return configJson[variable_name]
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ __status__ = "Production"
|
|||
__module_group__ = "Timeline"
|
||||
|
||||
import os
|
||||
from utils import isSystemAccount
|
||||
from utils import is_system_account
|
||||
from utils import getDomainFromActor
|
||||
from utils import get_config_param
|
||||
from person import personBoxJson
|
||||
|
@ -120,7 +120,7 @@ def htmlFrontScreen(signing_priv_key_pem: str,
|
|||
nickname = profile_json['preferredUsername']
|
||||
if not nickname:
|
||||
return ""
|
||||
if not isSystemAccount(nickname):
|
||||
if not is_system_account(nickname):
|
||||
return ""
|
||||
domain, port = getDomainFromActor(profile_json['id'])
|
||||
if not domain:
|
||||
|
|
|
@ -20,7 +20,7 @@ from utils import is_artist
|
|||
from utils import is_dormant
|
||||
from utils import getNicknameFromActor
|
||||
from utils import getDomainFromActor
|
||||
from utils import isSystemAccount
|
||||
from utils import is_system_account
|
||||
from utils import removeHtml
|
||||
from utils import load_json
|
||||
from utils import get_config_param
|
||||
|
@ -569,7 +569,7 @@ def htmlProfile(signing_priv_key_pem: str,
|
|||
nickname = profile_json['preferredUsername']
|
||||
if not nickname:
|
||||
return ""
|
||||
if isSystemAccount(nickname):
|
||||
if is_system_account(nickname):
|
||||
return htmlFrontScreen(signing_priv_key_pem,
|
||||
rss_icon_at_top,
|
||||
cssCache, icons_as_buttons,
|
||||
|
@ -652,7 +652,7 @@ def htmlProfile(signing_priv_key_pem: str,
|
|||
PGPfingerprint or emailAddress:
|
||||
donateSection = '<div class="container">\n'
|
||||
donateSection += ' <center>\n'
|
||||
if donateUrl and not isSystemAccount(nickname):
|
||||
if donateUrl and not is_system_account(nickname):
|
||||
donateSection += \
|
||||
' <p><a href="' + donateUrl + \
|
||||
'"><button class="donateButton">' + translate['Donate'] + \
|
||||
|
|
Loading…
Reference in New Issue