mirror of
				https://github.com/yuzu-emu/liftinstall.git
				synced 2025-11-04 15:34:52 +00:00 
			
		
		
		
	fix(auth): fix JWT verification
This commit is contained in:
		
							parent
							
								
									7b8bf579f2
								
							
						
					
					
						commit
						61a7db2005
					
				| 
						 | 
				
			
			@ -2,8 +2,6 @@
 | 
			
		|||
//!
 | 
			
		||||
//! Contains Config structures, as well as means of serialising them.
 | 
			
		||||
 | 
			
		||||
use std::collections::HashSet;
 | 
			
		||||
 | 
			
		||||
use toml;
 | 
			
		||||
use toml::de::Error as TomlError;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -68,7 +66,7 @@ pub struct PackageDescription {
 | 
			
		|||
/// Configuration for validating the JWT token
 | 
			
		||||
#[derive(Debug, Serialize, Deserialize, Clone)]
 | 
			
		||||
pub struct JWTValidation {
 | 
			
		||||
    pub iss: Option<HashSet<String>>,
 | 
			
		||||
    pub iss: Option<String>,
 | 
			
		||||
    // This can technically be a Vec as well, but thats a pain to support atm
 | 
			
		||||
    pub aud: Option<String>,
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,7 @@
 | 
			
		|||
//!
 | 
			
		||||
//! Provides mechanisms to authenticate users using JWT.
 | 
			
		||||
 | 
			
		||||
use std::collections::HashSet;
 | 
			
		||||
use std::sync::Arc;
 | 
			
		||||
 | 
			
		||||
use futures::{Future, Stream};
 | 
			
		||||
| 
						 | 
				
			
			@ -142,7 +143,11 @@ pub fn validate_token(
 | 
			
		|||
    let mut validation = match validation {
 | 
			
		||||
        Some(v) => {
 | 
			
		||||
            let mut valid = Validation::new(Algorithm::RS256);
 | 
			
		||||
            valid.iss = v.iss;
 | 
			
		||||
            valid.iss = v.iss.map(|iss| {
 | 
			
		||||
                let mut issuer = HashSet::new();
 | 
			
		||||
                issuer.insert(iss);
 | 
			
		||||
                issuer
 | 
			
		||||
            });
 | 
			
		||||
            if let &Some(ref v) = &v.aud {
 | 
			
		||||
                valid.set_audience(&[v]);
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue