コード例 #1
0
def clear_users(args):
    print('Are you sure you want to delete all users?')
    answer = input('(yes/no): ')

    if answer.lower() == 'yes':
        auth.init()
        auth.clear()
        print('Deleted all users')
    else:
        print('Cancelled')
コード例 #2
0
ファイル: manage.py プロジェクト: wkevina/garage
def clear_users(args):
    print('Are you sure you want to delete all users?')
    answer = input('(yes/no): ')

    if answer.lower() == 'yes':
        auth.init()
        auth.clear()
        print('Deleted all users')
    else:
        print('Cancelled')
コード例 #3
0
def add_user(args):
    print("Set password for user {}".format(args.user_name))
    password = getpass.getpass()
    confirm = getpass.getpass(prompt='Confirm password: '******'Error: passwords do not match')
    else:
        auth.init()
        auth.add_user(args.user_name, password)
        print('User database updated')
コード例 #4
0
ファイル: manage.py プロジェクト: wkevina/garage
def add_user(args):
    print("Set password for user {}".format(args.user_name))
    password = getpass.getpass()
    confirm = getpass.getpass(prompt='Confirm password: '******'Error: passwords do not match')
    else:
        auth.init()
        auth.add_user(args.user_name, password)
        print('User database updated')
コード例 #5
0
ファイル: jwc.py プロジェクト: WuHuaJi0/jwc
def mask():
    form = UserForm()
    if request.method == 'GET':
        session['cookie'] = None
        session['__VIEWSTATE'] = None
        session['__EVENTVALIDATION'] = None
        session['headers'] = None
        session['randomNum'] = None

        (session['cookie'],session['__VIEWSTATE'],session['__EVENTVALIDATION']) = auth.init()
        session['headers'] = auth.createHeaders(session['cookie'])
        session['randomNum'] = auth.getImage(session['headers'])

    if form.validate_on_submit() and request.method == 'POST':
        username = form.txtUserName.data
        password = form.txtUserPassword.data
        CheckCode = form.CheckCode.data
        loginResult = auth.login(session.get('__VIEWSTATE'),session.get('__EVENTVALIDATION'),session.get('headers'),username,password,CheckCode)

        if loginResult != 'yes':
            return render_template('login_error.html', loginError = loginResult,before='mask')

        (tiaomu2012,tiaomu2013,tiaomu2014,tiaomu2015,userinfo) = auth.getGrade(session['headers'],loginResult)

        return render_template('mask_detail.html',tiaomu2012 = tiaomu2012,tiaomu2013 = tiaomu2013,tiaomu2014 = tiaomu2014,tiaomu2015 = tiaomu2015,userinfo=userinfo)

    return render_template('query.html',form=form,randomNum=str(session['randomNum']))
コード例 #6
0
ファイル: jwc.py プロジェクト: WuHuaJi0/jwc
def studyCompare():
    form = UserForm()
    if request.method == 'GET':
        session['cookie'] = None
        session['__VIEWSTATE'] = None
        session['__EVENTVALIDATION'] = None
        session['headers'] = None
        session['randomNum'] = None

        (session['cookie'],session['__VIEWSTATE'],session['__EVENTVALIDATION']) = auth.init()
        session['headers'] = auth.createHeaders(session['cookie'])
        session['randomNum'] = auth.getImage(session['headers'])

    if form.validate_on_submit() and request.method == 'POST':
        username = form.txtUserName.data
        password = form.txtUserPassword.data
        CheckCode = form.CheckCode.data
        loginResult = auth.login(session.get('__VIEWSTATE'),session.get('__EVENTVALIDATION'),session.get('headers'),username,password,CheckCode)

        if loginResult != 'yes':
            return render_template('login_error.html', loginError = loginResult,before='course')

        plan = auth.studyCompare(session['headers'],loginResult)

        return render_template('studyCompare.html',plan = plan)

    return render_template('query.html',form=form,randomNum=str(session['randomNum']))
コード例 #7
0
def main():
    _init_logging()

    ovirt_provider_config.load()
    auth.init()

    server_keystone = HTTPServer(('', keystone_port()), TokenHandler)
    _ssl_wrap(server_keystone)
    Thread(target=server_keystone.serve_forever).start()

    server_neutron = HTTPServer(('', neturon_port()), NeutronHandler)
    _ssl_wrap(server_neutron)
    Thread(target=server_neutron.serve_forever).start()

    def kill_handler(signal, frame):
        logging.info('Shutting down http ...')
        server_keystone.shutdown()
        server_neutron.shutdown()
        logging.info('Http shut down successfully, exiting. Bye.')
        logging.shutdown()

    atexit.register(kill_handler)
コード例 #8
0
def test_auth_core_init_valid(mock_get):
    init()
コード例 #9
0
ファイル: area.py プロジェクト: oktilon/areacalc
import math
import sph
import auth
# import numpy

script, fname = argv

a, f = 6378137, 1. / 298.257223563  # большая полуось и сжатие

# print "atan2(10,12)   = %.16f" %(math.atan2(10, 12))
# print "atan2(-10,12)   = %.16f" %(math.atan2(-10, 12))
# print "atan2(10,-12)   = %.16f" %(math.atan2(10, -12))
# print "atan2(-10,-12)   = %.16f" %(math.atan2(-10, -12))

# инициализировать эквивалентную сферу
r_auth, to_auth_2, to_auth_4, to_auth_6 = auth.init(a, f)

print "SPH R=%.16f, a2=%.16f, a4=%.16f, a6=%.16f" % (r_auth, to_auth_2,
                                                     to_auth_4, to_auth_6)

fp = open(fname, 'r')
tau = 0.
azi0 = azi1 = azi2 = 0.
i = 1
for line in fp:
    # прочитать долготу и широту
    alon, alat = map(float, line.split(" "))
    lon = math.radians(alon)
    lat = math.radians(alat)
    lonx = lon
    latx = lat
コード例 #10
0
import asyncio
import discord
import platform
from discord.ext import commands
import settings
import auth
import dbmanagement
import tools
import time

#read values from the settings and auth file
auth.init()
settings.init()
tools.init()

client = settings.client
startup_extensions = settings.startup_extensions
appinfo = settings.appinfo
lastChannel = settings.lastChannel
last_link = ""
ver_number = "1.8.2"  # built with commit #45


# This is what happens everytime the bot launches. In this case, it prints information like server count, user count the bot is connected to, and the bot id in the console.
# Do not mess with it because the bot can break, if you wish to do so, please consult me or someone trusted.
@client.event
async def on_ready():
    print('--------')
    print('Logged in as ' + client.user.name + ' (ID:' + client.user.id + ')')
    print('Connected to ' + str(len(client.servers)) +
          ' servers | Connected to ' +
コード例 #11
0
app = Flask(__name__)
db_overwrite = os.environ.get('SQLALCHEMY_DATABASE_OVERWRITE')
app.config[
    'SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite' if db_overwrite is None else db_overwrite
app.config['JWT_SECRET_KEY'] = 'Somebodysaidpythonwasmemorysafe'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
db = SQLAlchemy(app)

from models.User import User  # noqa: E402, F401

db.create_all()
print('Creating the db')

from auth import init  # noqa: E402

jwt = init(app)

from resources.users import UserResource  # noqa: E402
from resources.auth import AuthResource  # noqa: E402

api = Api()
api.add_resource(UserResource,
                 '/api/users',
                 '/api/users/<string:id>',
                 endpoint='user')
api.add_resource(AuthResource, '/api/auth', endpoint='auth')
api.init_app(app)

if __name__ == '__main__':
    app.run(debug=True)
コード例 #12
0
ファイル: manage.py プロジェクト: wkevina/garage
def remove_user(args):
    print("Removing user {}".format(args.user_name))
    auth.init()
    auth.remove_user(args.user_name)
コード例 #13
0
# Gets uri for each song in a playlist
# user. Uses Client Credentials flow

import json
# from auth import get_session
import auth
from ReportGenerator import ReportGenerator

with open('./config.json') as config_file:
    config_data = json.load(config_file)

    watchlist_path = config_data['watchlist_path']

    username = auth.init()

    report_generator = ReportGenerator(username, watchlist_path)

    watchlist = report_generator.db_get_watchlist(
        config_data['watchlist_path'])

    # test_playlist_uri = 'spotify:user:valeedm92:playlist:5iMnObRSZlbUY2sgyut9Jf'
    # print(watchlist)
    # x = playlist_name(test_playlist_uri)
    # print(x)

    for playlist in watchlist:
        report_generator.generate_playlist_report(playlist)

        print(playlist)

    report_generator.generate_aggregate_report()
コード例 #14
0
def test_auth_core_init_incomplete(mock_get):
    with pytest.raises(TypeError):
        init()
コード例 #15
0
def remove_user(args):
    print("Removing user {}".format(args.user_name))
    auth.init()
    auth.remove_user(args.user_name)
コード例 #16
0
def test_auth_core_init_no_plugin(mock_get):
    with pytest.raises(AssertionError):
        init()
コード例 #17
0
# TODO:
#
# - Move configuration out of code.

discovery_url = 'https://accounts.google.com/.well-known/openid-configuration'
oauth_config_file = 'oauth-config.json'
allowed_domains = {'dnc.org'}

app = Flask(__name__)
app.config['DEBUG'] = True
app.secret_key = urandom(12)
db = LinkDB("testdb")
nonces = NonceDB("nonces")

disco, config = init(discovery_url, oauth_config_file)


def authenticated(f):
    @wraps(f)
    def wrapper(*args, **kwargs):
        if not session.get('authenticated'):
            return authenticate()

        return f(*args, **kwargs)

    return wrapper


@app.after_request
def add_header(r):