Merge pull request #3603 from thomasdarimont/issue/KEYCLOAK-3969-Allow-authentication-via-ScriptAuthenticator-without-user
KEYCLOAK-3969 Allow use of ScriptAuthenticator without user
This commit is contained in:
commit
f03d79c7d3
2 changed files with 10 additions and 4 deletions
|
@ -52,6 +52,10 @@ import java.util.Map;
|
||||||
* </ol>
|
* </ol>
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
|
* Note that the {@code user} variable is only defined when the user was identified by a preceeding
|
||||||
|
* authentication step, e.g. by the {@link UsernamePasswordForm} authenticator.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
* Additional context information can be extracted from the {@code context} argument passed to the {@code authenticate(context)}
|
* Additional context information can be extracted from the {@code context} argument passed to the {@code authenticate(context)}
|
||||||
* or {@code action(context)} function.
|
* or {@code action(context)} function.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -63,9 +67,10 @@ import java.util.Map;
|
||||||
*
|
*
|
||||||
* function authenticate(context) {
|
* function authenticate(context) {
|
||||||
*
|
*
|
||||||
* LOG.info(script.name + " --> trace auth for: " + user.username);
|
* var username = user ? user.username : "anonymous";
|
||||||
|
* LOG.info(script.name + " --> trace auth for: " + username);
|
||||||
*
|
*
|
||||||
* if ( user.username === "tester"
|
* if ( username === "tester"
|
||||||
* && user.getAttribute("someAttribute")
|
* && user.getAttribute("someAttribute")
|
||||||
* && user.getAttribute("someAttribute").contains("someValue")) {
|
* && user.getAttribute("someAttribute").contains("someValue")) {
|
||||||
*
|
*
|
||||||
|
@ -160,7 +165,7 @@ public class ScriptBasedAuthenticator implements Authenticator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean requiresUser() {
|
public boolean requiresUser() {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,7 +24,8 @@ AuthenticationFlowError = Java.type("org.keycloak.authentication.AuthenticationF
|
||||||
*/
|
*/
|
||||||
function authenticate(context) {
|
function authenticate(context) {
|
||||||
|
|
||||||
LOG.info(script.name + " trace auth for: " + user.username);
|
var username = user ? user.username : "anonymous";
|
||||||
|
LOG.info(script.name + " trace auth for: " + username);
|
||||||
|
|
||||||
var authShouldFail = false;
|
var authShouldFail = false;
|
||||||
if (authShouldFail) {
|
if (authShouldFail) {
|
||||||
|
|
Loading…
Reference in a new issue