-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: document reasoning for interface{} in compose package - closes #94
- Loading branch information
Showing
31 changed files
with
534 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ language: go | |
go: | ||
- 1.5 | ||
- 1.6 | ||
- 1.7 | ||
|
||
env: | ||
- GO15VENDOREXPERIMENT=1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ func writeJsonError(rw http.ResponseWriter, err error) { | |
|
||
rw.WriteHeader(rfcerr.StatusCode) | ||
rw.Write(js) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package oauth2 | ||
|
||
import ( | ||
"github.com/ory-am/fosite" | ||
"github.com/pkg/errors" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type CoreValidator struct { | ||
CoreStrategy | ||
CoreStorage | ||
ScopeStrategy fosite.ScopeStrategy | ||
} | ||
|
||
func (c *CoreValidator) IntrospectToken(ctx context.Context, token string, tokenType fosite.TokenType, accessRequest fosite.AccessRequester, scopes []string) (err error) { | ||
switch tokenType { | ||
case fosite.RefreshToken: | ||
if err = c.introspectRefreshToken(ctx, token, accessRequest); err == nil { | ||
return err | ||
} else if err = c.introspectAuthorizeCode(ctx, token, accessRequest); err == nil { | ||
return err | ||
} else if err = c.introspectAccessToken(ctx, token, accessRequest, scopes); err == nil { | ||
return err | ||
} | ||
return err | ||
case fosite.AuthorizeCode: | ||
if err = c.introspectAuthorizeCode(ctx, token, accessRequest); err == nil { | ||
return err | ||
} else if err := c.introspectAccessToken(ctx, token, accessRequest, scopes); err == nil { | ||
return err | ||
} else if err := c.introspectRefreshToken(ctx, token, accessRequest); err == nil { | ||
return err | ||
} | ||
return err | ||
} | ||
if err = c.introspectAccessToken(ctx, token, accessRequest, scopes); err == nil { | ||
return err | ||
} else if err := c.introspectRefreshToken(ctx, token, accessRequest); err == nil { | ||
return err | ||
} else if err := c.introspectAuthorizeCode(ctx, token, accessRequest); err == nil { | ||
return err | ||
} | ||
return err | ||
} | ||
|
||
func (c *CoreValidator) introspectAccessToken(ctx context.Context, token string, accessRequest fosite.AccessRequester, scopes []string) error { | ||
sig := c.CoreStrategy.AccessTokenSignature(token) | ||
or, err := c.CoreStorage.GetAccessTokenSession(ctx, sig, accessRequest.GetSession()) | ||
if err != nil { | ||
return errors.Wrap(fosite.ErrRequestUnauthorized, err.Error()) | ||
} else if err := c.CoreStrategy.ValidateAccessToken(ctx, or, token); err != nil { | ||
return err | ||
} | ||
|
||
for _, scope := range scopes { | ||
if scope == "" { | ||
continue | ||
} | ||
|
||
if !c.ScopeStrategy(or.GetGrantedScopes(), scope) { | ||
return errors.Wrap(fosite.ErrInvalidScope, "") | ||
} | ||
} | ||
|
||
accessRequest.Merge(or) | ||
return nil | ||
} | ||
|
||
func (c *CoreValidator) introspectRefreshToken(ctx context.Context, token string, accessRequest fosite.AccessRequester) error { | ||
sig := c.CoreStrategy.RefreshTokenSignature(token) | ||
if or, err := c.CoreStorage.GetRefreshTokenSession(ctx, sig, accessRequest.GetSession()); err != nil { | ||
return errors.Wrap(fosite.ErrRequestUnauthorized, err.Error()) | ||
} else if err := c.CoreStrategy.ValidateRefreshToken(ctx, or, token); err != nil { | ||
return err | ||
} else { | ||
accessRequest.Merge(or) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (c *CoreValidator) introspectAuthorizeCode(ctx context.Context, token string, accessRequest fosite.AccessRequester) error { | ||
sig := c.CoreStrategy.AuthorizeCodeSignature(token) | ||
if or, err := c.CoreStorage.GetAuthorizeCodeSession(ctx, sig, accessRequest.GetSession()); err != nil { | ||
return errors.Wrap(err, fosite.ErrRequestUnauthorized.Error()) | ||
} else if err := c.CoreStrategy.ValidateAuthorizeCode(ctx, or, token); err != nil { | ||
return err | ||
} else { | ||
accessRequest.Merge(or) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.