Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ jobs:
run: |
cargo build --manifest-path ./portal/Cargo.toml

- name: Build git-credential-oo7
run: |
cargo build --manifest-path ./git-credential/Cargo.toml

- name: Test (native)
run: |
cargo test --manifest-path ./client/Cargo.toml --no-default-features --features tokio --features native_crypto --features schema
Expand Down
8 changes: 8 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"cargo-credential",
"client",
"cli",
"git-credential",
"kwallet/cli",
"kwallet/parser",
"macros",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The repository consists of the following projects:
- [cargo-credential](./cargo-credential/): a [cargo credential](https://doc.rust-lang.org/stable/cargo/reference/registry-authentication.html#registry-authentication) provider
- [cli](./cli/): a secret-tool replacement
- [client](./client/): the client side library
- [git-credential](./git-credential/): a [git credential helper](https://git-scm.com/docs/gitcredentials), replacement for git-credential-libsecret
- [pam](./pam/): PAM integration for the server implementation
- [portal](./portal/): [org.freedesktop.impl.portal.Secret](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.impl.portal.Secret.html) implementation
- [server](./server/): [org.freedesktop.secrets](https://specifications.freedesktop.org/secret-service-spec/latest/) server implementation
Expand Down
16 changes: 8 additions & 8 deletions cargo-credential/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ impl SecretServiceCredential {
return Err(Error::NotFound);
}

let secret = items[0]
.secret()
.await
.map_err(|err| Error::Other(Box::new(err)))?;
let token = Secret::from(
std::str::from_utf8(
&items[0]
.secret()
.await
.map_err(|err| Error::Other(Box::new(err)))?,
)
.unwrap()
.to_owned(),
secret
.as_str()
.ok_or_else(|| Error::Other("secret is not valid UTF-8".into()))?
.to_owned(),
);

Ok(CredentialResponse::Get {
Expand Down
9 changes: 4 additions & 5 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,12 @@ impl ItemOutput {
.unwrap();

let secret_str = secret.map(|s| {
let bytes = s.as_bytes();
if as_hex {
hex::encode(bytes)
hex::encode(s.as_bytes())
} else {
match std::str::from_utf8(bytes) {
Ok(s) => s.to_string(),
Err(_) => hex::encode(bytes),
match s.as_str() {
Some(s) => s.to_string(),
None => hex::encode(s.as_bytes()),
}
}
});
Expand Down
9 changes: 9 additions & 0 deletions client/src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ impl Secret {
}
}

/// Returns the secret as a string slice, or `None` if it is not valid
/// UTF-8.
pub fn as_str(&self) -> Option<&str> {
match self {
Self::Text(text) => Some(text.as_str()),
Self::Blob(bytes) => std::str::from_utf8(bytes).ok(),
}
}

pub fn as_bytes(&self) -> &[u8] {
match self {
Self::Text(text) => text.as_bytes(),
Expand Down
2 changes: 2 additions & 0 deletions coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ grcov coverage-raw/combined.info \
--ignore-not-existing \
--ignore "**/portal/*" \
--ignore "**/python/*" \
--ignore "**/git-credential/*" \
--ignore "**/cli/*" \
--ignore "**/pam/*" \
--ignore "**/tests/*" \
Expand All @@ -74,6 +75,7 @@ grcov coverage-raw/combined.info \
--ignore-not-existing \
--ignore "**/portal/*" \
--ignore "**/python/*" \
--ignore "**/git-credential/*" \
--ignore "**/cli/*" \
--ignore "**/pam/*" \
--ignore "**/tests/*" \
Expand Down
22 changes: 22 additions & 0 deletions git-credential/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "git-credential-oo7"
description = "Git credential helper using oo7"
version.workspace = true
edition.workspace = true
authors.workspace = true
keywords.workspace = true
categories.workspace = true
repository.workspace = true
homepage.workspace = true
license.workspace = true
rust-version.workspace = true
exclude.workspace = true

[dependencies]
oo7 = { workspace = true, features = ["tokio", "schema"] }
tokio = { workspace = true, features = ["macros", "rt"] }

[features]
default = ["native_crypto"]
native_crypto = ["oo7/native_crypto"]
openssl_crypto = ["oo7/openssl_crypto"]
1 change: 1 addition & 0 deletions git-credential/LICENSE
20 changes: 20 additions & 0 deletions git-credential/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

# git-credential-oo7

[![crates.io](https://img.shields.io/crates/v/git-credential-oo7)](https://crates.io/crates/git-credential-oo7)

A [git credential helper](https://git-scm.com/docs/gitcredentials) built using oo7 instead of [libsecret](https://gitlab.gnome.org/GNOME/libsecret).

## Installation

1 - `cargo install git-credential-oo7`

2 - Set as the default credential helper

```
git config --global credential.helper oo7
```

## License

The project is released under the MIT license.
Loading
Loading