Skip to content

Add -bypass-auth-except-for to protect only paths matched by a regex#44

Merged
simo5 merged 1 commit intoopenshift:masterfrom
mrogers950:auth-regex
Jan 12, 2018
Merged

Add -bypass-auth-except-for to protect only paths matched by a regex#44
simo5 merged 1 commit intoopenshift:masterfrom
mrogers950:auth-regex

Conversation

@mrogers950
Copy link
Copy Markdown

This option takes priority over --skip-auth-regex if set. When unset, all paths
are protected by default.
Fixes #42
@smarterclayton @simo5 @enj please review :)

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 4, 2018
@mrogers950
Copy link
Copy Markdown
Author

I noticed login does not work if you don't include the proxy prefix (for {prefix}/start, etc.) in the auth-regex. So we should always include a match for paths under the prefix.
Also, I don't see the value in allowing both options to be set so I plan on making that a configuration error.

Copy link
Copy Markdown

@simo5 simo5 left a comment

Choose a reason for hiding this comment

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

I think we need tests ?

Comment thread README.md Outdated
```
Usage of oauth2_proxy:
-approval-prompt string: OAuth approval_prompt (default "force")
-auth-regex value: provide authentication for request paths that match (may be given multiple times), applied prior to skip-auth-regex
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I feel like we need to make more clear that when this isused the other paths will be without any authentication, so it "fails open". IE use it only if you really know what you are doing, Maybe we need a scarier name too ?

@mrogers950
Copy link
Copy Markdown
Author

I changed it to error out if both options are set, and fixed the problem with the proxy-prefix paths I mentioned above. I updated the option help as well, hopefully that is clearer.

I think we need tests ?

right, I think these would be most appropriate for the e2e testing.

@smarterclayton
Copy link
Copy Markdown

smarterclayton commented Jan 7, 2018 via email

@mrogers950
Copy link
Copy Markdown
Author

Why make it exclusive?

I'd expect -auth-regex to be a positive check (only auth check these
things) and -skip-auth-regex to punch holes in -auth-regex.

@smarterclayton I thought it would be best to make them exclusive so there is less chance for a user to configure an insecure endpoint by mistake.

Copy link
Copy Markdown

@simo5 simo5 left a comment

Choose a reason for hiding this comment

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

I think we really need a scarier name that makes users think twice. They need to realize from the get-go that this command is disabling authentication on all but the listed paths, but still letting everything through on the other paths.

I do not care much for combining the old and new options, ok for me if they stay separate.

Also ok to reconsider using a different regex engine in the original option and drop this new option.

@mrogers950
Copy link
Copy Markdown
Author

I think we really need a scarier name that makes users think twice. They need to realize from the get-go that this command is disabling authentication on all but the listed paths, but still letting everything through on the other paths.

How about renaming (or aliasing for now) skip-auth-regex to something like:
--bypass-auth-for=
and add this option as
--bypass-auth-except-for=
This makes the combination of the two less confusing to me.

Also ok to reconsider using a different regex engine in the original option and drop this new option.

There is https://github.com/dlclark/regexp2 which supports negative lookaheads, but not everything that the standard regex does so switching might break some users.

@enj
Copy link
Copy Markdown

enj commented Jan 8, 2018

There is https://github.com/dlclark/regexp2 which supports negative lookaheads, but not everything that the standard regex does so switching might break some users.

You could define another mutually exclusive flag--skip-auth-regex-v2-super-awesome that a user can opt into for the more advanced regex bits.

@enj
Copy link
Copy Markdown

enj commented Jan 8, 2018

Or you could add a flag --use-advanced-regex which swaps out what regex engine is being used.

This option protects only those paths matching the given regex.  Add
-bypass-auth-for as an alias to skip-auth-regex to make clear it is the inverse
of -bypass-auth-except-for
@mrogers950
Copy link
Copy Markdown
Author

@simo5 @enj I updated the option as -bypass-auth-except-for and added a similarly named alias for skip-auth-regex. I looked into the approach of swapping out the regex engine, but that was more complex especially with the need to keep the proxy-prefix paths protected when excluded by the regex.

@simo5
Copy link
Copy Markdown

simo5 commented Jan 11, 2018

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 11, 2018
@simo5
Copy link
Copy Markdown

simo5 commented Jan 11, 2018

@smarterclayton we kept the two options incompatible, and not compuinding them, you expressed surprise at that. If you feel strongly please shout. Otherwise we are going to merge this soon.

@simo5
Copy link
Copy Markdown

simo5 commented Jan 12, 2018

Ok I guess we'll have a followup PR is @smarterclayton feels really strongly about this

@simo5 simo5 changed the title Add -auth-regex to protect only paths matched by a regex Add -bypass-auth-except-for to protect only paths matched by a regex Jan 12, 2018
@simo5 simo5 merged commit 32f7fb8 into openshift:master Jan 12, 2018
@smarterclayton
Copy link
Copy Markdown

I'm ok with them being incompatible for now.

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

Labels

lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants