tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
11.53k stars 286 forks source link

docker image v0.23.0 fails with Invalid HTTP Basic configuration #1090

Open eznix86 opened 8 months ago

eznix86 commented 8 months ago

My config:

services:
  turso:
    image: ghcr.io/tursodatabase/libsql-server:v0.23.0@sha256:2e5fca03933b72de748cc0370cdbf494b82e010c7df98904f6ab2ff06b571fce
    ports:
      - "8080:8080"
    volumes:
      - ./turso:/var/lib/sqld
    environment:
      - RUST_BACKTRACE=full

results:

turso-1  |            _     _ 
turso-1  |  ___  __ _| | __| |
turso-1  | / __|/ _` | |/ _` |
turso-1  | \__ \ (_| | | (_| |
turso-1  | |___/\__, |_|\__,_|
turso-1  |         |_|        
turso-1  | 
turso-1  | Welcome to sqld!
turso-1  | 
turso-1  | version: 0.23.0
turso-1  | commit SHA: 52d8b8f1c4b7bff3582dfd7a1761123b13cf24aa
turso-1  | build date: 2024-02-26
turso-1  | 
turso-1  | This software is in BETA version.
turso-1  | If you encounter any bug, please open an issue at https://github.com/tursodatabase/libsql/issues
turso-1  | 
turso-1  | config:
turso-1  |      - mode: primary (0.0.0.0:5001)
turso-1  |      - database path: iku.db
turso-1  |      - extensions path: <disabled>
turso-1  |      - listening for HTTP requests on: 0.0.0.0:8080
turso-1  |      - grpc_tls: no
turso-1  | 2024-02-27T06:42:56.572227Z  INFO sqld: listening for incoming user HTTP connection on 0.0.0.0:8080
turso-1  | 2024-02-27T06:42:56.579515Z  INFO sqld: Using legacy HTTP basic authentication
turso-1  | thread 'main' panicked at libsql-server/src/main.rs:382:51:
turso-1  | Invalid HTTP Basic configuration
turso-1  | stack backtrace:
turso-1  |    0:       0x55016fcbac - std::backtrace_rs::backtrace::libunwind::trace::h02f9e4f4471336e3
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
turso-1  |    1:       0x55016fcbac - std::backtrace_rs::backtrace::trace_unsynchronized::hbb08758edbde5130
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
turso-1  |    2:       0x55016fcbac - std::sys_common::backtrace::_print_fmt::h5f86860630063d58
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:67:5
turso-1  |    3:       0x55016fcbac - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h28b1846dca2a17cc
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:44:22
turso-1  |    4:       0x550172af18 - core::fmt::rt::Argument::fmt::h4597596d5e31f449
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/rt.rs:142:9
turso-1  |    5:       0x550172af18 - core::fmt::write::h76788fb7851cda1c
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/mod.rs:1120:17
turso-1  |    6:       0x55016f945c - std::io::Write::write_fmt::h8c2b0771a274739d
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/io/mod.rs:1762:15
turso-1  |    7:       0x55016fc9dc - std::sys_common::backtrace::_print::hbe1ff52860729255
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:47:5
turso-1  |    8:       0x55016fc9dc - std::sys_common::backtrace::print::h13ddc61648c1b5cf
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:34:9
turso-1  |    9:       0x55016fe2ac - std::panicking::default_hook::{{closure}}::h3fb06cc4fa27f844
turso-1  |   10:       0x55016fdfd8 - std::panicking::default_hook::h585763c48ee63ab9
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:292:9
turso-1  |   11:       0x55016fe754 - std::panicking::rust_panic_with_hook::h25ba8e750f603eed
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:779:13
turso-1  |   12:       0x55016fe60c - std::panicking::begin_panic_handler::{{closure}}::he88f9d300c5c2c0b
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:657:13
turso-1  |   13:       0x55016fd054 - std::sys_common::backtrace::__rust_end_short_backtrace::h9c4571cb251fdb49
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
turso-1  |   14:       0x55016fe398 - rust_begin_unwind
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
turso-1  |   15:       0x550025978c - core::panicking::panic_fmt::h83f4337bb6f332d3
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
turso-1  |   16:       0x5500259758 - core::panicking::panic_display::h00b421c6fa1dc577
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:178:5
turso-1  |   17:       0x5500259758 - core::panicking::panic_str::h766107583bbe6c82
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:152:5
turso-1  |   18:       0x5500259758 - core::option::expect_failed::h303682c289bce6b7
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/option.rs:1985:5
turso-1  |   19:       0x5500777bcc - sqld::build_server::{{closure}}::h00d6a0a490701e80
turso-1  |   20:       0x550078bc60 - sqld::main::{{closure}}::haffa42c45d5f90bd
turso-1  |   21:       0x5500690f08 - tokio::runtime::context::blocking::BlockingRegionGuard::block_on::h32469a4844132350
turso-1  |   22:       0x550078949c - sqld::main::h367d407faa27b622
turso-1  |   23:       0x5500491570 - std::sys_common::backtrace::__rust_begin_short_backtrace::h9caa3ed40ace05a9
turso-1  |   24:       0x5500494cb4 - std::rt::lang_start::{{closure}}::h8c1f007f35b7fe54
turso-1  |   25:       0x55016ef7e0 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h6f396e33163198d5
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:284:13
turso-1  |   26:       0x55016ef7e0 - std::panicking::try::do_call::h6a321d44b3abf5fc
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
turso-1  |   27:       0x55016ef7e0 - std::panicking::try::h0eb42c098714b2f3
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
turso-1  |   28:       0x55016ef7e0 - std::panic::catch_unwind::hf07fd6e09bae57e2
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
turso-1  |   29:       0x55016ef7e0 - std::rt::lang_start_internal::{{closure}}::h398d9caf4abe015f
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:48
turso-1  |   30:       0x55016ef7e0 - std::panicking::try::do_call::h91387d694f1e2364
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
turso-1  |   31:       0x55016ef7e0 - std::panicking::try::hcc8c1230bee4591e
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
turso-1  |   32:       0x55016ef7e0 - std::panic::catch_unwind::h6bd43d0557e29b10
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
turso-1  |   33:       0x55016ef7e0 - std::rt::lang_start_internal::hea39f29bda0ceae5
turso-1  |                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:20
turso-1  |   34:       0x5500494c9c - std::rt::lang_start::h1b7c04505c9eb206
turso-1  |   35:       0x550078d030 - main
turso-1  |   36:       0x5504896e18 - __libc_start_main
turso-1  |   37:       0x5500259d8c - <unknown>
turso-1 exited with code 101
eznix86 commented 8 months ago

Fixed with:

echo -n "admin:admin" | base64     
# outputs YWRtaW46YWRtaW4=
services:
  turso:
    image: ghcr.io/tursodatabase/libsql-server:v0.23.0@sha256:2e5fca03933b72de748cc0370cdbf494b82e010c7df98904f6ab2ff06b571fce
    ports:
      - "8080:8080"
    volumes:
      - ./turso:/var/lib/sqld
    environment:
      - RUST_BACKTRACE=full
      - SQLD_HTTP_AUTH=basic:YWRtaW46YWRtaW4=

Recommendation:

If auth is not specified generate one and echo one:

if [ -z "${SQLD_HTTP_AUTH}" ]; then
    # Generate a random password
    PASSWORD=$(openssl rand -base64 10)

    # Encode the username:password pair in Base64
    ENCODED=$(echo -n "turso:${PASSWORD}" | base64)

    # Display the encoded value
    echo "${ENCODED}"

    # Display the password in the specified format
    echo "Basic HTTP_AUTH is \"turso:${PASSWORD}\""
else
    echo "SQLD_HTTP_AUTH is already set."
fi
LucioFranco commented 8 months ago

This should be fixed on main with the latest docker container and with https://github.com/tursodatabase/libsql/pull/1098

eznix86 commented 8 months ago

There is NO documentation specifying other method of authentication. Can you please redirect or write a quick doc to how to authentication without basic auth ?

Does this mean when the docker run there is no authentication ?