This repository has been archived by the owner on Nov 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
authority_success logging #119
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7dbe29f
Added option to enable logging for all authority interactions, as per…
forced-request da0f172
Refactored authority to introduce the authority_success method
forced-request 2eadac6
Added passing unit tests
forced-request 9fb29c6
renamed from log_all to log_success to be more indicative of what was…
forced-request fb86bd9
Removed config option. By default the authority_success method will a…
forced-request File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A couple of thoughts:
authority_forbidden
renders403
(a controller responsibility) and some people might want to show404
or something else (so it probably needs to be overridable). But it seems likeAuthority.enforce
could just say "if thelog_attempts
option is true, log the attempt."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.
Fair point. I think the function name makes sense, since we successfully passed through authority.. but the default message should be changed. Will fix that.
For my personal need I have to overwrite it because I need to capture specific information in the request such as path details and controller methods. Also figured that if it were a controller method other users would see the need to extend it as well since it's similar to the
authority_forbidden
action. At first I did have this being logged viaAuthority.enforce
, but overriding that was less clean than just making it a controller method.Really up to you! It's easy to make the change, but I think it's more restrictive.
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.
Makes sense.
One other thought - if
authority_success
can be overridden to do anything the user wants, the config optionlog_success
isn't necessarily an accurate name. What if we don't even have a config option, andauthority_success
has a default implementation that does nothing? Then the instructions are "if you want to log successful authorization or do anything else about it, defineauthority_success
however you like."