summaryrefslogtreecommitdiff
path: root/internal/oauth/server.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-10-04 15:24:19 +0200
committerLibravatar GitHub <noreply@github.com>2021-10-04 15:24:19 +0200
commite04b187702acb0c9908237a35b3a9857e2167b3f (patch)
tree29839b8d5bbc28d34aba759a48dd7b005f1444f5 /internal/oauth/server.go
parentFollow request auto approval (#259) (diff)
downloadgotosocial-e04b187702acb0c9908237a35b3a9857e2167b3f.tar.xz
Refactor/tidy (#261)
* tidy up streaming * cut down code duplication * test get followers/following * test streaming processor * fix some test models * add TimeMustParse * fix uri / url typo * make trace logging less verbose * make logging more consistent * disable quote on logging * remove context.Background * remove many extraneous mastodon references * regenerate swagger * don't log query on no rows result * log latency first for easier reading
Diffstat (limited to 'internal/oauth/server.go')
-rw-r--r--internal/oauth/server.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/oauth/server.go b/internal/oauth/server.go
index 6d8f50064..0386ade40 100644
--- a/internal/oauth/server.go
+++ b/internal/oauth/server.go
@@ -55,7 +55,7 @@ type Server interface {
HandleTokenRequest(w http.ResponseWriter, r *http.Request) error
HandleAuthorizeRequest(w http.ResponseWriter, r *http.Request) error
ValidationBearerToken(r *http.Request) (oauth2.TokenInfo, error)
- GenerateUserAccessToken(ti oauth2.TokenInfo, clientSecret string, userID string) (accessToken oauth2.TokenInfo, err error)
+ GenerateUserAccessToken(ctx context.Context, ti oauth2.TokenInfo, clientSecret string, userID string) (accessToken oauth2.TokenInfo, err error)
LoadAccessToken(ctx context.Context, access string) (accessToken oauth2.TokenInfo, err error)
}
@@ -66,8 +66,8 @@ type s struct {
}
// New returns a new oauth server that implements the Server interface
-func New(database db.Basic, log *logrus.Logger) Server {
- ts := newTokenStore(context.Background(), database, log)
+func New(ctx context.Context, database db.Basic, log *logrus.Logger) Server {
+ ts := newTokenStore(ctx, database, log)
cs := NewClientStore(database)
manager := manage.NewDefaultManager()
@@ -138,9 +138,9 @@ func (s *s) ValidationBearerToken(r *http.Request) (oauth2.TokenInfo, error) {
//
// The ti parameter refers to an existing Application token that was used to make the upstream
// request. This token needs to be validated and exist in database in order to create a new token.
-func (s *s) GenerateUserAccessToken(ti oauth2.TokenInfo, clientSecret string, userID string) (oauth2.TokenInfo, error) {
+func (s *s) GenerateUserAccessToken(ctx context.Context, ti oauth2.TokenInfo, clientSecret string, userID string) (oauth2.TokenInfo, error) {
- authToken, err := s.server.Manager.GenerateAuthToken(context.Background(), oauth2.Code, &oauth2.TokenGenerateRequest{
+ authToken, err := s.server.Manager.GenerateAuthToken(ctx, oauth2.Code, &oauth2.TokenGenerateRequest{
ClientID: ti.GetClientID(),
ClientSecret: clientSecret,
UserID: userID,
@@ -155,7 +155,7 @@ func (s *s) GenerateUserAccessToken(ti oauth2.TokenInfo, clientSecret string, us
}
s.log.Tracef("obtained auth token: %+v", authToken)
- accessToken, err := s.server.Manager.GenerateAccessToken(context.Background(), oauth2.AuthorizationCode, &oauth2.TokenGenerateRequest{
+ accessToken, err := s.server.Manager.GenerateAccessToken(ctx, oauth2.AuthorizationCode, &oauth2.TokenGenerateRequest{
ClientID: authToken.GetClientID(),
ClientSecret: clientSecret,
RedirectURI: authToken.GetRedirectURI(),