-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Refactor Sign In Page rendering and capture all page rendering code in pagewriter package #1043
Conversation
// It uses the passed redirectURL to give users the option to go back to where | ||
// they originally came from or try signing in again. | ||
func (e *ErrorPage) Render(rw http.ResponseWriter, status int, redirectURL string, appError string, messages ...interface{}) { | ||
func (e *errorPageWriter) WriteErrorPage(rw http.ResponseWriter, status int, redirectURL string, appError string, messages ...interface{}) { |
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.
Method errorPageWriter.WriteErrorPage
has 5 arguments (exceeds 4 allowed). Consider refactoring.
b06ff52
to
59bbad2
Compare
pkg/app/pagewriter_test.go
Outdated
|
||
templateHTML := `Custom Template` | ||
signInFile := filepath.Join(customDir, signInTemplateName) | ||
Expect(ioutil.WriteFile(signInFile, []byte(templateHTML), 0666)).To(Succeed()) |
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.
Can we tighten up the permissions on these test files? Can they be 0600
or 0400
?
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.
I fixed up to 0600 for all the tests in this package, not sure why I ended up with 0666 🤷
pkg/app/pagewriter/pagewriter.go
Outdated
"net/http" | ||
) | ||
|
||
// Writer is an interface for rednering html templates for both sign-in and |
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.
// Writer is an interface for rednering html templates for both sign-in and | |
// Writer is an interface for rendering html templates for both sign-in and |
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.
LGTM! This organization will be really handy moving forward.
I just left a couple of small NITs -- otherwise it looks great to me.
59bbad2
to
425cff7
Compare
Nits fixed, no other changes, will merge once tests pass |
Description
Motivation and Context
This completes the extraction of the templates and page rendering from the main OAuth2 Proxy package.
Now, everything to do with the templates and how they are rendered is in it's own package with a well defined boundary.
The OAuth2 Proxy app can now pass through the options once to the Writer constructor and be able to render the pages without knowing anything about the templating etc going on in under the hood.
(This may be best reviewed commit by commit)
How Has This Been Tested?
Unit tests and the manual testing environment
Checklist: