Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nss-pam-webapi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
magicfelix
nss-pam-webapi
Commits
e3ad91e2
Verified
Commit
e3ad91e2
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Return clone of BasicTokenResponse to not keep a ref to the static for too long
Thanks to tnariol!
parent
5edfd9e1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cache.rs
+5
-2
5 additions, 2 deletions
src/cache.rs
src/nss.rs
+3
-9
3 additions, 9 deletions
src/nss.rs
with
8 additions
and
11 deletions
src/cache.rs
+
5
−
2
View file @
e3ad91e2
...
...
@@ -293,7 +293,7 @@ impl UserInfo {
///
/// This will use the in-memory token from the `access_token` slot if it is filled,
/// or attempt to load a token from disk if not
pub
fn
get_access_token
(
&
mut
self
)
->
&
Option
<
BasicTokenResponse
>
{
pub
fn
get_access_token
(
&
mut
self
)
->
Option
<
BasicTokenResponse
>
{
// Try to load our acess token if none is known
if
self
.access_token
.is_none
()
{
debug!
(
"No token in memory, trying to load from file"
);
...
...
@@ -309,7 +309,10 @@ impl UserInfo {
self
.restore_privileges
();
}
return
&
self
.access_token
;
match
&
self
.access_token
{
Some
(
t
)
=>
Some
(
t
.clone
()),
None
=>
None
}
}
/// Set the known access token for this user
...
...
This diff is collapsed.
Click to expand it.
src/nss.rs
+
3
−
9
View file @
e3ad91e2
...
...
@@ -67,11 +67,9 @@ impl PasswdHooks for OidcPasswd {
let
conf
=
nss_hook_prepare
();
info!
(
"[NSS] passwd.get_all_entries called"
);
let
mut
context_user
=
get_context_user
();
let
user_token_res
=
context_user
.get_access_token
();
let
user_token_res
=
get_context_user
()
.get_access_token
();
// FIXME Implement caching of system token
let
system_token_res
=
get_access_token_client
(
&
conf
,
"nss"
,
""
,
""
);
let
system_token_res
=
system_token_res
.as_ref
();
let
token
=
match
user_token_res
{
Some
(
t
)
=>
t
,
None
=>
{
...
...
@@ -100,11 +98,9 @@ impl PasswdHooks for OidcPasswd {
let
conf
=
nss_hook_prepare
();
info!
(
"[NSS] passwd.get_entry_by_uid called for {}"
,
uid
);
let
mut
context_user
=
get_context_user
();
let
user_token_res
=
context_user
.get_access_token
();
let
user_token_res
=
get_context_user
()
.get_access_token
();
// FIXME Implement caching of system token
let
system_token_res
=
get_access_token_client
(
&
conf
,
"nss"
,
""
,
""
);
let
system_token_res
=
system_token_res
.as_ref
();
let
token
=
match
user_token_res
{
Some
(
t
)
=>
t
,
None
=>
{
...
...
@@ -133,11 +129,9 @@ impl PasswdHooks for OidcPasswd {
let
conf
=
nss_hook_prepare
();
info!
(
"[NSS] passwd.get_entry_by_name called for {}"
,
name
);
let
mut
context_user
=
get_context_user
();
let
user_token_res
=
context_user
.get_access_token
();
let
user_token_res
=
get_context_user
()
.get_access_token
();
// FIXME Implement caching of system token
let
system_token_res
=
get_access_token_client
(
&
conf
,
"nss"
,
""
,
""
);
let
system_token_res
=
system_token_res
.as_ref
();
let
token
=
match
user_token_res
{
Some
(
t
)
=>
t
,
None
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment