Skip to content

Configure a code for Authenticators to indicate AUTH_USER_NOT_FOUND#68

Open
carrvo wants to merge 6 commits intophokz:masterfrom
carrvo:issues-40
Open

Configure a code for Authenticators to indicate AUTH_USER_NOT_FOUND#68
carrvo wants to merge 6 commits intophokz:masterfrom
carrvo:issues-40

Conversation

@carrvo
Copy link
Copy Markdown

@carrvo carrvo commented Feb 24, 2026

Resolves #40

Add AuthnUserNotFoundCode directive

Keeps the existing behaviour (no special return codes) as the default, but allow the user to define a particular return code (new directive) to mean the user does not exist.

mkj and others added 5 commits August 11, 2016 23:29
Original commit from https://github.com/mkj
return AUTH_USER_NOT_FOUND
keep the existing behaviour (no special return codes) as the default,
but allow the user to define a particular return code (new directive)
to mean the user does not exist.
Copy link
Copy Markdown
Collaborator

@bimimicah bimimicah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good! Just needs a few comment/naming tweaks for clarity.

Side note: I used the new GitHub review experience to submit the comments, and I see they are all jumbled up here. 😓 They might make more sense if you use the 'Files Changed' tab at the top to see them in order in the file 😅

return AUTH_GRANTED;
}

/* Nonexistant login or (for some configurations) incorrect password
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* Nonexistant login or (for some configurations) incorrect password
/* Determine whether the return code means 'non-existent user' or 'incorrect

char *context; /* Context string from AuthExternalContext */
int groupsatonce; /* Check all groups in one call? */
int providecache; /* Provide auth data to mod_authn_socache? */
int authn_no_user_code; /* External code to use for no user (HTTP 401) */
Copy link
Copy Markdown
Collaborator

@bimimicah bimimicah Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name should probably be changed to something about user not found and the description needs to be fixed.
AUTH_USER_NOT_FOUND does not mean to send 401 and re-authenticate, though that can be the final result. It means that this particular authn module cannot find the submitted user, and Apache should try the next authn module (if the admin has defined a next module to check)

dir->context = NULL; /* no default */
dir->groupsatonce = 1; /* default to on */
dir->providecache = 0; /* default to off */
dir->authn_no_user_code = 0; /* default to 0 to ignore */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment for line 84

(void *)APR_OFFSETOF(authnz_external_dir_config_rec, authn_no_user_code),
OR_AUTHCFG,
"Set to a return code that the authenticator uses to indicate that the "
"user is not found (respond with HTTP 401). Set to 0 to ignore."),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment for line 84

}

/* Nonexistant login or (for some configurations) incorrect password
* Handle this differently so that unknown users can be passed to the next
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Handle this differently so that unknown users can be passed to the next
* password'. If 'non-existent user', move on to the next external authenticator

/* Nonexistant login or (for some configurations) incorrect password
* Handle this differently so that unknown users can be passed to the next
* Apache AuthBasicProvider
* Note that a configuration of 0, this will always be true and thus ignored */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be better to move this line to documentation, and rephrase to something about "0 is reserved for successful authorization" or something like that. It's not so much 'ignored' as it is that this code never even runs (success already returned)
What are your thoughts?

* Handle this differently so that unknown users can be passed to the next
* Apache AuthBasicProvider
* Note that a configuration of 0, this will always be true and thus ignored */
if (code != dir->authn_no_user_code)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment for line 84

"AuthExtern %s [%s]: Failed (%d) for user %s",
extname, extpath, code, r->user);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* If all external authenticators return 'non-existent user', we return
* AUTH_USER_NOT_FOUND so that unknown users can be passed to the next
* Apache AuthBasicProvider */

directive. In Apache 2.4, the notion of authoritativeness is
thankfully almost entirely gone, so this directive is too.

If you want the ability to specify a return code for your authenticator
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you want the ability to specify a return code for your authenticator
If you want to allow your authenticator to gracefully hand off to the

thankfully almost entirely gone, so this directive is too.

If you want the ability to specify a return code for your authenticator
to indicate that it could not find a user:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
to indicate that it could not find a user:
next apache authentication module when your authenticator cannot locate
the submitted user, you have the ability to specify a return code for
your authenticator to indicate that it could not find a user:

@bimimicah
Copy link
Copy Markdown
Collaborator

@carrvo, I sent you an e-mail at the address in your profile.
In case you don't get that, I'll also mention here that you should add yourself to the CONTRIBUTORS list in the way that you prefer (real name, github username, and/or e-mail as you prefer). I went ahead and added mkj for you as an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the ability to specify an authenticator return code that means AUTH_USER_NOT_FOUND

3 participants