Skip to content
Snippets Groups Projects
Verified Commit 5fb2a6b1 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

[PAM] Store user access token in cache after successful authentication

parent 000213ee
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,8 @@ use crate::oauth::get_access_token_password; ...@@ -24,6 +24,8 @@ use crate::oauth::get_access_token_password;
use crate::logging::setup_log; use crate::logging::setup_log;
use crate::cache::CACHE;
use pamsm::{PamServiceModule, Pam, PamFlag, PamError, PamLibExt}; use pamsm::{PamServiceModule, Pam, PamFlag, PamError, PamLibExt};
fn pam_sm_prepare(argv: &Vec<String>) -> Config { fn pam_sm_prepare(argv: &Vec<String>) -> Config {
...@@ -86,8 +88,9 @@ impl PamServiceModule for PamOidc { ...@@ -86,8 +88,9 @@ impl PamServiceModule for PamOidc {
debug!("Successfully got password"); debug!("Successfully got password");
match get_access_token_password(conf, "pam", username.to_string(), password.to_string(), PamError::SERVICE_ERR, PamError::AUTH_ERR) { match get_access_token_password(conf, "pam", username.to_string(), password.to_string(), PamError::SERVICE_ERR, PamError::AUTH_ERR) {
Ok(_) => { Ok(t) => {
info!("Authenticated {} using Resource Owner Password Grant", username); info!("Authenticated {} using Resource Owner Password Grant", username);
CACHE.save_user_token(username.to_string(), t.into());
return PamError::SUCCESS; return PamError::SUCCESS;
}, },
Err(e) => { Err(e) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment