import serial from pygame import mixer import RPi.GPIO as GPIO from mutagen.flac import FLAC #import the config file import config #set config password sudoPassword = config.SUDO_PASSWORD #setup Serial Coms ser = serial.Serial('/dev/ttyACM0', 9600) #create an instance instance = csh_ldap.CSHLDAP(config.LDAP_BIND_DN, config.PASSWORD) #authentication config file HAROLD_AUTH = config.harold_auth pygame.mixer.init() time_now = time.localtime() max_counter = 0 #main function def main(): ID = "" #keep the whole program running so it doesn't play one song and stop
app = Flask(__name__) # Check if deployed on OpenShift, if so use environment. if os.path.exists(os.path.join(os.getcwd(), 'config.py')): app.config.from_pyfile(os.path.join(os.getcwd(), 'config.py')) else: app.config.from_pyfile(os.path.join(os.getcwd(), 'config.env.py')) auth = OIDCAuthentication( app, issuer=app.config['OIDC_ISSUER'], client_registration_info=app.config['OIDC_CLIENT_CONFIG']) # Create a connection to CSH LDAP ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_ALLOW) _ldap = csh_ldap.CSHLDAP(app.config['LDAP_BIND_DN'], app.config['LDAP_BIND_PASS']) # Sentry sentry_sdk.init( dsn=app.config['SENTRY_DSN'], integrations=[FlaskIntegration(), SqlalchemyIntegration()], ) # Initalize the SQLAlchemy object and add models. # Make sure that you run the migrate task before running. db = SQLAlchemy(app) from selections.models import * migrate = Migrate(app, db)
import os import csh_ldap import graphene from flask_graphql import GraphQLView from flask import Flask # LDAP initialization _ldap = csh_ldap.CSHLDAP(os.environ['LDAP_BIND_DN'], os.environ['LDAP_BIND_PASS']) # app initialization app = Flask(__name__) app.debug = True class Query(graphene.ObjectType): hello = graphene.String(description='A typical hello world') def resolve_hello(self, info): o = _ldap.get_member('owen', uid=True) print(o.cn) return "owen" class ChangeFile(graphene.Mutation): class Arguments: name = graphene.String(required=True) text = graphene.String(required=True) ok = graphene.Boolean()
APP = Flask(__name__) if os.path.exists(os.path.join(os.getcwd(), "config.py")): APP.config.from_pyfile(os.path.join(os.getcwd(), "config.py")) else: APP.config.from_pyfile(os.path.join(os.getcwd(), "config.env.py")) APP.secret_key = APP.config['SECRET_KEY'] _CONFIG = ProviderConfiguration( APP.config['OIDC_ISSUER'], client_metadata=ClientMetadata(**APP.config['OIDC_CLIENT_CONFIG'])) _AUTH = OIDCAuthentication({'default': _CONFIG}, APP) _LDAP = csh_ldap.CSHLDAP(APP.config['LDAP_DN'], APP.config['LDAP_SECRET']) _SLACK_AUTH_URI = 'https://slack.com/oauth/authorize' \ + '?scope=identity.basic&client_id=%s&state=%s' \ + '&redirect_uri=https://eac.csh.rit.edu/slack/return' _SLACK_ACCESS_URI = 'https://slack.com/api/oauth.access' \ + '?client_id=%s&client_secret=%s&code=%s' _GITHUB_AUTH_URI = 'https://github.com/login/oauth/authorize' \ + '?client_id=%s&state=%s' _GITHUB_TOKEN_URI = 'https://github.com/login/oauth/access_token' \ + '?client_id=%s&client_secret=%s&code=%s' _ORG_HEADER = { 'Authorization': 'token ' + APP.config['ORG_TOKEN'], 'Accept': 'application/vnd.github.v3+json' }
def main(): global cshldap cshldap = ldap.CSHLDAP(login.ldap_user, login.ldap_pass) get_ibutton()
# Initialize Onesignal Notification apps csh_onesignal_client = onesignal.Client( user_auth_key=app.config["ONESIGNAL_USER_AUTH_KEY"], app_auth_key=app.config["ONESIGNAL_CSH_APP_AUTH_KEY"], app_id=app.config["ONESIGNAL_CSH_APP_ID"]) intro_onesignal_client = onesignal.Client( user_auth_key=app.config["ONESIGNAL_USER_AUTH_KEY"], app_auth_key=app.config["ONESIGNAL_INTRO_APP_AUTH_KEY"], app_id=app.config["ONESIGNAL_INTRO_APP_ID"]) # OIDC Auth auth = OIDCAuthentication({'app': APP_CONFIG}, app) # LDAP _ldap = csh_ldap.CSHLDAP(app.config["LDAP_BIND_DN"], app.config["LDAP_BIND_PASS"]) app.logger.info("OIDCAuth and LDAP configured") # pylint: disable=wrong-import-position from . import models from . import context_processors from . import commands from .routes import api, shared if app.config["REALM"] == "csh": from .routes import upperclassmen else: from .routes import freshmen app.logger.info("Routes registered")
def ldap_init(app): app.config['LDAP_CONN'] = csh_ldap.CSHLDAP(app.config['LDAP_BIND_DN'], app.config['LDAP_BIND_PW'], ro=True)
import os import time import RPi.GPIO as GPIO import csh_ldap from config import PASSWORD, BIND instance = csh_ldap.CSHLDAP(BIND, PASSWORD) GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(18, GPIO.OUT) print(time.strftime("%c")) base_dir = '/sys/devices/w1_bus_master1/w1_master_slaves' delete_dir = '/sys/devices/w1_bus_master1/w1_master_remove' def main(): GPIO.output(18, GPIO.HIGH) while True: # iButton Read f = open(base_dir, "r") ID = f.readline().strip() f.close() if ID != 'not found.\n': print("using username") user1 = instance.get_member("sutay", uid=True) print(user1)
os.system('echo %s|sudo modprobe w1-smem' % (sudoPassword)) os.system( 'echo %s|sudo chmod a+w /sys/devices/w1_bus_master1/w1_master_slaves' % (sudoPassword)) os.system( 'echo %s|sudo chmod a+w /sys/devices/w1_bus_master1/w1_master_remove' % (sudoPassword)) os.system( 'echo %s|sudo chmod a+w /sys/devices/w1_bus_master1/w1_master_search' % (sudoPassword)) base_dir = '/sys/devices/w1_bus_master1/w1_master_slaves' delete_dir = '/sys/devices/w1_bus_master1/w1_master_remove' #create an instance instance = csh_ldap.CSHLDAP( "uid=nfatkhiyev,cn=users,cn=accounts,dc=csh,dc=rit,dc=edu", config.PASSWORD) #authentication config file HAROLD_AUTH = config.harold_auth pygame.mixer.init() timeNow = time.localtime() #main function def main(): ID = "" volume = 0.0 #keep the whole program running so it doesn't play one song and stop