Little clean up
This commit is contained in:
parent
29df4f4b64
commit
10fbaaddb8
25
src/main.rs
25
src/main.rs
|
@ -6,15 +6,11 @@ extern crate ldap3;
|
|||
extern crate tokio;
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
use log::Level;
|
||||
|
||||
#[macro_use]
|
||||
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,
|
||||
|
@ -28,13 +24,8 @@ 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,
|
||||
|
@ -47,14 +38,8 @@ use biscuit::jwk::{
|
|||
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 };
|
||||
|
||||
|
@ -210,10 +195,6 @@ fn get_keys(_req: Request<Body>) -> Response<Body> {
|
|||
let jwks: Vec<JWK<Empty>> = fs::read_dir("./").unwrap()
|
||||
.filter_map(|dir_entry| {
|
||||
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() {
|
||||
Some(ext) => ext.to_str().unwrap().to_owned(),
|
||||
None => return None,
|
||||
|
@ -242,9 +223,9 @@ fn hello(_req: Request<Body>) -> Response<Body> {
|
|||
|
||||
fn router_service() -> Result<RouterService, std::io::Error> {
|
||||
let router = RouterBuilder::new()
|
||||
.add(Route::get("/hello").using(hello))
|
||||
.add(Route::get("/").using(hello))
|
||||
.add(Route::post("/auth").using(auth_handler))
|
||||
.add(Route::get("/oauth2/certs").using(get_keys))
|
||||
.add(Route::get("/oauth2/keys").using(get_keys))
|
||||
.build();
|
||||
Ok(RouterService::new(router))
|
||||
}
|
||||
|
@ -261,6 +242,6 @@ fn main() {
|
|||
.serve(router_service)
|
||||
.map_err(|e| eprintln!("server error: {}", e));
|
||||
|
||||
println!("Listening on http://{}", addr);
|
||||
info!("Listening on http://{}", addr);
|
||||
tokio::run(server);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue