auth

Paddy 2014-08-16 Parent:3423c552e249 Child:9fe684b33b3d

17:1f04b1146cad Go to Latest

auth/authorize.go

Implement CSRF prevention and pass info to confirmation. Implement CSRF prevention using the nosurf package. Note that the handler still needs to be wrapped before this will work. Pass info on the authorization being requested (namely the client and the scope) to the RenderConfirmation page so that the user can make an educated decision.

History
     1.1 --- a/authorize.go	Sat Aug 16 06:18:09 2014 -0400
     1.2 +++ b/authorize.go	Sat Aug 16 18:05:10 2014 -0400
     1.3 @@ -140,7 +140,7 @@
     1.4  func (req AuthRequest) handleCodeRequest(w http.ResponseWriter, r *http.Request, ctx Context) {
     1.5  
     1.6  	if r.Method == "GET" {
     1.7 -		ctx.RenderConfirmation(w)
     1.8 +		ctx.RenderConfirmation(w, r, req)
     1.9  		return
    1.10  	} else if r.Method != "POST" {
    1.11  		ctx.RenderError(w, InvalidMethodError)
    1.12 @@ -148,7 +148,7 @@
    1.13  	}
    1.14  
    1.15  	if err := validateSession(r, ctx); err == ErrorNotAuthenticated {
    1.16 -		ctx.RenderLogin(w)
    1.17 +		ctx.RenderLogin(w, r)
    1.18  		return
    1.19  	} else if err != nil {
    1.20  		ctx.RenderError(w, err)
    1.21 @@ -193,7 +193,7 @@
    1.22  func (req AuthRequest) handleTokenRequest(w http.ResponseWriter, r *http.Request, ctx Context) {
    1.23  
    1.24  	if r.Method == "GET" {
    1.25 -		ctx.RenderConfirmation(w)
    1.26 +		ctx.RenderConfirmation(w, r, req)
    1.27  		return
    1.28  	} else if r.Method != "POST" {
    1.29  		ctx.RenderError(w, InvalidMethodError)
    1.30 @@ -201,7 +201,7 @@
    1.31  	}
    1.32  
    1.33  	if err := validateSession(r, ctx); err == ErrorNotAuthenticated {
    1.34 -		ctx.RenderLogin(w)
    1.35 +		ctx.RenderLogin(w, r)
    1.36  		return
    1.37  	} else if err != nil {
    1.38  		ctx.RenderError(w, err)