auth

Paddy 2014-12-13 Parent:229422395721 Child:c1b3a36af1a7

90:d5561856f45e Browse Files

Log ignored errors, grant revocations can return an error. Turn a few TODOs for logging errors into calls to log the actual error. Change the return type of grant revocations for GrantTypes to an error, so they can be logged by the system, not each GrantType. Implement a stub of the revocation function for the authcode GrantType.

authcode.go oauth2.go

     1.1 --- a/authcode.go	Sat Dec 13 19:11:38 2014 -0500
     1.2 +++ b/authcode.go	Sat Dec 13 19:16:57 2014 -0500
     1.3 @@ -114,3 +114,8 @@
     1.4  	}
     1.5  	return authCode.Scope, authCode.ProfileID, true
     1.6  }
     1.7 +
     1.8 +func authCodeGrantInvalidate(r *http.Request, context Context) error {
     1.9 +	// TODO(paddy): implement marking the authcode as used.
    1.10 +	return nil
    1.11 +}
     2.1 --- a/oauth2.go	Sat Dec 13 19:11:38 2014 -0500
     2.2 +++ b/oauth2.go	Sat Dec 13 19:16:57 2014 -0500
     2.3 @@ -63,7 +63,7 @@
     2.4  // was successfully returned and the Invalidate function will be called asynchronously.
     2.5  type GrantType struct {
     2.6  	Validate      func(w http.ResponseWriter, r *http.Request, context Context) (scope string, profileID uuid.ID, valid bool)
     2.7 -	Invalidate    func(r *http.Request, context Context) bool
     2.8 +	Invalidate    func(r *http.Request, context Context) error
     2.9  	ReturnToken   func(w http.ResponseWriter, r *http.Request, token Token, context Context) bool
    2.10  	IssuesRefresh bool
    2.11  }
    2.12 @@ -107,7 +107,7 @@
    2.13  		Error: errorType,
    2.14  	})
    2.15  	if err != nil {
    2.16 -		// TODO(paddy): log this or something
    2.17 +		log.Println(err)
    2.18  	}
    2.19  }
    2.20  
    2.21 @@ -123,7 +123,7 @@
    2.22  	}
    2.23  	err := enc.Encode(resp)
    2.24  	if err != nil {
    2.25 -		// TODO(paddy): log this or something
    2.26 +		log.Println(err)
    2.27  		return false
    2.28  	}
    2.29  	return true