Skip to content
This repository has been archived by the owner on Nov 19, 2019. It is now read-only.

Log all authorization attempts? #118

Closed
nathanl opened this issue Feb 1, 2017 · 5 comments
Closed

Log all authorization attempts? #118

nathanl opened this issue Feb 1, 2017 · 5 comments

Comments

@nathanl
Copy link
Owner

nathanl commented Feb 1, 2017

I got a question via Twitter and thought it would be best to make it a discussion here:

any recommendations for logging all authorization attempts via authority?

@nathanl
Copy link
Owner Author

nathanl commented Feb 1, 2017

Logging all authorization attempts would currently require modifying Authority, either as a monkey patch or a PR.

Here's how logging is currently done.

First, Authority.enforce raises an exception if an attempted action is unauthorized.

Then this code rescues the exception and calls your configured security_violation_handler.

By default, that's the :authority_forbidden method, which logs the violation and renders a 403.

So to log all attempts at authorization, successful or not, would require modifying Authority.enforce to have it log any attempted access. Eg, it could do Authority.logger.info("#{user} is attempting to #{action} #{resource} with options #{options}". It could still leave it to the exception handler to make a second warn log entry if the action is unauthorized.

That's not a hard change, but I don't know if any users would object to having those extra log messages. We could configure whether to log in that case, but more options == more complexity.

@forced-request
Copy link
Contributor

Thanks @nathanl. I think it's good to have the option. This allows developers to better audit user actions. I would probably have this disabled by default, and be enabled via the rollbar initializer.

@nathanl
Copy link
Owner Author

nathanl commented Feb 1, 2017

@forced-request I can see why you'd want to be able to log everything. Interested in making a PR?

@forced-request
Copy link
Contributor

I should be able to make that happen. I'll get back to you soon.

forced-request added a commit to forced-request/authority that referenced this issue Feb 2, 2017
…athanl#118

Added option to enable logging for all authority interactions, as per nathanl#118

Logging will utilize Authority.info, and will only occur in instance within which a SecurityViolation is not generated
@nathanl
Copy link
Owner Author

nathanl commented Apr 7, 2017

Fixed in #119

@nathanl nathanl closed this as completed Apr 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants