Пример #1
0
 def menu_click_lock(self, widget, ssid, bssid, wificard):
     if bssid in open(wpa_supplican).read():
         connectToSsid(ssid, wificard)
     else:
         Authentication(ssid, bssid, wificard)
     self.updateinfo()
     self.ifruning = False
Пример #2
0
    def __init__(self, username=None, api_key=None, **kwargs):
        """
        Accepts keyword arguments for Mosso username and api key.
        Optionally, you can omit these keywords and supply an
        Authentication object using the auth keyword.
        
        @type username: str
        @param username: a Mosso username
        @type api_key: str
        @param api_key: a Mosso API key
        """
        self.cdn_enabled = False
        self.cdn_args = None
        self.connection_args = None
        self.cdn_connection = None
        self.connection = None
        self.token = None
        self.debuglevel = int(kwargs.get('debuglevel', 0))
        socket.setdefaulttimeout = int(kwargs.get('timeout', 5))
        self.auth = kwargs.has_key('auth') and kwargs['auth'] or None

        if not self.auth:
            authurl = kwargs.get('authurl', consts.default_authurl)
            if username and api_key and authurl:
                self.auth = Authentication(username, api_key, authurl)
            else:
                raise TypeError("Incorrect or invalid arguments supplied")

        self._authenticate()
Пример #3
0
    def __init__(self, username=None, api_key=None, timeout=10, **kwargs):
        """
        Accepts keyword arguments for Rackspace Cloud username and api key.
        Optionally, you can omit these keywords and supply an
        Authentication object using the auth keyword.

        @type username: str
        @param username: a Rackspace Cloud username
        @type api_key: str
        @param api_key: a Rackspace Cloud API key
        """
        self.connection_args = None
        self.connection = None
        self.token = None
        self.debuglevel = int(kwargs.get('debuglevel', 0))
        self.user_agent = kwargs.get('useragent', consts.user_agent)
        self.timeout = timeout
        self._total_domains = -1

        self.auth = 'auth' in kwargs and kwargs['auth'] or None

        if not self.auth:
            authurl = kwargs.get('authurl', consts.us_authurl)
            if username and api_key and authurl:
                self.auth = Authentication(username,
                                           api_key,
                                           authurl=authurl,
                                           useragent=self.user_agent)
            else:
                raise TypeError("Incorrect or invalid arguments supplied")

        self._authenticate()
 def test_authentication_change_password_fail(self):
     fake_persist = FakePersist()
     fake_persist.custom_retrieve_value = {}
     auth = Authentication(fake_persist)
     auth.add_user('foobar', 'baz', 'student')
     self.assertDictEqual(auth.change_password('foobar', 'qux', 'wobble'),
                          {})
Пример #5
0
 def authenticate_umls(self):
     # TODO sort imports out
     from authentication import Authentication
     import creds
     auth = Authentication(apikey=creds.apikey)
     tgt = auth.gettgt()
     return auth, tgt
Пример #6
0
    def get_vendor(self, card_num):
        validity = Authentication().verify_card(
            card_num
        )  #call verify card method fron Authentication class and assign it to variable
        #check for validity
        if validity == 'Valid':
            first_digit = str(card_num)[0]  #assign first digits of card number
            industry = ''  #declare which type of industry card belongs to

            if first_digit == '1' or first_digit == '2':  #if first digit of card is 1 or 2
                industry = 'Airline'  #it is in airline industry
            elif first_digit == '3':  #if digit is 3
                industry = 'Travel & Entertainment'
                issuer = 'American Express'  #amex card
            elif first_digit == '4' or first_digit == '5' or first_digit == '6':  #if digits are 4 or 5 or 6
                industry = 'Banking'  # it is banking industry
                if first_digit == '4':  #if digit is 4
                    issuer = 'Visa'  #card is VISA
                elif first_digit == '5':  #if digit is 5
                    issuer = 'MasterCard'  #it is Mastercard
                else:
                    issuer = 'Discover'  #any other digit is Discover
            return '\tIndustry: {0} \n\tIssuer: {1}'.format(industry, issuer)
        else:
            self.vendor = "Invalid card has no Vendor"  #otherwise card has no vendor
            return self.vendor
Пример #7
0
class TestAuthentication(unittest.TestCase):
    test_authen = Authentication("jake", "jake")

    def test_credential_manager(self):
        # Checking the result when a  user is found in the database
        self.assertNotEqual(self.test_authen.credential_manager("jake"), False)
        # Checking the result when a user is not found
        self.assertFalse(self.test_authen.credential_manager("barrybluejeans"))

    def test_check_login(self):
        # Checking the result when the login credentials are correct for an admin
        self.assertEqual(self.test_authen.check_login("dev", "dev"), "admin")
        # Checking the result when the login credentials are correct for a user
        self.assertEqual(self.test_authen.check_login("jamie", "jamie"),
                         "user")
        # Checking the result when the login credentials are incorrect
        self.assertRaises(Exception,
                          self.test_authen.check_login("jake", "notjake"))

    def test_db_credentials(self):
        # Checking if an exception is raised when the user can't log in with the provided details
        with self.assertRaises(Exception):
            self.test_authen.db_credentials(False)
        # Checking if
        checking_admin_tuple = ("jake", "user")
        self.assertTupleEqual(checking_admin_tuple,
                              self.test_authen.db_credentials("user"))
Пример #8
0
 def setup_clients(self):
     """
       A method to seting up authentication and necessary clients for the tool - Called by Constructor
       """
     auth = Authentication()
     self.novaclient = NovaClient(auth)
     self.keystoneclient = KeystoneClient(auth)
Пример #9
0
def userSignUp(request):
    if request.method == 'POST':

        serializer = UserSerializer(data=request.data)
        if serializer.is_valid():
            save = serializer.save()
            auth = Authentication()
            user, token = auth.authenticate(
                serializer.validated_data.get('mobile'),
                serializer.validated_data.get('password'))
            data = AuthUserSerializer(user).data
            result = {'token': token}
            result.update(data)
            wallet = WalletSerializer(data={'win_bal': '0', 'wal_bal': '10'})
            if wallet.is_valid():
                user_wallet = wallet.save()
                user_wallet.user = save
                user_wallet.save()
                user_txn = TransactionSerializer(
                    data={
                        'txn_status': 'credit',
                        'txn_amount': '10',
                        'txn_description': 'Signup bonus'
                    })
                if user_txn.is_valid():

                    user_txn1 = user_txn.save()
                    user_txn1.user = save
                    user_txn1.save()

            return Response(data=result, status=status.HTTP_201_CREATED)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Пример #10
0
 def test_login(self):
     auth = Authentication()
     login_url = auth.login()
     print(login_url)
     match = re.search(
         r'https://slack\.com/oauth/authorize\?response_type=code&client_id=.*&state=.*',
         login_url).group()
     self.assertEqual(match, login_url)
Пример #11
0
def main():
    encryption_main()
    if checking_hashfile():
        arc4_decoder(HASH_KEY)

    root = Tk()
    from authentication import Authentication
    my_gui = Authentication(root)
    root.mainloop()
Пример #12
0
 def menu_click_lock(self, widget, ssid, bssid):
     if ssid in open(wpa_supplican).read():
         connectToSsid(ssid)
     else:
         Authentication(ssid, bssid)
     if not self.thr.is_alive():
         self.thr.start()
     else:
         self.nmMenu = self.nm_menu()
Пример #13
0
def auth():
    data = request.get_json()
    token = uuid4()
    status = 'SUCCESS'
    if data.get('username') != 'user_01':
        status = 'FAILED'

    auth_result = Authentication(token, status)
    tokens.append(str(token))
    return auth_result.to_json()
Пример #14
0
def main():
    codeUser, wordObjects = Authentication().login()
    correctAnswer = True
    while correctAnswer:
        userInput = input(
            'Would you like to do the wordtrainer (WT) or crossword puzzle (CW): '
        )
        if userInput.lower() == 'wt':
            WordTrainer().keepAsking(codeUser, wordObjects)
        elif userInput.lower() == 'cw':
            correctAnswer = Crossword(wordObjects)
Пример #15
0
def userSignIn(request):
    if request.method == 'POST':
        serializer = UserLoginSerializer(data=request.data)
        if serializer.is_valid():
            auth = Authentication()
            user, token = auth.authenticate(**serializer.validated_data)
            data = AuthUserSerializer(user).data
            result = {'token': token}
            result.update(data)
            return Response(data=result, status=status.HTTP_200_OK)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Пример #16
0
    def __init__(self):
        self.authentication = Authentication()
        self.menu = ConsoleMenu("Library Management System", "Reception")
        self.user = None
        self.faceid = FaceID()
        function_item_login = FunctionItem("Login", self.login)
        function_item_faceid = FunctionItem("Face-ID Login", self.login_faceid)
        function_item_register = FunctionItem("Register", self.register)
        self.menu.append_item(function_item_login)
        self.menu.append_item(function_item_faceid)
        self.menu.append_item(function_item_register)

        self.menu.show()
 def authenticate_user(self):
     global AUTHENTICATED
     from authentication import Authentication
     # we should check to see if we are already authenticated before blindly
     # doing it again
     if (AUTHENTICATED is False):
         obj = Authentication(self.configuration.vipr_hostname,
                              self.configuration.vipr_port)
         # cookiedir = os.getcwd()
         cookiedir = self.configuration.vipr_cookiedir
         obj.authenticate_user(self.configuration.vipr_username,
                               self.configuration.vipr_password, cookiedir,
                               None)
         AUTHENTICATED = True
Пример #18
0
class Follow:
    @app.route("/follow", methods=['POST'])
    def followUser():
        try:
            req_json = request.get_json()
        except Exception, e:
            print e

        profile_api = req_json['profile_api']
        profile_user = req_json['profile_user']

        endpoint = "https://api.twitter.com/1.1/friendships/create.json?screen_name=" + profile_user + "&follow=true"
        api_handler = Authentication().twitter(profile_api)
        res, data = api_handler.request(endpoint, "POST")
        return data
Пример #19
0
    def __init__(self, username=None, api_key=None, timeout=5, **kwargs):
        """
        Accepts keyword arguments for Mosso username and api key.
        Optionally, you can omit these keywords and supply an
        Authentication object using the auth keyword. Setting the argument
        servicenet to True will make use of Rackspace servicenet network.

        @type username: str
        @param username: a Mosso username
        @type api_key: str
        @param api_key: a Mosso API key
        @type servicenet: bool
        @param servicenet: Use Rackspace servicenet to access Cloud Files.
        @type cdn_log_retention: bool
        @param cdn_log_retention: set logs retention for this cdn enabled
        container.
        """
        self.cdn_enabled = False
        self.cdn_args = None
        self.connection_args = None
        self.cdn_connection = None
        self.connection = None
        self.token = None
        self.debuglevel = int(kwargs.get('debuglevel', 0))
        self.servicenet = kwargs.get('servicenet', False)
        self.user_agent = kwargs.get('useragent', consts.user_agent)
        self.timeout = timeout

        # if the environement variable RACKSPACE_SERVICENET is set (to
        # anything) it will automatically set servicenet=True
        if not 'servicenet' in kwargs \
                and 'RACKSPACE_SERVICENET' in os.environ:
            self.servicenet = True

        self.auth = 'auth' in kwargs and kwargs['auth'] or None

        if not self.auth:
            authurl = kwargs.get('authurl', consts.us_authurl)
            if username and api_key and authurl:
                self.auth = Authentication(username,
                                           api_key,
                                           authurl=authurl,
                                           useragent=self.user_agent,
                                           timeout=self.timeout)
            else:
                raise TypeError("Incorrect or invalid arguments supplied")

        self._authenticate()
Пример #20
0
    def __init__(self):
        self.db = Database()
        self.command = commands.Commands()
        self.encrypt = Encrypt()
        self.auth = Authentication()

        self.commands = {
            "help": self.command.help,
            "new": self.command.new,
            "show": self.command.show,
            "save": self.command.save,
            "search": self.command.search,
            "delete": self.command.delete,
            "update": self.command.update_master_password,
            "security": self.command.security
        }
Пример #21
0
    def __init__(self, port):
        self.BACKLOG = 1024  # size of the queue for pending connections

        self.ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
        self.ssl_context.load_cert_chain('ssl/certificate.crt',
                                         'ssl/private.key')

        self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.s.bind(('', port))  # Bind to the port
        self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

        self.s = self.ssl_context.wrap_socket(self.s, server_side=True)

        self.db_handler = DBHandler()
        self.auth = Authentication()
        self.logger = self.configure_logging()
Пример #22
0
    def __init__(self, username=None, api_key=None, timeout=5, **kwargs):
        """
        Accepts keyword arguments for chouti username and api key.
        Optionally, you can omit these keywords and supply an
        Authentication object using the auth keyword. 

        @type username: str
        @param username: a chouti username, pattern is account:admin
        @type api_key: str
        @param api_key: a chouti password
        container.
        """
        self.connection_args = None
        self.connection = None
        self.token = None
        self.debuglevel = int(kwargs.get('debuglevel', 0))
        self.servicenet = kwargs.get('servicenet', False)
        self.user_agent = kwargs.get('useragent', consts.user_agent)
        self.timeout = timeout

        self.username = username
        self.api_key = api_key
        self._share_user_uri = kwargs.get('_share_user_uri', None)
        self._share_request = kwargs.get('_share_request', False)

        if kwargs.get('share_request', False):
            # 产生一个专为共享请求的请求连接方法
            self.make_request = self.make_share_requst

        self.auth = 'auth' in kwargs and kwargs['auth'] or None

        if not self.auth:
            authurl = kwargs.get('authurl', consts.chouti_authurl)
            if username and api_key and authurl:
                # 此处的auth为Authentication类的实例
                self.auth = Authentication(username,
                                           api_key,
                                           authurl=authurl,
                                           useragent=self.user_agent)
            else:
                raise TypeError("Incorrect or invalid arguments supplied")

        self._authenticate()
Пример #23
0
    def get_vendor(self, card_num):
        validity = Authentication().verify_card(card_num)
        if validity == 'Valid':
            first_digit = str(card_num)[0]
            industry = ''

            if first_digit == '1' or first_digit == '2':
                industry = 'Airline'
            elif first_digit == '3':
                industry = 'Travel & Entertainment'
                issuer = 'American Express'
            elif first_digit == '4' or first_digit == '5' or first_digit == '6':
                industry = 'Banking'
                if first_digit == '4':
                    issuer = 'Visa'
                elif first_digit == '5':
                    issuer = 'MasterCard'
                else:
                    issuer = 'Discover'
            return '\tIndustry: {0} \n\tIssuer: {1}'.format(industry, issuer)
        else:
            return "Invalid card has no Vendor"
Пример #24
0
 def back_to_auth_screen(self):
     self.root.destroy()
     screen = Tk()
     from authentication import Authentication
     sign_up = Authentication(screen)
     screen.mainloop()
Пример #25
0
from flask import Flask, render_template, request, jsonify, redirect, abort, Response, make_response
import re
from typing import Optional  # noqa: F401

import config
import json
from gregorian_calendar import GregorianCalendar
from calendar_data import CalendarData
from authentication import Authentication
from app_utils import (previous_month_link, next_month_link, new_session_id,
                       add_session, authenticated, get_session_username,
                       authorized)

app = Flask(__name__)

authentication = Authentication(data_folder=config.USERS_DATA_FOLDER,
                                password_salt=config.PASSWORD_SALT)


@app.route("/", methods=["GET"])
@authenticated
def index() -> Response:
    username = get_session_username(session_id=str(request.cookies.get("sid")))
    user_data = authentication.user_data(username=username)
    return redirect("/{}/".format(user_data["default_calendar"]))


@app.route("/login", methods=["GET"])
def login() -> Response:
    return render_template("login.html")

 def test_authentication_login(self):
     auth = Authentication(FakePersist())
     auth.add_user('foobar', 'baz', 'professor')
     self.assertDictEqual(auth.login('foobar', 'baz'), {})
Пример #27
0
def authentication() -> Authentication:
    return Authentication(data_folder="test/fixtures",
                          password_salt="a test salt",
                          failed_login_delay_base=0)
 def test_authentication_login_wrong_password_fail(self):
     auth = Authentication(FakePersist())
     auth.add_user('wobble', 'spam', 'student')
     self.assertDictEqual(auth.login('wobble', 'wrong_password'), {})
 def test_authentication_login_unknown_user_fail(self):
     auth = Authentication(FakePersist())
     self.assertDictEqual(auth.login('foobar', 'baz'), {
         'success': False,
         'message': 'User does not exist.'
     })
 def test_authentication_change_password(self):
     auth = Authentication(FakePersist())
     auth.add_user('foobar', 'baz', 'student')
     auth.login('foobar', 'baz')
     self.assertDictEqual(auth.change_password('foobar', 'qux'), {})