Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend KBS to provide the resources required to create an encrypted overlay network #451

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 73 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ config = "0.13.3"
env_logger = "0.10.0"
hex = "0.4.3"
jwt-simple = "0.11"
kbs_protocol = { git = "https://github.com/confidential-containers/guest-components.git", rev="9bd6f06a9704e01808e91abde130dffb20e632a5", default-features = false }
kbs_protocol = { git = "https://github.com/confidential-containers/guest-components.git", rev="0d08cccf3c72647de273fee90716d6842b9ddcfd", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also update the version of kms as they come from the same repo.

kbs-types = "0.6.0"
kms = { git = "https://github.com/confidential-containers/guest-components.git", rev="9bd6f06a9704e01808e91abde130dffb20e632a5", default-features = false }
jsonwebtoken = { version = "9", default-features = false }
log = "0.4.17"
log = "0.4.22"
prost = "0.12"
regorus = { version = "0.1.5", default-features = false, features = ["regex", "base64", "time"] }
reqwest = "0.12"
rstest = "0.18.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.89"
serde_qs = "0.13.0"
serde_with = { version = "1.11.0", features = ["base64", "hex"] }
serial_test = "0.9.0"
sha2 = "0.10"
Expand All @@ -49,4 +50,4 @@ thiserror = "1.0"
tokio = { version = "1", features = ["full"] }
tempfile = "3.4.0"
tonic = "0.11"
tonic-build = "0.11"
tonic-build = "0.11"
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ services:
command: [
"/usr/local/bin/kbs",
"--config-file",
"/etc/kbs-config.toml",
"/etc/kbs/kbs-config.toml",
]
restart: always # keep the server running
ports:
- "8080:8080"
volumes:
- ./kbs/data/kbs-storage:/opt/confidential-containers/kbs/repository:rw
- ./kbs/data/kbs-storage:/opt/confidential-containers/kbs/storage:rw
- ./kbs/data/kbs-plugin:/opt/confidential-containers/kbs/plugin:rw
- ./kbs/config/public.pub:/opt/confidential-containers/kbs/user-keys/public.pub
- ./kbs/config/docker-compose/kbs-config.toml:/etc/kbs-config.toml
- ./kbs/config/docker-compose/kbs-config.toml:/etc/kbs/kbs-config.toml
- ./kbs/config/plugin/nebula-config.toml:/etc/kbs/plugin/nebula-config.toml
depends_on:
- as

Expand Down
6 changes: 4 additions & 2 deletions kbs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ rustls = ["actix-web/rustls", "dep:rustls", "dep:rustls-pemfile"]

# Use openssl crypto stack for KBS
openssl = ["actix-web/openssl", "dep:openssl"]
nebula-plugin = []

# Use aliyun KMS as KBS backend
aliyun = ["kms/aliyun"]
Expand Down Expand Up @@ -76,16 +77,17 @@ semver = "1.0.16"
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
strum.workspace = true
serde_qs.workspace = true
thiserror.workspace = true
time = { version = "0.3.23", features = ["std"] }
tokio.workspace = true
tonic = { workspace = true, optional = true }
uuid = { version = "1.2.2", features = ["serde", "v4"] }
openssl = { version = "0.10.46", optional = true }
tempfile.workspace = true

[dev-dependencies]
tempfile.workspace = true
rstest.workspace = true

[build-dependencies]
tonic-build = { workspace = true, optional = true }
tonic-build = { workspace = true, optional = true }
12 changes: 11 additions & 1 deletion kbs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ AS_TYPE ?= coco-as
HTTPS_CRYPTO ?= rustls
POLICY_ENGINE ?=
ALIYUN ?= false
PLUGINS ?=

ARCH := $(shell uname -m)
# Check if ARCH is supported, otehrwise return error
Expand All @@ -24,9 +25,18 @@ else
endif

ifeq ($(ALIYUN), true)
FEATURES += aliyun
FEATURE_LIST += aliyun
endif

ifdef PLUGINS
FEATURE_LIST += $(PLUGINS)
endif

NOOP =
SPACE = $(NOOP) $(NOOP)
COMMA = ,
FEATURES=$(subst $(SPACE),$(COMMA),$(FEATURE_LIST))

ifndef CLI_FEATURES
ifdef ATTESTER
CLI_FEATURES = "sample_only,$(ATTESTER)"
Expand Down
8 changes: 8 additions & 0 deletions kbs/config/docker-compose/kbs-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ sockets = ["0.0.0.0:8080"]
auth_public_key = "/opt/confidential-containers/kbs/user-keys/public.pub"
insecure_http = true

[repository_config]
type = "LocalFs"
dir_path = "/opt/confidential-containers/kbs/storage"

[plugin_manager_config]
work_dir = "/opt/confidential-containers/kbs/plugin"
enabled_plugins = []

Copy link
Member

@Xynnn007 Xynnn007 Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would have an overall workdir for all plugins. Maybe we should let every single plugin has its own configs, like the workdir of them own?

Some config format in my mind

insecure_http = true
insecure_api = true

[attestation_token_config]
attestation_token_type = "CoCo"

[grpc_config]
as_addr = "http://127.0.0.1:50004"
pool_size = 200

[repository_config]
type = "LocalFs"
dir_path = "/opt/confidential-containers/kbs/storage"

[plugins.nebula]
config_path = "/etc/kbs/plugin/nebula-config.toml"

[plugins.another]
config_a=xxx
config_b=yyy

If only [plugins.nebula] is explicitly specified in the toml, nebula be initialized. In this way every single plugin could have its own config, or specify the config path inside that.

This could be implemented via

#[derive(Clone, Debug, Deserialize)]
pub struct KbsConfig {
...
    pub plugins: Option<PluginManagerConfig>,
}

#[derive(Clone, Debug, Deserialize)]
struct PluginManagerConfig {
    #[cfg(feature = "nebula-plugin")]
    nebula: Option<NebulaConfig>,

    #[cfg(feature = "another-plugin")]
    another: Option<AnotherPluginConfig>,
}

#[cfg(feature = "nebula-plugin")]
#[derive(Clone, Debug, Deserialize)]
struct NebulaConfig {
    config_path: String,
}

#[cfg(feature = "another-plugin")]
#[derive(Clone, Debug, Deserialize)]
struct AnotherPluginConfig {
    config_a:  String,
    config_b: String,
}

[attestation_token_config]
attestation_token_type = "CoCo"

Expand Down
6 changes: 5 additions & 1 deletion kbs/config/kbs-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ attestation_token_type = "CoCo"

[repository_config]
type = "LocalFs"
dir_path = "/opt/confidential-containers/kbs/repository"
dir_path = "/opt/confidential-containers/kbs/storage"

[plugin_manager_config]
work_dir = "/opt/confidential-containers/kbs/plugin"
enabled_plugins = []

[as_config]
work_dir = "/opt/confidential-containers/attestation-service"
Expand Down
Loading
Loading