Skip to content

Commit

Permalink
Initial work on changing to oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
augustuswm committed Sep 8, 2023
1 parent 0cc1b8d commit 6a38743
Show file tree
Hide file tree
Showing 31 changed files with 1,424 additions and 695 deletions.
3 changes: 3 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 @@ -48,6 +48,7 @@ octorust = "0.7.0-rc.1"
partial-struct = { git = "https://github.com/oxidecomputer/partial-struct" }
progenitor = { git = "https://github.com/oxidecomputer/progenitor" }
progenitor-client = { git = "https://github.com/oxidecomputer/progenitor" }
rand = "0.8.5"
rand_core = "0.6"
regex = "1.7.1"
reqwest = { version = "0.11", features = ["json", "stream"] }
Expand Down
2 changes: 2 additions & 0 deletions rfd-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ dropshot = { workspace = true }
dropshot-authorization-header = { path = "../dropshot-authorization-header" }
dropshot-verified-body = { workspace = true, features = ["github"] }
google-cloudkms1 = { workspace = true }
hex = { workspace = true }
http = { workspace = true }
hyper = { workspace = true }
hyper-tls = { workspace = true }
jsonwebtoken = { workspace = true }
oauth2 = { workspace = true }
octorust = { workspace = true }
partial-struct = { workspace = true }
rand = { workspace = true, features = ["std"] }
rand_core = { workspace = true, features = ["std"] }
regex = { workspace = true }
reqwest = { workspace = true }
Expand Down
14 changes: 7 additions & 7 deletions rfd-api/src/authn/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use thiserror::Error;
use tracing::instrument;
use uuid::Uuid;

use crate::{config::JwtKey, context::ApiContext, ApiPermissions};
use crate::{config::AsymmetricKey, context::ApiContext, ApiPermissions};

#[derive(Debug, Error)]
pub enum JwtError {
Expand Down Expand Up @@ -168,7 +168,7 @@ pub enum CloudKmsError {

// Signer that relies on a private key stored in GCP, and a locally store JWK. This signer never
// has direct access to the private key
pub struct CloudKmSigner {
pub struct CloudKmsSigner {
client: CloudKMS<HttpsConnector<HttpConnector>>,
key_name: String,
header: Header,
Expand All @@ -187,7 +187,7 @@ pub struct CloudKmsSignatureResponse {
}

#[async_trait]
impl JwtSigner for CloudKmSigner {
impl JwtSigner for CloudKmsSigner {
type Claims = Claims;

#[instrument(skip(self, claims), err(Debug))]
Expand Down Expand Up @@ -302,10 +302,10 @@ fn pem_to_jwk(id: &str, pem: &str) -> Result<Jwk, SignerError> {

#[instrument(skip(key), err(Debug))]
pub async fn key_to_signer(
key: &JwtKey,
key: &AsymmetricKey,
) -> Result<Box<dyn JwtSigner<Claims = Claims>>, SignerError> {
Ok(match key {
JwtKey::Local {
AsymmetricKey::Local {
kid,
private,
public,
Expand All @@ -322,7 +322,7 @@ pub async fn key_to_signer(
jwk,
})
}
JwtKey::Ckms {
AsymmetricKey::Ckms {
kid,
version,
key,
Expand Down Expand Up @@ -399,7 +399,7 @@ pub async fn key_to_signer(

tracing::trace!(?header, ?jwk, "Generated Cloud KMS signer");

Box::new(CloudKmSigner {
Box::new(CloudKmsSigner {
client: gcp_kms,
key_name,
header,
Expand Down
Loading

0 comments on commit 6a38743

Please sign in to comment.