diff options
author | 2021-03-15 14:47:23 +0100 | |
---|---|---|
committer | 2021-03-15 14:47:23 +0100 | |
commit | 7590eb9cc2e1557d4f7acea858a896afc7b03ca5 (patch) | |
tree | e61048d160d21dbcf3784f55d6605a3d4bca5af0 | |
parent | start working on oauth2 implementation (diff) | |
download | gotosocial-7590eb9cc2e1557d4f7acea858a896afc7b03ca5.tar.xz |
move mastotypes
-rw-r--r-- | internal/oauth/oauth.go | 38 | ||||
-rw-r--r-- | pkg/mastotypes/account.go (renamed from pkg/mastotypes/model/account.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/activity.go (renamed from pkg/mastotypes/model/activity.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/admin.go (renamed from pkg/mastotypes/model/admin.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/announcement.go (renamed from pkg/mastotypes/model/announcement.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/announcementreaction.go (renamed from pkg/mastotypes/model/announcementreaction.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/application.go (renamed from pkg/mastotypes/model/application.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/attachment.go (renamed from pkg/mastotypes/model/attachment.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/card.go (renamed from pkg/mastotypes/model/card.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/context.go (renamed from pkg/mastotypes/model/context.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/conversation.go (renamed from pkg/mastotypes/model/conversation.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/emoji.go (renamed from pkg/mastotypes/model/emoji.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/error.go (renamed from pkg/mastotypes/model/error.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/featuredtag.go (renamed from pkg/mastotypes/model/featuredtag.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/field.go (renamed from pkg/mastotypes/model/field.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/filter.go (renamed from pkg/mastotypes/model/filter.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/history.go (renamed from pkg/mastotypes/model/history.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/identityproof.go (renamed from pkg/mastotypes/model/identityproof.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/instance.go (renamed from pkg/mastotypes/model/instance.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/list.go (renamed from pkg/mastotypes/model/list.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/marker.go (renamed from pkg/mastotypes/model/marker.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/mention.go (renamed from pkg/mastotypes/model/mention.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/notification.go (renamed from pkg/mastotypes/model/notification.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/poll.go (renamed from pkg/mastotypes/model/poll.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/preferences.go (renamed from pkg/mastotypes/model/preferences.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/pushsubscription.go (renamed from pkg/mastotypes/model/pushsubscription.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/relationship.go (renamed from pkg/mastotypes/model/relationship.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/results.go (renamed from pkg/mastotypes/model/results.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/scheduledstatus.go (renamed from pkg/mastotypes/model/scheduledstatus.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/source.go (renamed from pkg/mastotypes/model/source.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/status.go (renamed from pkg/mastotypes/model/status.go) | 0 | ||||
-rw-r--r-- | pkg/mastotypes/tag.go (renamed from pkg/mastotypes/model/tag.go) | 0 |
32 files changed, 38 insertions, 0 deletions
diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go index 95cf97191..11b1b57fd 100644 --- a/internal/oauth/oauth.go +++ b/internal/oauth/oauth.go @@ -19,4 +19,42 @@ package oauth type Server struct { + manager := manage.NewDefaultManager() + // token memory store + manager.MustTokenStorage(store.NewMemoryTokenStore()) + + // client memory store + clientStore := store.NewClientStore() + clientStore.Set("000000", &models.Client{ + ID: "000000", + Secret: "999999", + Domain: "http://localhost", + }) + manager.MapClientStorage(clientStore) + + srv := server.NewDefaultServer(manager) + srv.SetAllowGetAccessRequest(true) + srv.SetClientInfoHandler(server.ClientFormHandler) + + srv.SetInternalErrorHandler(func(err error) (re *errors.Response) { + log.Println("Internal Error:", err.Error()) + return + }) + + srv.SetResponseErrorHandler(func(re *errors.Response) { + log.Println("Response Error:", re.Error.Error()) + }) + + http.HandleFunc("/authorize", func(w http.ResponseWriter, r *http.Request) { + err := srv.HandleAuthorizeRequest(w, r) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + } + }) + + http.HandleFunc("/token", func(w http.ResponseWriter, r *http.Request) { + srv.HandleTokenRequest(w, r) + }) + + log.Fatal(http.ListenAndServe(":9096", nil)) } diff --git a/pkg/mastotypes/model/account.go b/pkg/mastotypes/account.go index 031fa7c02..031fa7c02 100644 --- a/pkg/mastotypes/model/account.go +++ b/pkg/mastotypes/account.go diff --git a/pkg/mastotypes/model/activity.go b/pkg/mastotypes/activity.go index b8dbf2c1b..b8dbf2c1b 100644 --- a/pkg/mastotypes/model/activity.go +++ b/pkg/mastotypes/activity.go diff --git a/pkg/mastotypes/model/admin.go b/pkg/mastotypes/admin.go index 71c2bb309..71c2bb309 100644 --- a/pkg/mastotypes/model/admin.go +++ b/pkg/mastotypes/admin.go diff --git a/pkg/mastotypes/model/announcement.go b/pkg/mastotypes/announcement.go index 882d6bb9b..882d6bb9b 100644 --- a/pkg/mastotypes/model/announcement.go +++ b/pkg/mastotypes/announcement.go diff --git a/pkg/mastotypes/model/announcementreaction.go b/pkg/mastotypes/announcementreaction.go index 444c57e2c..444c57e2c 100644 --- a/pkg/mastotypes/model/announcementreaction.go +++ b/pkg/mastotypes/announcementreaction.go diff --git a/pkg/mastotypes/model/application.go b/pkg/mastotypes/application.go index d2f894306..d2f894306 100644 --- a/pkg/mastotypes/model/application.go +++ b/pkg/mastotypes/application.go diff --git a/pkg/mastotypes/model/attachment.go b/pkg/mastotypes/attachment.go index 4d4d0955a..4d4d0955a 100644 --- a/pkg/mastotypes/model/attachment.go +++ b/pkg/mastotypes/attachment.go diff --git a/pkg/mastotypes/model/card.go b/pkg/mastotypes/card.go index d1147e04b..d1147e04b 100644 --- a/pkg/mastotypes/model/card.go +++ b/pkg/mastotypes/card.go diff --git a/pkg/mastotypes/model/context.go b/pkg/mastotypes/context.go index 397522dc7..397522dc7 100644 --- a/pkg/mastotypes/model/context.go +++ b/pkg/mastotypes/context.go diff --git a/pkg/mastotypes/model/conversation.go b/pkg/mastotypes/conversation.go index ed95c124c..ed95c124c 100644 --- a/pkg/mastotypes/model/conversation.go +++ b/pkg/mastotypes/conversation.go diff --git a/pkg/mastotypes/model/emoji.go b/pkg/mastotypes/emoji.go index e9ef95460..e9ef95460 100644 --- a/pkg/mastotypes/model/emoji.go +++ b/pkg/mastotypes/emoji.go diff --git a/pkg/mastotypes/model/error.go b/pkg/mastotypes/error.go index 394085724..394085724 100644 --- a/pkg/mastotypes/model/error.go +++ b/pkg/mastotypes/error.go diff --git a/pkg/mastotypes/model/featuredtag.go b/pkg/mastotypes/featuredtag.go index 0e0bbe802..0e0bbe802 100644 --- a/pkg/mastotypes/model/featuredtag.go +++ b/pkg/mastotypes/featuredtag.go diff --git a/pkg/mastotypes/model/field.go b/pkg/mastotypes/field.go index dbfe08c54..dbfe08c54 100644 --- a/pkg/mastotypes/model/field.go +++ b/pkg/mastotypes/field.go diff --git a/pkg/mastotypes/model/filter.go b/pkg/mastotypes/filter.go index 86d9795a3..86d9795a3 100644 --- a/pkg/mastotypes/model/filter.go +++ b/pkg/mastotypes/filter.go diff --git a/pkg/mastotypes/model/history.go b/pkg/mastotypes/history.go index 235761378..235761378 100644 --- a/pkg/mastotypes/model/history.go +++ b/pkg/mastotypes/history.go diff --git a/pkg/mastotypes/model/identityproof.go b/pkg/mastotypes/identityproof.go index 7265d46e3..7265d46e3 100644 --- a/pkg/mastotypes/model/identityproof.go +++ b/pkg/mastotypes/identityproof.go diff --git a/pkg/mastotypes/model/instance.go b/pkg/mastotypes/instance.go index 10e626a8e..10e626a8e 100644 --- a/pkg/mastotypes/model/instance.go +++ b/pkg/mastotypes/instance.go diff --git a/pkg/mastotypes/model/list.go b/pkg/mastotypes/list.go index 5b704367b..5b704367b 100644 --- a/pkg/mastotypes/model/list.go +++ b/pkg/mastotypes/list.go diff --git a/pkg/mastotypes/model/marker.go b/pkg/mastotypes/marker.go index 790322313..790322313 100644 --- a/pkg/mastotypes/model/marker.go +++ b/pkg/mastotypes/marker.go diff --git a/pkg/mastotypes/model/mention.go b/pkg/mastotypes/mention.go index 81a593d99..81a593d99 100644 --- a/pkg/mastotypes/model/mention.go +++ b/pkg/mastotypes/mention.go diff --git a/pkg/mastotypes/model/notification.go b/pkg/mastotypes/notification.go index 26d361b43..26d361b43 100644 --- a/pkg/mastotypes/model/notification.go +++ b/pkg/mastotypes/notification.go diff --git a/pkg/mastotypes/model/poll.go b/pkg/mastotypes/poll.go index bedaebec2..bedaebec2 100644 --- a/pkg/mastotypes/model/poll.go +++ b/pkg/mastotypes/poll.go diff --git a/pkg/mastotypes/model/preferences.go b/pkg/mastotypes/preferences.go index c28f5d5ab..c28f5d5ab 100644 --- a/pkg/mastotypes/model/preferences.go +++ b/pkg/mastotypes/preferences.go diff --git a/pkg/mastotypes/model/pushsubscription.go b/pkg/mastotypes/pushsubscription.go index 4d7535100..4d7535100 100644 --- a/pkg/mastotypes/model/pushsubscription.go +++ b/pkg/mastotypes/pushsubscription.go diff --git a/pkg/mastotypes/model/relationship.go b/pkg/mastotypes/relationship.go index 1e0bbab46..1e0bbab46 100644 --- a/pkg/mastotypes/model/relationship.go +++ b/pkg/mastotypes/relationship.go diff --git a/pkg/mastotypes/model/results.go b/pkg/mastotypes/results.go index 3fa7c7abb..3fa7c7abb 100644 --- a/pkg/mastotypes/model/results.go +++ b/pkg/mastotypes/results.go diff --git a/pkg/mastotypes/model/scheduledstatus.go b/pkg/mastotypes/scheduledstatus.go index ff45eaade..ff45eaade 100644 --- a/pkg/mastotypes/model/scheduledstatus.go +++ b/pkg/mastotypes/scheduledstatus.go diff --git a/pkg/mastotypes/model/source.go b/pkg/mastotypes/source.go index e4a2ca06a..e4a2ca06a 100644 --- a/pkg/mastotypes/model/source.go +++ b/pkg/mastotypes/source.go diff --git a/pkg/mastotypes/model/status.go b/pkg/mastotypes/status.go index e98504e27..e98504e27 100644 --- a/pkg/mastotypes/model/status.go +++ b/pkg/mastotypes/status.go diff --git a/pkg/mastotypes/model/tag.go b/pkg/mastotypes/tag.go index d34314b0b..d34314b0b 100644 --- a/pkg/mastotypes/model/tag.go +++ b/pkg/mastotypes/tag.go |