-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use axum::{http::StatusCode, routing::get, Router}; | ||
use josekit::jwe::{deserialize_json, RSA_OAEP_256}; | ||
use josekit::jwk::Jwk; | ||
const KEY: &str = r#"{ | ||
"kty": "RSA", | ||
"n": "tX4yurmjaH70PEgrVcrq6syvAzWCp3EvLmoYeq4JSQruT3r0fsEN_3iRNQ13VALZSL_k9xidlYEDqhNN6owui3uql6L8UrhmhhOeNOOYI4YOpTa9Yda_yuYFii6o_NrOpHv4LmrMzLzCX7kPW3j4GNiS7vYkwGI0n1mtVGqpYs9jic4GR3Be-kBMgNpZanJk9OA2LKf1cyh2n5LkU9lO15ZszvKfA9u_08A5s62b9_MhjEVlmENUWXGJzZtx-pZMWZwZFjV2KrEoCY3BykmwSSNyhdxN1NKp-l3_plOLop96G621k8tabctHbS565BpmDiKT5rNymXDZWpiYod6gpQ", | ||
"e": "AQAB", | ||
"d": "LYTySjzHDC1TKk9bdxAGrU8a0e44z7AmijiX3SULNSOls49-BNB8p0dg-_JdrFdukb13OrYUx-tstNpUn2_7OIaSuadqK4EOTbBb7J3siXRU9gDtrL1EqynX19luDsT-MOjazSGCLhNlmMZ8YI_NgcXHzGE1xH6c_h5qx5Jc22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WY" | ||
} | ||
"#; | ||
|
||
pub fn router() -> Router { | ||
Router::new() | ||
.route("/tiebreaker/health", get(|| async { StatusCode::OK })) | ||
.route("/tiebreaker/naughty_list", get(naughty_list)) | ||
} | ||
|
||
async fn naughty_list() { | ||
let key = Jwk::from_bytes(KEY.as_bytes()).unwrap(); | ||
let client = reqwest::Client::new(); | ||
let response = client | ||
.get("https://www.codehunt.rs/api/naughty") | ||
.header("Authorization", "Bearer Lb7bB6PyL1kP0hU2") | ||
.send() | ||
.await | ||
.unwrap(); | ||
let encrypted = response.text().await.unwrap(); | ||
println!("{:?}", encrypted); | ||
let decrypter = RSA_OAEP_256.decrypter_from_jwk(&key).unwrap(); | ||
|
||
let (payload, _) = deserialize_json(&encrypted, &decrypter).unwrap(); | ||
|
||
println!("{:?}", payload) | ||
} |