Skip to content

Support helper ttl= annotations for Basic authentication#774

Open
yadij wants to merge 21 commits intosquid-cache:masterfrom
yadij:cleanup-auth_ttl
Open

Support helper ttl= annotations for Basic authentication#774
yadij wants to merge 21 commits intosquid-cache:masterfrom
yadij:cleanup-auth_ttl

Conversation

@yadij
Copy link
Contributor

@yadij yadij commented Feb 14, 2021

... and clean up the TTL / expiry information for all
authentication schemes behind an API of Auth::User.

Fixes a small bug where Basic auth credentials could be expired
one second earlier than they should have been.

Fixes a small bug where Basic auth credentials could be expired
by authenticate_ttl earlier than their squid.conf credentialsttl
is set to. These two configuration settings are supposed to
cover different time periods in credentials lifetime within
Squid memory.

Documentation updated to clarify the various credential TTL
config setting meaning and behaviour impact.

As a side effect the auth_param credentialsttl may be overridden
by a smaller global authenticate_ttl value. This is temporary.
Make the Basic auth credentials obey squid.conf documentation
where auth_param credentialsttl sets the valid lifetime
and authenticate_ttl the caching duration (after expiry).
@yadij yadij added the review-1 label Feb 14, 2021
@yadij yadij requested a review from rousskov February 14, 2021 08:46
@squid-anubis squid-anubis added M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Feb 14, 2021
Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

Please add a description for the currently undocumented Auth::User::expiretime field. This PR manipulates that field a lot but it is very difficult to review those manipulations without knowing exactly what that field is.

*/
virtual int32_t ttl() const = 0;

/// simple accessor to detect expired credentials
Copy link
Contributor

Choose a reason for hiding this comment

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

This "expired() means expired" comment adds very little useful information, but raises a question: What expires, the whole user record (i.e. this object, as the method name implies) or just the user credentials (the comment mentions credentials so there might be a reason for that)?

  • If user credentials expire separately from the user record as a whole, then this description should be adjusted to document that important caveat and the method should probably be renamed to expiredCredentials().
  • Otherwise, I would remove this description to avoid the problems it causes. Documenting the obvious can only hurt. Or you may want to attract the reader attention that objects expiring during the current second (zero TTL) are still considered fresh.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing the comment violates the requirement to provide a description of what each public method does.

Suggestions for better wording are welcome.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After looking at a few similar trivial methods accepted in other PR I'm thinking something like
"whether the credentials represented by this Auth::User object have passed their latest known TTL"

Copy link
Contributor

Choose a reason for hiding this comment

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

Removing the comment violates the requirement to provide a description of what each public method does.

In my documented opinion, there are virtually no absolute requirements. The "every new name should be documented" (or equivalent) rule does apply to this method, of course, but leaving this trivial test method without explicit documentation would be reasonable IMO if no suitable documentation is found (i.e. exceptional treatment can be justified in this specific case). Providing proper documentation would be even better, of course, but the current "foo is foo" documentation is (slightly) worse than the absence of any explicit documentation.

"whether the credentials represented by this Auth::User object have passed their latest known TTL"

AFAICT, the only useful bit of information here is the word "credentials". The rest is essentially a definition of what the word "expires" means in a context with a known TTL. By saying "credentials", are we implying that the user record itself (i.e. the Auth::User object) does not really expire and can be meaningfully used by Squid beyond the credentials expiration time? If yes, let's be very explicit about that important fact -- it is valuable. Otherwise, let's not imply that credentials have a separate "usable lifetime" from their User object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"whether the credentials represented by this Auth::User object have passed their latest known TTL"

AFAICT, the only useful bit of information here is the word "credentials".

That is somewhat insulting. But i shall overlook other than to point out.

The rest is essentially a definition of what the word "expires" means in a context with a known TTL.

Exactly. Documentating what "expired()" means in its use-case context(s).

By saying "credentials", are we implying that the user record itself (i.e. the Auth::User object) does not really expire and can be meaningfully used by Squid beyond the credentials expiration time?

Yes. The object itself only "expires" when free()'d. The credentials/value can be expired/stale without free().

If yes, let's be very explicit about that important fact -- it is valuable.

Suggestions welcome. I thought that original wording sufficiently clear "to detect expired credentials" (note word is credentials, not "user")

Copy link
Contributor

Choose a reason for hiding this comment

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

The object itself only "expires" when free()'d. The credentials/value can be expired/stale without free().

If the whole object does not expire when the expired() method starts returning true, then the method itself would have to be renamed. Right now, the method name implies that the method is describing the state of the entire object, not some part of that object. The distinction is very important because this object stores a lot more than credentials. If all those other pieces of information can be used when expired() returns true, let's call the method User::withExpiredCredentials().

As for the method documentation (the original subject of this change request), I can suggest specific improvements but would prefer to wait until the new method name confirms my understanding of what this method actually means. Feel free to polish the description while renaming, of course. I would very much prefer not to work on this documentation!

@rousskov rousskov added the S-waiting-for-author author action is expected (and usually required) label Feb 17, 2021
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Feb 17, 2021
yadij and others added 7 commits February 21, 2021 21:35
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Feb 22, 2021
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Sep 15, 2021
@yadij yadij added the feature maintainer needs documentation updates for merge label Oct 24, 2021
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Nov 10, 2021
@squid-anubis squid-anubis added the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Aug 8, 2022
@squid-anubis squid-anubis added M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels labels Aug 17, 2022
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Feb 13, 2023
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Mar 27, 2023
@yadij yadij removed the review-2 label Jun 27, 2023
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Nov 3, 2023
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Jan 9, 2024
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Mar 21, 2024
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Apr 3, 2024
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Apr 24, 2024
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Jun 26, 2024
@kinkie kinkie added the M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature maintainer needs documentation updates for merge M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels S-waiting-for-author author action is expected (and usually required)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants