diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go index 95cf971..11b1b57 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 similarity index 100% rename from pkg/mastotypes/model/account.go rename to pkg/mastotypes/account.go diff --git a/pkg/mastotypes/model/activity.go b/pkg/mastotypes/activity.go similarity index 100% rename from pkg/mastotypes/model/activity.go rename to pkg/mastotypes/activity.go diff --git a/pkg/mastotypes/model/admin.go b/pkg/mastotypes/admin.go similarity index 100% rename from pkg/mastotypes/model/admin.go rename to pkg/mastotypes/admin.go diff --git a/pkg/mastotypes/model/announcement.go b/pkg/mastotypes/announcement.go similarity index 100% rename from pkg/mastotypes/model/announcement.go rename to pkg/mastotypes/announcement.go diff --git a/pkg/mastotypes/model/announcementreaction.go b/pkg/mastotypes/announcementreaction.go similarity index 100% rename from pkg/mastotypes/model/announcementreaction.go rename to pkg/mastotypes/announcementreaction.go diff --git a/pkg/mastotypes/model/application.go b/pkg/mastotypes/application.go similarity index 100% rename from pkg/mastotypes/model/application.go rename to pkg/mastotypes/application.go diff --git a/pkg/mastotypes/model/attachment.go b/pkg/mastotypes/attachment.go similarity index 100% rename from pkg/mastotypes/model/attachment.go rename to pkg/mastotypes/attachment.go diff --git a/pkg/mastotypes/model/card.go b/pkg/mastotypes/card.go similarity index 100% rename from pkg/mastotypes/model/card.go rename to pkg/mastotypes/card.go diff --git a/pkg/mastotypes/model/context.go b/pkg/mastotypes/context.go similarity index 100% rename from pkg/mastotypes/model/context.go rename to pkg/mastotypes/context.go diff --git a/pkg/mastotypes/model/conversation.go b/pkg/mastotypes/conversation.go similarity index 100% rename from pkg/mastotypes/model/conversation.go rename to pkg/mastotypes/conversation.go diff --git a/pkg/mastotypes/model/emoji.go b/pkg/mastotypes/emoji.go similarity index 100% rename from pkg/mastotypes/model/emoji.go rename to pkg/mastotypes/emoji.go diff --git a/pkg/mastotypes/model/error.go b/pkg/mastotypes/error.go similarity index 100% rename from pkg/mastotypes/model/error.go rename to pkg/mastotypes/error.go diff --git a/pkg/mastotypes/model/featuredtag.go b/pkg/mastotypes/featuredtag.go similarity index 100% rename from pkg/mastotypes/model/featuredtag.go rename to pkg/mastotypes/featuredtag.go diff --git a/pkg/mastotypes/model/field.go b/pkg/mastotypes/field.go similarity index 100% rename from pkg/mastotypes/model/field.go rename to pkg/mastotypes/field.go diff --git a/pkg/mastotypes/model/filter.go b/pkg/mastotypes/filter.go similarity index 100% rename from pkg/mastotypes/model/filter.go rename to pkg/mastotypes/filter.go diff --git a/pkg/mastotypes/model/history.go b/pkg/mastotypes/history.go similarity index 100% rename from pkg/mastotypes/model/history.go rename to pkg/mastotypes/history.go diff --git a/pkg/mastotypes/model/identityproof.go b/pkg/mastotypes/identityproof.go similarity index 100% rename from pkg/mastotypes/model/identityproof.go rename to pkg/mastotypes/identityproof.go diff --git a/pkg/mastotypes/model/instance.go b/pkg/mastotypes/instance.go similarity index 100% rename from pkg/mastotypes/model/instance.go rename to pkg/mastotypes/instance.go diff --git a/pkg/mastotypes/model/list.go b/pkg/mastotypes/list.go similarity index 100% rename from pkg/mastotypes/model/list.go rename to pkg/mastotypes/list.go diff --git a/pkg/mastotypes/model/marker.go b/pkg/mastotypes/marker.go similarity index 100% rename from pkg/mastotypes/model/marker.go rename to pkg/mastotypes/marker.go diff --git a/pkg/mastotypes/model/mention.go b/pkg/mastotypes/mention.go similarity index 100% rename from pkg/mastotypes/model/mention.go rename to pkg/mastotypes/mention.go diff --git a/pkg/mastotypes/model/notification.go b/pkg/mastotypes/notification.go similarity index 100% rename from pkg/mastotypes/model/notification.go rename to pkg/mastotypes/notification.go diff --git a/pkg/mastotypes/model/poll.go b/pkg/mastotypes/poll.go similarity index 100% rename from pkg/mastotypes/model/poll.go rename to pkg/mastotypes/poll.go diff --git a/pkg/mastotypes/model/preferences.go b/pkg/mastotypes/preferences.go similarity index 100% rename from pkg/mastotypes/model/preferences.go rename to pkg/mastotypes/preferences.go diff --git a/pkg/mastotypes/model/pushsubscription.go b/pkg/mastotypes/pushsubscription.go similarity index 100% rename from pkg/mastotypes/model/pushsubscription.go rename to pkg/mastotypes/pushsubscription.go diff --git a/pkg/mastotypes/model/relationship.go b/pkg/mastotypes/relationship.go similarity index 100% rename from pkg/mastotypes/model/relationship.go rename to pkg/mastotypes/relationship.go diff --git a/pkg/mastotypes/model/results.go b/pkg/mastotypes/results.go similarity index 100% rename from pkg/mastotypes/model/results.go rename to pkg/mastotypes/results.go diff --git a/pkg/mastotypes/model/scheduledstatus.go b/pkg/mastotypes/scheduledstatus.go similarity index 100% rename from pkg/mastotypes/model/scheduledstatus.go rename to pkg/mastotypes/scheduledstatus.go diff --git a/pkg/mastotypes/model/source.go b/pkg/mastotypes/source.go similarity index 100% rename from pkg/mastotypes/model/source.go rename to pkg/mastotypes/source.go diff --git a/pkg/mastotypes/model/status.go b/pkg/mastotypes/status.go similarity index 100% rename from pkg/mastotypes/model/status.go rename to pkg/mastotypes/status.go diff --git a/pkg/mastotypes/model/tag.go b/pkg/mastotypes/tag.go similarity index 100% rename from pkg/mastotypes/model/tag.go rename to pkg/mastotypes/tag.go