Skip to content

Commit 36d6676

Browse files
committed
Appease python style gods
1 parent 9326aa4 commit 36d6676

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

pam_auth_provider.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@
1313
# See the Licence for the specific language governing permissions and
1414
# limitations under the Licence.
1515

16-
import pam
17-
import pwd
16+
"""Module containing the PAM auth provider for the Synapse Matrix server."""
1817

18+
import pwd
1919
from collections import namedtuple
20+
21+
import pam
2022
from twisted.internet import defer
2123

24+
2225
class PAMAuthProvider:
26+
"""PAM auth provider for the Synapse Matrix server."""
27+
2328
def __init__(self, config, account_handler):
2429
self.account_handler = account_handler
2530
self.create_users = config.create_users
2631
self.skip_user_check = config.skip_user_check
2732

2833
@defer.inlineCallbacks
2934
def check_password(self, user_id, password):
30-
""" Attempt to authenticate a user against PAM
31-
and register an account if none exists.
32-
33-
Returns:
34-
True if authentication against PAM was successful
35-
"""
35+
"""Check user/password against PAM, optionally creating the user."""
3636
if not password:
3737
defer.returnValue(False)
3838
# user_id is of the form @foo:bar.com
@@ -46,7 +46,8 @@ def check_password(self, user_id, password):
4646
defer.returnValue(False)
4747

4848
# Now check the password
49-
if not pam.pam().authenticate(localpart, password, service='matrix-synapse'):
49+
if not pam.pam().authenticate(localpart, password,
50+
service='matrix-synapse'):
5051
defer.returnValue(False)
5152

5253
# From here on, the user is authenticated
@@ -63,6 +64,7 @@ def check_password(self, user_id, password):
6364

6465
@staticmethod
6566
def parse_config(config):
67+
"""Parse the configuration for use in __init__."""
6668
pam_config = namedtuple('_Config', 'create_users')
6769
pam_config.create_users = config.get('create_users', True)
6870
pam_config.skip_user_check = config.get('skip_user_check', False)

0 commit comments

Comments
 (0)