Skip to content
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

server: add error HTML templates with error description. #742

Merged
merged 1 commit into from
Dec 16, 2016

Conversation

rithujohn191
Copy link
Contributor

Tested the change with the example-app, it successfully displays an error template with error type and error description.

closes #657

@ericchiang

@@ -683,8 +683,10 @@ func (s *Server) writeAccessToken(w http.ResponseWriter, idToken, refreshToken s
w.Write(data)
}

func (s *Server) renderError(w http.ResponseWriter, status int, err, description string) {
http.Error(w, fmt.Sprintf("%s: %s", err, description), status)
func (s *Server) renderError(w http.ResponseWriter, status int, errType string, description string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use inferred type for errType

@@ -294,14 +294,14 @@ func (s *Server) handleConnectorCallback(w http.ResponseWriter, r *http.Request)
identity, err := callbackConnector.HandleCallback(parseScopes(authReq.Scopes), r)
if err != nil {
s.logger.Errorf("Failed to authenticate: %v", err)
s.renderError(w, http.StatusInternalServerError, errServerError, "")
s.renderError(w, http.StatusInternalServerError, errServerError, "Connector callback error")
Copy link
Contributor

Choose a reason for hiding this comment

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

Are users going to be expected to know what Connectors are? It seems like we should make this more general.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed it to "Login error"

@@ -138,13 +138,13 @@ func (s *Server) discoveryHandler() (http.HandlerFunc, error) {
func (s *Server) handleAuthorization(w http.ResponseWriter, r *http.Request) {
authReq, err := s.parseAuthorizationRequest(s.supportedResponseTypes, r)
if err != nil {
s.renderError(w, http.StatusInternalServerError, err.Type, err.Description)
s.renderError(w, http.StatusInternalServerError, errServerError, "Failed to parse authorization request")
Copy link
Contributor

Choose a reason for hiding this comment

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

Users wont understand what an "authorization request" is. :/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A lot of the existing http errors actually mentioned "authorization request". I'll clean those up too then.

@rithujohn191 rithujohn191 force-pushed the dex-frontend-cleanup branch 2 times, most recently from 11d1075 to 3809517 Compare December 16, 2016 06:55
@rithujohn191
Copy link
Contributor Author

rithujohn191 commented Dec 16, 2016

approval

Error template on the example-app

@rithujohn191
Copy link
Contributor Author

approval 1

Improved "error type" message that gets displayed.

@ericchiang
Copy link
Contributor

lgtm. we can continue improving the exact error messages later.

@ericchiang ericchiang merged commit c7aa154 into dexidp:master Dec 16, 2016
@rithujohn191 rithujohn191 deleted the dex-frontend-cleanup branch December 16, 2016 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

server: error HTML templates
3 participants