Skip to content

Commit e50eaf5

Browse files
chore: bump deps and ac version (#1394)
* chore: bump deps and ac version * chore: address nr-auth v0.0.7 breaking changes * chore: update license notices file * fix test * chore: remove unneeded TODO --------- Co-authored-by: David Sánchez <[email protected]>
1 parent ddbc0ae commit e50eaf5

File tree

7 files changed

+103
-42
lines changed

7 files changed

+103
-42
lines changed

Cargo.lock

Lines changed: 61 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

THIRD_PARTY_NOTICES.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,13 @@ Distributed under the following license(s):
17791779
* MIT
17801780
* Apache-2.0
17811781

1782+
## rcgen <https://crates.io/crates/rcgen>
1783+
1784+
Distributed under the following license(s):
1785+
1786+
* MIT
1787+
* Apache-2.0
1788+
17821789
## redox_syscall <https://crates.io/crates/redox_syscall>
17831790

17841791
Distributed under the following license(s):
@@ -2673,6 +2680,13 @@ Distributed under the following license(s):
26732680
* MIT
26742681
* Apache-2.0
26752682

2683+
## yasna <https://crates.io/crates/yasna>
2684+
2685+
Distributed under the following license(s):
2686+
2687+
* MIT
2688+
* Apache-2.0
2689+
26762690
## yoke <https://crates.io/crates/yoke>
26772691

26782692
Distributed under the following license(s):

agent-control/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "newrelic_agent_control"
33
description = "New Relic Agent Control Limited Preview"
4-
version = "0.39.0"
4+
version = "0.40.0"
55
authors.workspace = true
66
edition.workspace = true
77
rust-version.workspace = true
@@ -36,8 +36,8 @@ chrono = { workspace = true }
3636
base64 = { version = "0.22.1" }
3737
# New Relic dependencies (private external repos)
3838
# IMPORTANT: GitHub deployment keys are used to access these repos on the CI/CD pipelines
39-
nr-auth = { git = "https://github.com/newrelic/newrelic-auth-rs.git", tag = "0.0.4" }
40-
opamp-client = { git = "https://github.com/newrelic/newrelic-opamp-rs.git", tag = "0.0.33" }
39+
nr-auth = { git = "https://github.com/newrelic/newrelic-auth-rs.git", tag = "0.0.8" }
40+
opamp-client = { git = "https://github.com/newrelic/newrelic-opamp-rs.git", tag = "0.0.34" }
4141
# local dependencies
4242
fs = { path = "../fs" }
4343
wrapper_with_default = { path = "../wrapper_with_default" }
@@ -91,7 +91,7 @@ jsonwebtoken = { workspace = true }
9191
fs = { path = "../fs", features = ["mocks"] }
9292
tokio = { version = "1.44.0", features = ["rt-multi-thread", "macros"] }
9393
fake = { version = "4.0.0", features = ["derive", "http"] }
94-
prost = "0.13.5"
94+
prost = "0.14"
9595
# Alpha version needed to test proxy the feature, it is safe because it is only used as dev-dependency
9696
httpmock = { version = "0.8.0-alpha.1", features = ["proxy"] }
9797
serial_test = "3.2.0"

agent-control/src/opamp/auth/config.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
use std::path::PathBuf;
22

3+
use http::Uri;
34
use nr_auth::ClientID;
45
use serde::Deserialize;
5-
use url::Url;
66

77
use crate::agent_control::defaults::AUTH_PRIVATE_KEY_FILE_NAME;
88

99
/// Authorization configuration used by the OpAmp connection to NewRelic.
1010
#[derive(Debug, Deserialize, PartialEq, Clone)]
1111
pub struct AuthConfig {
1212
/// Endpoint to obtain the access token presenting the client id and secret.
13-
pub token_url: Url,
13+
#[serde(with = "http_serde::uri")]
14+
pub token_url: Uri,
1415
/// Auth client id associated with the provided key.
1516
pub client_id: ClientID,
1617
/// Method to sign the client secret used to retrieve the access token.
@@ -51,7 +52,7 @@ impl LocalConfig {
5152
mod tests {
5253
use std::{path::PathBuf, str::FromStr};
5354

54-
use url::Url;
55+
use http::Uri;
5556

5657
use crate::opamp::auth::config::{AuthConfig, LocalConfig, ProviderConfig};
5758

@@ -80,7 +81,7 @@ private_key_path: "path/to/key"
8081
),
8182
expected: AuthConfig {
8283
client_id: "fake".into(),
83-
token_url: Url::from_str("http://fake.com/oauth2/v1/token").unwrap(),
84+
token_url: Uri::from_str("http://fake.com/oauth2/v1/token").unwrap(),
8485
provider: Some(ProviderConfig::Local(LocalConfig {
8586
private_key_path: PathBuf::from("path/to/key"),
8687
})),
@@ -96,7 +97,7 @@ client_id: "fake"
9697
),
9798
expected: AuthConfig {
9899
client_id: "fake".into(),
99-
token_url: Url::from_str("http://fake.com/oauth2/v1/token").unwrap(),
100+
token_url: Uri::from_str("http://fake.com/oauth2/v1/token").unwrap(),
100101
provider: None,
101102
retries: 0u8,
102103
},
@@ -111,7 +112,7 @@ retries: 3
111112
),
112113
expected: AuthConfig {
113114
client_id: "fake".into(),
114-
token_url: Url::from_str("http://fake.com/oauth2/v1/token").unwrap(),
115+
token_url: Uri::from_str("http://fake.com/oauth2/v1/token").unwrap(),
115116
provider: None,
116117
retries: 3u8,
117118
},

agent-control/src/opamp/auth/token_retriever.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub enum TokenRetrieverImplError {
2727
}
2828

2929
// Just an alias to make the code more readable
30-
type TokenRetrieverHttp = TokenRetrieverWithCache<HttpAuthenticator<HttpClient>>;
30+
type TokenRetrieverHttp = TokenRetrieverWithCache<HttpAuthenticator<HttpClient>, JwtSignerImpl>;
3131

3232
/// Enumerates all implementations for `TokenRetriever` for static dispatching reasons.
3333
#[allow(clippy::large_enum_variant)]
@@ -75,7 +75,7 @@ impl TokenRetrieverImpl {
7575
let authenticator = HttpAuthenticator::new(client, ac.token_url.clone());
7676

7777
Ok(Self::HttpTR(
78-
TokenRetrieverHttp::new(ac.client_id, jwt_signer, authenticator)
78+
TokenRetrieverHttp::new_with_jwt_signer(ac.client_id, authenticator, jwt_signer)
7979
.with_retries(ac.retries),
8080
))
8181
}

agent-control/tests/k8s/agent_control_cli/upgrade_local_vs_remote.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ use std::time::Duration;
2525
fn k8s_cli_local_and_remote_updates() {
2626
let mut k8s_env = block_on(K8sEnv::new());
2727
let namespace = block_on(k8s_env.test_namespace());
28-
let k8s_client = Arc::new(SyncK8sClient::try_new(tokio_runtime(), namespace.clone()).unwrap());
28+
let k8s_client =
29+
Arc::new(SyncK8sClient::try_from_namespace(tokio_runtime(), namespace.clone()).unwrap());
2930

3031
create_simple_values_secret(
3132
k8s_env.client.clone(),

agent-control/tests/on_host/opamp_auth.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ use httpmock::Method::POST;
55
use httpmock::{MockServer, When};
66
use jsonwebtoken::{Algorithm, DecodingKey, Validation};
77
use newrelic_agent_control::agent_control::defaults::AGENT_CONTROL_CONFIG_FILENAME;
8-
use nr_auth::authenticator::{Request, Response};
8+
use nr_auth::authenticator::{AuthCredential, TokenRetrievalRequest, TokenRetrievalResponse};
99
use nr_auth::jwt::claims::Claims;
10-
use nr_auth::token_retriever::DEFAULT_AUDIENCE;
1110
use predicates::prelude::predicate;
1211
use std::path::PathBuf;
1312
use std::time::Duration;
1413
use tempfile::TempDir;
1514

15+
const DEFAULT_AUDIENCE: &str = "https://www.newrelic.com/";
16+
1617
#[test]
1718
#[ignore = "requires root"]
1819
fn test_auth_local_provider_as_root() {
@@ -199,7 +200,7 @@ fn auth_server(token: String) -> MockServer {
199200
.header(CONTENT_TYPE.as_str(), "application/json")
200201
.and(is_authorized);
201202
then.json_body(
202-
serde_json::to_value(Response {
203+
serde_json::to_value(TokenRetrievalResponse {
203204
access_token: token,
204205
token_type: "bearer".to_string(),
205206
expires_in: 10,
@@ -213,17 +214,24 @@ fn auth_server(token: String) -> MockServer {
213214

214215
fn is_authorized(when: When) -> When {
215216
when.is_true(|req| {
216-
let request: Request = serde_json::from_slice(req.body_ref()).unwrap();
217+
let request: TokenRetrievalRequest = serde_json::from_slice(req.body_ref()).unwrap();
217218

218219
// Validation
219220
let mut validation = Validation::new(Algorithm::RS256);
220221
validation.sub = Some(request.client_id.to_owned());
221222
validation.set_audience(&[DEFAULT_AUDIENCE]);
222223
validation.set_required_spec_claims(&["exp", "sub", "aud"]);
223224

225+
let AuthCredential::ClientAssertion {
226+
client_assertion, ..
227+
} = &request.credential
228+
else {
229+
return false;
230+
};
231+
224232
// Decode the signed token
225233
jsonwebtoken::decode::<Claims>(
226-
&request.client_assertion,
234+
client_assertion,
227235
&DecodingKey::from_rsa_pem(RS256_PUBLIC_KEY.as_bytes()).unwrap(),
228236
&validation,
229237
)

0 commit comments

Comments
 (0)