Esempio n. 1
0
    def post(self):
        if users.is_current_user_admin():
            oauth_set = False
            webhook_set = False

            github_id = self.request.get('github_id')
            github_secret = self.request.get('github_secret')
            if github_id and github_secret:
                value = {'id': github_id, 'secret': github_secret}
                secrets.put('github_client', value)
                app.config['github_client'] = value
                oauth_set = True
            github_webhook_secret = self.request.get('github_webhook_secret')
            if github_webhook_secret:
                secrets.put('github_webhook_secret',
                            github_webhook_secret,
                            per_host=False)
                webhook_set = True
            self.render(
                'config.html', {
                    'hostname': hostname,
                    'oauth_set': oauth_set,
                    'webhook_set': webhook_set
                })
        else:
            self.abort(403)
Esempio n. 2
0
def get_session_secret():
    try:
        return str(secrets.get('session'))
    except KeyError:
        # Make a new session key -- only happens once per hostname!
        logging.warning('creating new session key!')
        session_key = security.generate_random_string(entropy=256)
        secrets.put('session', session_key)
        return session_key
Esempio n. 3
0
def get_session_secret():
    try:
        return str(secrets.get('session'))
    except KeyError:
        # Make a new session key -- only happens once per hostname!
        logging.warning('creating new session key!')
        session_key = security.generate_random_string(entropy=256)
        secrets.put('session', session_key)
        return session_key
Esempio n. 4
0
    def post(self):
        self.check_csrf()
        if users.is_current_user_admin():
            oauth_set = False
            webhook_set = False
            token_set = False

            github_id = self.request.get('github_id')
            github_secret = self.request.get('github_secret')
            github_token = self.request.get('github_token')
            if github_id and github_secret:
                value = {'id': github_id, 'secret': github_secret}
                secrets.put('github_client', value)
                app.config['github_client'] = value
                oauth_set = True
            github_webhook_secret = self.request.get('github_webhook_secret')
            if github_webhook_secret:
                secrets.put('github_webhook_secret',
                            github_webhook_secret,
                            per_host=False)
                webhook_set = True
            if github_token:
                secrets.put('github_token', github_token, per_host=False)
                token_set = True
            self.render(
                'config.html',
                dict(hostname=hostname,
                     oauth_set=oauth_set,
                     webhook_set=webhook_set,
                     token_set=token_set))
        else:
            self.abort(403)
Esempio n. 5
0
    def post(self):
        self.check_csrf()
        if users.is_current_user_admin():
            oauth_set = False
            webhook_set = False
            token_set = False

            github_id = self.request.get('github_id')
            github_secret = self.request.get('github_secret')
            github_token = self.request.get('github_token')
            if github_id and github_secret:
                value = {'id': github_id, 'secret': github_secret}
                secrets.put('github_client', value)
                app.config['github_client'] = value
                oauth_set = True
            github_webhook_secret = self.request.get('github_webhook_secret')
            if github_webhook_secret:
                secrets.put('github_webhook_secret',
                            github_webhook_secret,
                            per_host=False)
                webhook_set = True
            if github_token:
                secrets.put('github_token', github_token, per_host=False)
                token_set = True
            self.render('config.html',
                        dict(hostname=hostname,
                             oauth_set=oauth_set,
                             webhook_set=webhook_set,
                             token_set=token_set))
        else:
            self.abort(403)
Esempio n. 6
0
    def post(self):
        self.check_csrf()
        if users.is_current_user_admin():
            oauth_set = False
            webhook_set = False
            token_set = False

            github_id = self.request.get('github_id')
            github_secret = self.request.get('github_secret')
            github_token = self.request.get('github_token')
            github_client_key = 'github_client'
            if self.request.get('github_client_host'):
                # enable custom domains pointed at the same app to have their
                # own github oauth config.
                github_client_key = 'github_client_%s' % \
                    self.request.get('github_client_host')
            if github_id and github_secret:
                value = {'id': github_id, 'secret': github_secret}
                secrets.put(github_client_key, value)
                app.config[github_client_key] = value
                oauth_set = True
            github_webhook_secret = self.request.get('github_webhook_secret')
            if github_webhook_secret:
                secrets.put('github_webhook_secret',
                            github_webhook_secret,
                            per_host=False)
                webhook_set = True
            if github_token:
                secrets.put('github_token', github_token, per_host=False)
                token_set = True
            self.render(
                'config.html',
                dict(hostname=hostname,
                     oauth_set=oauth_set,
                     webhook_set=webhook_set,
                     token_set=token_set))
        else:
            self.abort(403)
Esempio n. 7
0
    def post(self):
        self.check_csrf()
        if users.is_current_user_admin():
            oauth_set = False
            webhook_set = False
            token_set = False

            github_id = self.request.get('github_id')
            github_secret = self.request.get('github_secret')
            github_token = self.request.get('github_token')
            github_client_key = 'github_client'
            if self.request.get('github_client_host'):
                # enable custom domains pointed at the same app to have their
                # own github oauth config.
                github_client_key = 'github_client_%s' % \
                    self.request.get('github_client_host')
            if github_id and github_secret:
                value = {'id': github_id, 'secret': github_secret}
                secrets.put(github_client_key, value)
                app.config[github_client_key] = value
                oauth_set = True
            github_webhook_secret = self.request.get('github_webhook_secret')
            if github_webhook_secret:
                secrets.put('github_webhook_secret',
                            github_webhook_secret,
                            per_host=False)
                webhook_set = True
            if github_token:
                secrets.put('github_token', github_token, per_host=False)
                token_set = True
            self.render('config.html',
                        dict(hostname=hostname,
                             oauth_set=oauth_set,
                             webhook_set=webhook_set,
                             token_set=token_set))
        else:
            self.abort(403)
Esempio n. 8
0
 def setUp(self):
     self.init_stubs()
     self.taskqueue = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME)
     secrets.put('github_webhook_secret', 'some_secret', per_host=False)
Esempio n. 9
0
 def setUp(self):
     self.init_stubs()
     self.taskqueue = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME)
     secrets.put('github_token', TOKEN, per_host=False)
     self.gh_data = {}