diff --git a/Cargo.toml b/Cargo.toml index 23fb527..5dd188b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,3 +14,7 @@ base64 = "0.10.0" serde = "1.0.40" serde_json = "1.0.40" serde_derive = "1.0.40" +biscuit = "0.3.1" +ring = "0.16.5" +num = "0.2" +openssl = "0.10.28" diff --git a/src/main.rs b/src/main.rs index 62ce75d..d8f8413 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ #![deny(warnings)] +extern crate biscuit; extern crate base64; extern crate hyper; extern crate ldap3; @@ -8,6 +9,10 @@ extern crate tokio; extern crate serde_derive; use std::env; +use std::io; +use std::fs; +use std::fs::File; +use std::path::Path; use std::str::{ FromStr, from_utf8, @@ -20,6 +25,34 @@ use hyper::header::{AUTHORIZATION}; use hyper_router::{Route, RouterBuilder, RouterService}; use base64::decode; +use ring::signature::RsaKeyPair; +use biscuit::{ + ClaimsSet, + Empty, + JWT, + RegisteredClaims, + SingleOrMultiple, +}; +use biscuit::jwa::{ + SignatureAlgorithm, + Algorithm, +}; +use biscuit::jwk::{ + RSAKeyParameters, + CommonParameters, + AlgorithmParameters, + JWK, + JWKSet, +}; +use biscuit::jws::{ + Secret, + RegisteredHeader, +}; +use num::BigUint; +use openssl::bn::BigNum; +use openssl::rsa::Rsa; +use openssl::rsa::RsaPrivateKeyBuilder; + use ldap3::{ LdapConn, Scope, SearchEntry }; #[derive(Debug)] @@ -152,30 +185,48 @@ fn auth_handler(req: Request
) -> Response { Response::new(Body::from(format!("BasicAuthentication {:?}", user))) } -#[derive(Debug, Serialize)] -struct Key { - pub e: String, -} - -#[derive(Debug, Serialize)] -struct JwksResponse { - pub keys: Vec