gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 7590eb9cc2e1557d4f7acea858a896afc7b03ca5
parent 772f6e59490b090edf7f2ab502ccaa480985c1ca
Author: tsmethurst <tobi.smethurst@protonmail.com>
Date:   Mon, 15 Mar 2021 14:47:23 +0100

move mastotypes

Diffstat:
Minternal/oauth/oauth.go | 38++++++++++++++++++++++++++++++++++++++
Rpkg/mastotypes/model/account.go -> pkg/mastotypes/account.go | 0
Rpkg/mastotypes/model/activity.go -> pkg/mastotypes/activity.go | 0
Rpkg/mastotypes/model/admin.go -> pkg/mastotypes/admin.go | 0
Rpkg/mastotypes/model/announcement.go -> pkg/mastotypes/announcement.go | 0
Rpkg/mastotypes/model/announcementreaction.go -> pkg/mastotypes/announcementreaction.go | 0
Rpkg/mastotypes/model/application.go -> pkg/mastotypes/application.go | 0
Rpkg/mastotypes/model/attachment.go -> pkg/mastotypes/attachment.go | 0
Rpkg/mastotypes/model/card.go -> pkg/mastotypes/card.go | 0
Rpkg/mastotypes/model/context.go -> pkg/mastotypes/context.go | 0
Rpkg/mastotypes/model/conversation.go -> pkg/mastotypes/conversation.go | 0
Rpkg/mastotypes/model/emoji.go -> pkg/mastotypes/emoji.go | 0
Rpkg/mastotypes/model/error.go -> pkg/mastotypes/error.go | 0
Rpkg/mastotypes/model/featuredtag.go -> pkg/mastotypes/featuredtag.go | 0
Rpkg/mastotypes/model/field.go -> pkg/mastotypes/field.go | 0
Rpkg/mastotypes/model/filter.go -> pkg/mastotypes/filter.go | 0
Rpkg/mastotypes/model/history.go -> pkg/mastotypes/history.go | 0
Rpkg/mastotypes/model/identityproof.go -> pkg/mastotypes/identityproof.go | 0
Rpkg/mastotypes/model/instance.go -> pkg/mastotypes/instance.go | 0
Rpkg/mastotypes/model/list.go -> pkg/mastotypes/list.go | 0
Rpkg/mastotypes/model/marker.go -> pkg/mastotypes/marker.go | 0
Rpkg/mastotypes/model/mention.go -> pkg/mastotypes/mention.go | 0
Rpkg/mastotypes/model/notification.go -> pkg/mastotypes/notification.go | 0
Rpkg/mastotypes/model/poll.go -> pkg/mastotypes/poll.go | 0
Rpkg/mastotypes/model/preferences.go -> pkg/mastotypes/preferences.go | 0
Rpkg/mastotypes/model/pushsubscription.go -> pkg/mastotypes/pushsubscription.go | 0
Rpkg/mastotypes/model/relationship.go -> pkg/mastotypes/relationship.go | 0
Rpkg/mastotypes/model/results.go -> pkg/mastotypes/results.go | 0
Rpkg/mastotypes/model/scheduledstatus.go -> pkg/mastotypes/scheduledstatus.go | 0
Rpkg/mastotypes/model/source.go -> pkg/mastotypes/source.go | 0
Rpkg/mastotypes/model/status.go -> pkg/mastotypes/status.go | 0
Rpkg/mastotypes/model/tag.go -> pkg/mastotypes/tag.go | 0
32 files changed, 38 insertions(+), 0 deletions(-)

diff --git 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 diff --git a/pkg/mastotypes/model/activity.go b/pkg/mastotypes/activity.go diff --git a/pkg/mastotypes/model/admin.go b/pkg/mastotypes/admin.go diff --git a/pkg/mastotypes/model/announcement.go b/pkg/mastotypes/announcement.go diff --git a/pkg/mastotypes/model/announcementreaction.go b/pkg/mastotypes/announcementreaction.go diff --git a/pkg/mastotypes/model/application.go b/pkg/mastotypes/application.go diff --git a/pkg/mastotypes/model/attachment.go b/pkg/mastotypes/attachment.go diff --git a/pkg/mastotypes/model/card.go b/pkg/mastotypes/card.go diff --git a/pkg/mastotypes/model/context.go b/pkg/mastotypes/context.go diff --git a/pkg/mastotypes/model/conversation.go b/pkg/mastotypes/conversation.go diff --git a/pkg/mastotypes/model/emoji.go b/pkg/mastotypes/emoji.go diff --git a/pkg/mastotypes/model/error.go b/pkg/mastotypes/error.go diff --git a/pkg/mastotypes/model/featuredtag.go b/pkg/mastotypes/featuredtag.go diff --git a/pkg/mastotypes/model/field.go b/pkg/mastotypes/field.go diff --git a/pkg/mastotypes/model/filter.go b/pkg/mastotypes/filter.go diff --git a/pkg/mastotypes/model/history.go b/pkg/mastotypes/history.go diff --git a/pkg/mastotypes/model/identityproof.go b/pkg/mastotypes/identityproof.go diff --git a/pkg/mastotypes/model/instance.go b/pkg/mastotypes/instance.go diff --git a/pkg/mastotypes/model/list.go b/pkg/mastotypes/list.go diff --git a/pkg/mastotypes/model/marker.go b/pkg/mastotypes/marker.go diff --git a/pkg/mastotypes/model/mention.go b/pkg/mastotypes/mention.go diff --git a/pkg/mastotypes/model/notification.go b/pkg/mastotypes/notification.go diff --git a/pkg/mastotypes/model/poll.go b/pkg/mastotypes/poll.go diff --git a/pkg/mastotypes/model/preferences.go b/pkg/mastotypes/preferences.go diff --git a/pkg/mastotypes/model/pushsubscription.go b/pkg/mastotypes/pushsubscription.go diff --git a/pkg/mastotypes/model/relationship.go b/pkg/mastotypes/relationship.go diff --git a/pkg/mastotypes/model/results.go b/pkg/mastotypes/results.go diff --git a/pkg/mastotypes/model/scheduledstatus.go b/pkg/mastotypes/scheduledstatus.go diff --git a/pkg/mastotypes/model/source.go b/pkg/mastotypes/source.go diff --git a/pkg/mastotypes/model/status.go b/pkg/mastotypes/status.go diff --git a/pkg/mastotypes/model/tag.go b/pkg/mastotypes/tag.go