-
Notifications
You must be signed in to change notification settings - Fork 14
Configure a code for Authenticators to indicate AUTH_USER_NOT_FOUND #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
a85f7ac
0c142fb
4fd1221
ebd525b
9f78204
9f55ca8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -574,6 +574,11 @@ instructions to your server configuration. | |||||||||
| 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 | ||||||||||
| to indicate that it could not find a user: | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| AuthnUserNotFoundCode <code> | ||||||||||
|
|
||||||||||
| * OLD DIRECTIVES | ||||||||||
|
|
||||||||||
| Some of the directives mentioned above used to have different names. | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -81,6 +81,7 @@ typedef struct | |||||||||||
| 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) */ | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||||||||
| int authncheck; /* Check for previous authentication? */ | ||||||||||||
|
|
||||||||||||
| } authnz_external_dir_config_rec; | ||||||||||||
|
|
@@ -120,6 +121,7 @@ static void *create_authnz_external_dir_config(apr_pool_t *p, char *d) | |||||||||||
| 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 */ | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see comment for line 84 |
||||||||||||
| dir->authncheck = 1; /* default to on */ | ||||||||||||
| return dir; | ||||||||||||
| } | ||||||||||||
|
|
@@ -321,6 +323,13 @@ static const command_rec authnz_external_cmds[] = | |||||||||||
| OR_AUTHCFG, | ||||||||||||
| "Old version of 'GroupExternalManyAtOnce'"), | ||||||||||||
|
|
||||||||||||
| AP_INIT_TAKE1("AuthnUserNotFoundCode", | ||||||||||||
| ap_set_int_slot, | ||||||||||||
| (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."), | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see comment for line 84 |
||||||||||||
|
|
||||||||||||
| AP_INIT_FLAG("GroupExternalAuthNCheck", | ||||||||||||
| ap_set_flag_slot, | ||||||||||||
| (void *)APR_OFFSETOF(authnz_external_dir_config_rec, authncheck), | ||||||||||||
|
|
@@ -764,7 +773,7 @@ void mock_turtle_cache(request_rec *r, const char *plainpw) | |||||||||||
|
|
||||||||||||
| /* Password checker for basic authentication - given a login/password, | ||||||||||||
| * check if it is valid. Returns one of AUTH_DENIED, AUTH_GRANTED, | ||||||||||||
| * or AUTH_GENERAL_ERROR. */ | ||||||||||||
| * AUTH_USER_NOT_FOUND, or AUTH_GENERAL_ERROR. */ | ||||||||||||
|
|
||||||||||||
| static authn_status authn_external_check_password(request_rec *r, | ||||||||||||
| const char *user, const char *password) | ||||||||||||
|
|
@@ -787,6 +796,8 @@ static authn_status authn_external_check_password(request_rec *r, | |||||||||||
| return AUTH_GENERAL_ERROR; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| int all_not_found = 1; | ||||||||||||
|
|
||||||||||||
| for (i = 0; i < dir->auth_name->nelts; i++) | ||||||||||||
| { | ||||||||||||
| extname = ((const char **)dir->auth_name->elts)[i]; | ||||||||||||
|
|
@@ -813,12 +824,26 @@ static authn_status authn_external_check_password(request_rec *r, | |||||||||||
| return AUTH_GRANTED; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /* Nonexistant login or (for some configurations) incorrect password | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| * Apache AuthBasicProvider | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| * Note that a configuration of 0, this will always be true and thus ignored */ | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) |
||||||||||||
| if (code != dir->authn_no_user_code) | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see comment for line 84 |
||||||||||||
| { | ||||||||||||
| all_not_found = 0; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /* Log a failed authentication */ | ||||||||||||
| errno = 0; | ||||||||||||
| ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, | ||||||||||||
| "AuthExtern %s [%s]: Failed (%d) for user %s", | ||||||||||||
| extname, extpath, code, r->user); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| if (all_not_found) { | ||||||||||||
| return AUTH_USER_NOT_FOUND; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /* If no authenticators succeed, refuse authentication */ | ||||||||||||
| return AUTH_DENIED; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.