13
13
import org .elasticsearch .common .util .concurrent .ThreadContext .StoredContext ;
14
14
import org .elasticsearch .node .Node ;
15
15
import org .elasticsearch .xpack .core .security .authc .Authentication ;
16
+ import org .elasticsearch .xpack .core .security .authc .Authentication .AuthenticationType ;
16
17
import org .elasticsearch .xpack .core .security .user .User ;
17
18
18
19
import java .io .IOException ;
20
+ import java .util .Collections ;
19
21
import java .util .Objects ;
20
22
import java .util .function .Consumer ;
21
23
@@ -71,7 +73,8 @@ public void setUser(User user, Version version) {
71
73
} else {
72
74
lookedUpBy = null ;
73
75
}
74
- setAuthentication (new Authentication (user , authenticatedBy , lookedUpBy , version ));
76
+ setAuthentication (
77
+ new Authentication (user , authenticatedBy , lookedUpBy , version , AuthenticationType .INTERNAL , Collections .emptyMap ()));
75
78
}
76
79
77
80
/** Writes the authentication to the thread context */
@@ -89,7 +92,7 @@ private void setAuthentication(Authentication authentication) {
89
92
*/
90
93
public void executeAsUser (User user , Consumer <StoredContext > consumer , Version version ) {
91
94
final StoredContext original = threadContext .newStoredContext (true );
92
- try (ThreadContext .StoredContext ctx = threadContext .stashContext ()) {
95
+ try (ThreadContext .StoredContext ignore = threadContext .stashContext ()) {
93
96
setUser (user , version );
94
97
consumer .accept (original );
95
98
}
@@ -102,9 +105,9 @@ public void executeAsUser(User user, Consumer<StoredContext> consumer, Version v
102
105
public void executeAfterRewritingAuthentication (Consumer <StoredContext > consumer , Version version ) {
103
106
final StoredContext original = threadContext .newStoredContext (true );
104
107
final Authentication authentication = Objects .requireNonNull (userSettings .getAuthentication ());
105
- try (ThreadContext .StoredContext ctx = threadContext .stashContext ()) {
108
+ try (ThreadContext .StoredContext ignore = threadContext .stashContext ()) {
106
109
setAuthentication (new Authentication (authentication .getUser (), authentication .getAuthenticatedBy (),
107
- authentication .getLookedUpBy (), version ));
110
+ authentication .getLookedUpBy (), version , authentication . getAuthenticationType (), authentication . getMetadata () ));
108
111
consumer .accept (original );
109
112
}
110
113
}
0 commit comments