Commit 8c702ef0 authored by Dmitry Volodin's avatar Dmitry Volodin
Browse files

PEP8 & Futurize

parent 44810002
Pipeline #8163 passed with stages
in 5 minutes and 28 seconds
......@@ -2,7 +2,7 @@
# ---------------------------------------------------------------------
# Authentication Backends
# ---------------------------------------------------------------------
# Copyright (C) 2007-2016 The NOC Project
# Copyright (C) 2007-2018 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
......
......@@ -2,14 +2,16 @@
# ---------------------------------------------------------------------
# Local Authentication backend
# ---------------------------------------------------------------------
# Copyright (C) 2007-2016 The NOC Project
# Copyright (C) 2007-2018 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import absolute_import
# NOC modules
from base import BaseAuthBackend
from noc.main.models import User
from noc.core.translation import ugettext as _
from .base import BaseAuthBackend
class LocalBackend(BaseAuthBackend):
......
......@@ -2,22 +2,24 @@
# ---------------------------------------------------------------------
# PAM Authentication backend
# ---------------------------------------------------------------------
# Copyright (C) 2007-2016 The NOC Project
# Copyright (C) 2007-2018 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import absolute_import
# Third-party modules
import pam
# NOC modules
from base import BaseAuthBackend
from noc.config import config
from .base import BaseAuthBackend
class PAMBackend(BaseAuthBackend):
def authenticate(self, user=None, password=None, **kwargs):
pam = pam.pam()
r = pam.authenticate(user, password,
service=config.login.pam_service)
p = pam.pam()
r = p.authenticate(user, password,
service=config.login.pam_service)
if not r:
raise self.LoginError("PAM authentication failed")
return user
......@@ -2,17 +2,19 @@
# ---------------------------------------------------------------------
# RADIUS Authentication backend
# ---------------------------------------------------------------------
# Copyright (C) 2007-2016 The NOC Project
# Copyright (C) 2007-2018 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import absolute_import
# Third-party modules
from pyrad.packet import AccessAccept
from pyrad.packet import AccessAccept, AccessRequest
from pyrad.client import Client
from pyrad.dictionary import Dictionary
# NOC modules
from base import BaseAuthBackend
from noc.config import config
from .base import BaseAuthBackend
class RADIUSBackend(BaseAuthBackend):
......@@ -30,7 +32,7 @@ class RADIUSBackend(BaseAuthBackend):
dict=self.RADIUS_DICT
)
req = client.CreateAuthPacket(
code=packet.AccessRequest,
code=AccessRequest,
User_Name=user,
NAS_Identifier="noc"
)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment