File tree Expand file tree Collapse file tree 4 files changed +35
-15
lines changed Expand file tree Collapse file tree 4 files changed +35
-15
lines changed Original file line number Diff line number Diff line change @@ -853,17 +853,17 @@ impl FileClusterConfig {
853
853
let http_frontend = frontend. to_http_front ( cluster_id) ?;
854
854
frontends. push ( http_frontend) ;
855
855
}
856
- self . authorized_hashes
857
- . iter ( )
858
- . map ( |hash| {
859
- hex:: decode ( hash)
860
- . map_err ( |_| ConfigError :: InvalidHash ( hash. clone ( ) ) )
861
- . and_then ( |v| {
862
- v. try_into ( )
863
- . map_err ( |_| ConfigError :: InvalidHash ( hash. clone ( ) ) )
864
- } )
865
- } )
866
- . collect :: < Result < Vec < [ u8 ; 32 ] > , ConfigError > > ( ) ?;
856
+ // self.authorized_hashes
857
+ // .iter()
858
+ // .map(|hash| {
859
+ // hex::decode(hash)
860
+ // .map_err(|_| ConfigError::InvalidHash(hash.clone()))
861
+ // .and_then(|v| {
862
+ // v.try_into()
863
+ // .map_err(|_| ConfigError::InvalidHash(hash.clone()))
864
+ // })
865
+ // })
866
+ // .collect::<Result<Vec<[u8; 32]>, ConfigError>>()?;
867
867
868
868
Ok ( ClusterConfig :: Http ( HttpClusterConfig {
869
869
cluster_id : cluster_id. to_string ( ) ,
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ include = [
29
29
30
30
[dependencies ]
31
31
anyhow = " ^1.0.89"
32
+ base64 = " 0.22.1"
32
33
cookie-factory = " ^0.3.3"
33
34
hdrhistogram = " ^7.5.4"
34
35
hex = " ^0.4.3"
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use std::{
4
4
str:: { from_utf8, from_utf8_unchecked} ,
5
5
} ;
6
6
7
+ use base64:: Engine ;
7
8
use rusty_ulid:: Ulid ;
8
9
use sha2:: { Digest , Sha256 } ;
9
10
use sozu_command:: logging:: CachedTags ;
@@ -209,9 +210,20 @@ impl HttpContext {
209
210
}
210
211
}
211
212
212
- self . authorization_found = auth
213
- . and_then ( |header| header. val . data_opt ( buf) )
214
- . map ( |auth| hex:: encode ( Sha256 :: digest ( auth) ) ) ;
213
+ self . authorization_found =
214
+ auth. and_then ( |header| header. val . data_opt ( buf) )
215
+ . and_then ( |auth| {
216
+ let ( kind, token) = auth. trim_ascii_start ( ) . split_at ( "Basic " . len ( ) ) ;
217
+ compare_no_case ( kind, b"Basic " ) . then_some ( ( ) ) ?;
218
+ let token = base64:: prelude:: BASE64_STANDARD . decode ( token) . ok ( ) ?;
219
+ let ( name, pwd) = token
220
+ . iter ( )
221
+ . position ( |c| * c == b':' )
222
+ . map ( |i| token. split_at ( i+1 ) ) ?;
223
+ let mut auth = String :: from_utf8 ( name. to_vec ( ) ) . ok ( ) ?;
224
+ auth. push_str ( & hex:: encode ( Sha256 :: digest ( pwd) ) ) ;
225
+ Some ( auth)
226
+ } ) ;
215
227
216
228
// If session_address is set:
217
229
// - append its ip address to the list of "X-Forwarded-For" if it was found, creates it if not
You can’t perform that action at this time.
0 commit comments