Skip to content

Commit

Permalink
example: split library and example - closes ory#92
Browse files Browse the repository at this point in the history
  • Loading branch information
budougumi0617 committed Oct 16, 2016
1 parent 25caf4f commit 28fd350
Show file tree
Hide file tree
Showing 51 changed files with 1,030 additions and 786 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func someResourceProviderHandlerFunc(rw http.ResponseWriter, req *http.Request)
mySessionData := &session{}
requiredScope := "blogposts.create"

ar, err := oauth2.ValidateToken(ctx, fosite.AccessTokenFromRequest(req), mySessionData, requiredScope)
ar, err := oauth2.IntrospectToken(ctx, fosite.AccessTokenFromRequest(req), mySessionData, requiredScope)
if err != nil {
// ...
}
Expand Down
6 changes: 5 additions & 1 deletion compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func Compose(config *Config, storage interface{}, strategy interface{}, handlers
AuthorizeEndpointHandlers: fosite.AuthorizeEndpointHandlers{},
TokenEndpointHandlers: fosite.TokenEndpointHandlers{},
TokenValidators: fosite.TokenValidators{},
RevocationHandlers: fosite.RevocationHandlers{},
Hasher: &hash.BCrypt{WorkFactor: config.GetHashCost()},
Logger: &logrus.Logger{},
ScopeStrategy: fosite.HierarchicScopeStrategy,
Expand All @@ -49,9 +50,12 @@ func Compose(config *Config, storage interface{}, strategy interface{}, handlers
if th, ok := res.(fosite.TokenEndpointHandler); ok {
f.TokenEndpointHandlers.Append(th)
}
if tv, ok := res.(fosite.TokenValidator); ok {
if tv, ok := res.(fosite.TokenIntrospector); ok {
f.TokenValidators.Append(tv)
}
if rh, ok := res.(fosite.RevocationHandler); ok {
f.RevocationHandlers.Append(rh)
}
}

return f
Expand Down
10 changes: 10 additions & 0 deletions compose/compose_oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,13 @@ func OAuth2ResourceOwnerPasswordCredentialsFactory(config *Config, storage inter
},
}
}

// OAuth2TokenRevocationFactory creates an OAuth2 token revocation handler and registers
// an access token, refresh token and authorize code validator.
func OAuth2TokenRevocationFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &oauth2.TokenRevocationHandler{
TokenRevocationStorage: storage.(oauth2.TokenRevocationStorage),
AccessTokenStrategy: strategy.(oauth2.AccessTokenStrategy),
RefreshTokenStrategy: strategy.(oauth2.RefreshTokenStrategy),
}
}
27 changes: 0 additions & 27 deletions fosite-example/cert/rs256-private.pem

This file was deleted.

9 changes: 0 additions & 9 deletions fosite-example/cert/rs256-public.pem

This file was deleted.

309 changes: 0 additions & 309 deletions fosite-example/main.go

This file was deleted.

Loading

0 comments on commit 28fd350

Please sign in to comment.