auth

Paddy 2014-12-07 Parent:d43c3fbf00f3 Child:a22b35677cd5

87:1fb166575e69 Go to Latest

auth/context.go

Rename Grant to AuthorizationCode. God bless gofmt. Rename all our instances of Grant to AuthorizationCode (including related variables and types, like grantStore and ErrGrantNotFound, plus all our comments and error strings. Whew.) to better reflect that it is only a single type of grant that could be accepted by the server.

History
     1.1 --- a/context.go	Sun Dec 07 02:54:42 2014 -0500
     1.2 +++ b/context.go	Sun Dec 07 03:40:25 2014 -0500
     1.3 @@ -14,13 +14,13 @@
     1.4  // be used as the main point of interaction for the data storage
     1.5  // layer.
     1.6  type Context struct {
     1.7 -	template *template.Template
     1.8 -	loginURI *url.URL
     1.9 -	clients  clientStore
    1.10 -	grants   grantStore
    1.11 -	profiles profileStore
    1.12 -	tokens   tokenStore
    1.13 -	sessions sessionStore
    1.14 +	template  *template.Template
    1.15 +	loginURI  *url.URL
    1.16 +	clients   clientStore
    1.17 +	authCodes authorizationCodeStore
    1.18 +	profiles  profileStore
    1.19 +	tokens    tokenStore
    1.20 +	sessions  sessionStore
    1.21  }
    1.22  
    1.23  // Render uses the HTML templates associated with the Context to render the
    1.24 @@ -129,30 +129,30 @@
    1.25  	return c.clients.countEndpoints(client)
    1.26  }
    1.27  
    1.28 -// GetGrant returns the Grant specified by the provided code from the grantStore associated with the
    1.29 +// GetAuthorizationCode returns the AuthorizationCode specified by the provided code from the authorizationCodeStore associated with the
    1.30  // Context.
    1.31 -func (c Context) GetGrant(code string) (Grant, error) {
    1.32 -	if c.grants == nil {
    1.33 -		return Grant{}, ErrNoGrantStore
    1.34 +func (c Context) GetAuthorizationCode(code string) (AuthorizationCode, error) {
    1.35 +	if c.authCodes == nil {
    1.36 +		return AuthorizationCode{}, ErrNoAuthorizationCodeStore
    1.37  	}
    1.38 -	return c.grants.getGrant(code)
    1.39 +	return c.authCodes.getAuthorizationCode(code)
    1.40  }
    1.41  
    1.42 -// SaveGrant stores the passed Grant in the grantStore associated with the Context.
    1.43 -func (c Context) SaveGrant(grant Grant) error {
    1.44 -	if c.grants == nil {
    1.45 -		return ErrNoGrantStore
    1.46 +// SaveAuthorizationCode stores the passed AuthorizationCode in the authorizationCodeStore associated with the Context.
    1.47 +func (c Context) SaveAuthorizationCode(authCode AuthorizationCode) error {
    1.48 +	if c.authCodes == nil {
    1.49 +		return ErrNoAuthorizationCodeStore
    1.50  	}
    1.51 -	return c.grants.saveGrant(grant)
    1.52 +	return c.authCodes.saveAuthorizationCode(authCode)
    1.53  }
    1.54  
    1.55 -// DeleteGrant removes the Grant specified by the provided code from the grantStore associated with
    1.56 +// DeleteAuthorizationCode removes the AuthorizationCode specified by the provided code from the authorizationCodeStore associated with
    1.57  // the Context.
    1.58 -func (c Context) DeleteGrant(code string) error {
    1.59 -	if c.grants == nil {
    1.60 -		return ErrNoGrantStore
    1.61 +func (c Context) DeleteAuthorizationCode(code string) error {
    1.62 +	if c.authCodes == nil {
    1.63 +		return ErrNoAuthorizationCodeStore
    1.64  	}
    1.65 -	return c.grants.deleteGrant(code)
    1.66 +	return c.authCodes.deleteAuthorizationCode(code)
    1.67  }
    1.68  
    1.69  // GetProfileByID returns the Profile specified by the provided ID from the profileStore associated with