Esempio n. 1
0
def _launch_command(port):
    config = _discover_apps()
    command = [
        "panel", "serve", *config.get('apps'), "--allow-websocket-origin=*",
        "--port", f"{port}", "--prefix", "{base_url}panel",
        "--disable-index-redirect"
    ]
    if config.get('autoreload'):
        command.append('--autoreload')
    if config.get('warm'):
        command.append('--warm')
    if 'num_procs' in config:
        command += ['--num-procs', str(config['num_procs'])]
    if 'static_dirs' in config:
        command += ['--static-dirs', *config['static_dirs']]
    if 'oauth_provider' in config:
        from cryptography.fernet import Fernet
        from bokeh.util.token import generate_secret_key
        command += ['--oauth-provider', config['oauth_provider']]
        command += ['--oauth-encryption-key', Fernet.generate_key()]
        command += ['--cookie-secret', generate_secret_key()]
    if 'oauth_key' in config:
        command += ['--oauth-key', config['oauth_key']]
    if 'oauth_secret' in config:
        command += ['--oauth-secret', config['oauth_secret']]
    if 'oauth_redirect_uri' in config:
        command += ['--oauth-redirect-uri', config['oauth_redirect_uri']]
    if 'oauth_jwt_user' in config:
        command += ['--oauth-jtw-user', config['oauth_jwt_user']]
    if 'oauth_extra_params' in config:
        command += ['--oauth-extra-params', repr(config['oauth_extra_params'])]
    if 'index' in config:
        command += ['--index', str(pathlib.Path(config['index']).absolute())]
    return command
Esempio n. 2
0
    def invoke(self, args: Namespace) -> None:
        '''

        '''
        key = generate_secret_key()

        # suppress LGTM, since the intent is precisesly to output a secret
        print(key)  # lgtm [py/clear-text-logging-sensitive-data]
Esempio n. 3
0
 def test_generate_secret_key(self) -> None:
     key = generate_secret_key()
     assert 44 == len(key)
     key2 = generate_secret_key()
     assert 44 == len(key2)
     assert key != key2