Little clean up

This commit is contained in:
Alex Wright 2020-02-23 20:18:00 +01:00
parent 29df4f4b64
commit 10fbaaddb8
1 changed files with 3 additions and 22 deletions

View File

@ -6,15 +6,11 @@ extern crate ldap3;
extern crate tokio; extern crate tokio;
#[macro_use] extern crate log; #[macro_use] extern crate log;
use log::Level;
#[macro_use]
extern crate serde_derive; extern crate serde_derive;
use std::env; use std::env;
use std::io;
use std::fs; use std::fs;
use std::fs::File;
use std::path::Path; use std::path::Path;
use std::str::{ use std::str::{
FromStr, FromStr,
@ -28,13 +24,8 @@ use hyper::header::{AUTHORIZATION};
use hyper_router::{Route, RouterBuilder, RouterService}; use hyper_router::{Route, RouterBuilder, RouterService};
use base64::decode; use base64::decode;
use ring::signature::RsaKeyPair;
use biscuit::{ use biscuit::{
ClaimsSet,
Empty, Empty,
JWT,
RegisteredClaims,
SingleOrMultiple,
}; };
use biscuit::jwa::{ use biscuit::jwa::{
SignatureAlgorithm, SignatureAlgorithm,
@ -47,14 +38,8 @@ use biscuit::jwk::{
JWK, JWK,
JWKSet, JWKSet,
}; };
use biscuit::jws::{
Secret,
RegisteredHeader,
};
use num::BigUint; use num::BigUint;
use openssl::bn::BigNum;
use openssl::rsa::Rsa; use openssl::rsa::Rsa;
use openssl::rsa::RsaPrivateKeyBuilder;
use ldap3::{ LdapConn, Scope, SearchEntry }; use ldap3::{ LdapConn, Scope, SearchEntry };
@ -210,10 +195,6 @@ fn get_keys(_req: Request<Body>) -> Response<Body> {
let jwks: Vec<JWK<Empty>> = fs::read_dir("./").unwrap() let jwks: Vec<JWK<Empty>> = fs::read_dir("./").unwrap()
.filter_map(|dir_entry| { .filter_map(|dir_entry| {
let path = dir_entry.unwrap().path(); let path = dir_entry.unwrap().path();
let filename = match path.file_name() {
Some(filename) => filename.to_str().unwrap().to_owned(),
None => return None,
};
let ext = match path.extension() { let ext = match path.extension() {
Some(ext) => ext.to_str().unwrap().to_owned(), Some(ext) => ext.to_str().unwrap().to_owned(),
None => return None, None => return None,
@ -242,9 +223,9 @@ fn hello(_req: Request<Body>) -> Response<Body> {
fn router_service() -> Result<RouterService, std::io::Error> { fn router_service() -> Result<RouterService, std::io::Error> {
let router = RouterBuilder::new() let router = RouterBuilder::new()
.add(Route::get("/hello").using(hello)) .add(Route::get("/").using(hello))
.add(Route::post("/auth").using(auth_handler)) .add(Route::post("/auth").using(auth_handler))
.add(Route::get("/oauth2/certs").using(get_keys)) .add(Route::get("/oauth2/keys").using(get_keys))
.build(); .build();
Ok(RouterService::new(router)) Ok(RouterService::new(router))
} }
@ -261,6 +242,6 @@ fn main() {
.serve(router_service) .serve(router_service)
.map_err(|e| eprintln!("server error: {}", e)); .map_err(|e| eprintln!("server error: {}", e));
println!("Listening on http://{}", addr); info!("Listening on http://{}", addr);
tokio::run(server); tokio::run(server);
} }