pub fn url_authentication(url: &Url) -> Option<String>Available on crate feature
config only.Expand description
Method to get authentication value out of URL username/password
- If user password is provided, it return Basic authentication with base64 encoded username:password
- If only password is provided, it return Bearer authentication with the password as token
use url::Url;
use prosa_utils::config::url_authentication;
let basic_auth_target = Url::parse("http://user:pass@localhost:8080").unwrap();
assert_eq!(Some(String::from("Basic dXNlcjpwYXNz")), url_authentication(&basic_auth_target));
let bearer_auth_target = Url::parse("http://:token@localhost:8080").unwrap();
assert_eq!(Some(String::from("Bearer token")), url_authentication(&bearer_auth_target));