| 69 | } |
| 70 | |
| 71 | async fn provision_user<S>(&self, user_id: &Uuid, user_info: &S) -> Result<()> |
| 72 | where |
| 73 | S: Serialize, |
| 74 | { |
| 75 | let conf = config::get(); |
| 76 | if conf |
| 77 | .user_authentication |
| 78 | .openid_connect |
| 79 | .registration_callback_url |
| 80 | .is_empty() |
| 81 | { |
| 82 | return Ok(()); |
| 83 | } |
| 84 | |
| 85 | let client = Client::builder().timeout(Duration::from_secs(5)).build()?; |
| 86 | let mut headers = HeaderMap::new(); |
| 87 | headers.insert(CONTENT_TYPE, "application/json".parse().unwrap()); |
| 88 | |
| 89 | let res = client |
| 90 | .post( |
| 91 | &conf |
| 92 | .user_authentication |
| 93 | .openid_connect |
| 94 | .registration_callback_url, |
| 95 | ) |
| 96 | .json(user_info) |
| 97 | .query(&[("user_id", user_id.to_string())]) |
| 98 | .headers(headers) |
| 99 | .send() |
| 100 | .await?; |
| 101 | |
| 102 | match res.error_for_status().context("Provision request error") { |
| 103 | Ok(_) => Ok(()), |
| 104 | Err(e) => Err(e), |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | pub struct DropReceiver<T> { |