diff --git a/storage-new/self.go b/storage-new/self.go index b72a5ad..8e12888 100644 --- a/storage-new/self.go +++ b/storage-new/self.go @@ -7,7 +7,6 @@ import ( "git.mstar.dev/mstar/goutils/other" "github.com/google/uuid" - "github.com/rs/zerolog/log" "gorm.io/gorm" "git.mstar.dev/mstar/linstrom/config" @@ -27,7 +26,6 @@ func InsertSelf() error { if err != nil { return other.Error("storage", "failed to save/update self server", err) } - log.Debug().Any("server", server).Send() user, err := insertUser(server) if err != nil { return other.Error("storage", "failed to save/update self user", err) @@ -35,6 +33,9 @@ func InsertSelf() error { if err = insertUserPronoun(user); err != nil { return other.Error("storage", "failed to save/update self user pronoun", err) } + if err = attachUserToRole(user); err != nil { + return other.Error("storage", "failed to save/update self user to full admin role", err) + } return nil } @@ -152,3 +153,13 @@ func insertUserPronoun(user *models.User) error { return err } } + +func attachUserToRole(user *models.User) error { + u2r := models.UserToRole{ + User: *user, + UserId: user.ID, + Role: models.FullAdminRole, + RoleId: models.FullAdminRole.ID, + } + return dbgen.UserToRole.Save(&u2r) +} diff --git a/web/debug/server.go b/web/debug/server.go index 9042b56..e0afc95 100644 --- a/web/debug/server.go +++ b/web/debug/server.go @@ -1,3 +1,12 @@ +// Package webdebug provides a http server for local debugging. +// The server is explicitly for localhost only as it offers +// a lot more control and access than the public one. +// Additionally, there is no guarantee for functional authentication +// and authorisation of requests. +// Using it can be considered a security risk. +// +// There is no guarantee for API stability. It might change drastically +// across versions or even commits and doesn't need announcements package webdebug import ( @@ -16,6 +25,8 @@ func New() *Server { handler.HandleFunc("GET /non-deleted", getNonDeletedUsers) handler.HandleFunc("POST /local-user", createLocalUser) handler.HandleFunc("GET /delete", deleteUser) + handler.HandleFunc("POST /post-as", postAs) + handler.HandleFunc("GET /notes-for", notesFrom) web := http.Server{ Addr: DebugAddr, Handler: handler, diff --git a/web/public/server.go b/web/public/server.go index df8c3a6..53d8911 100644 --- a/web/public/server.go +++ b/web/public/server.go @@ -1,3 +1,29 @@ +// Package webpublic contains the public webserver +// which provides the primary and only intended access point +// for interacting with the system. +// +// # Sections +// +// - Frontend: Serves the various web frontend versions +// - Main: The original Linstrom specific frontend +// - NoJs: An entirely serverside rendered frontend, no JS included +// - Custom: Custom frontend files will be served here +// +// - API: Endpoints for the actual interactions +// - Frontend: The API used by the main frontend +// - Masto: Mastodon compatible adapter for internal structures +// - ActivityPub: For integration with the Fediverse via ActivityPub +// - Linstrom-RPC: For Linstrom to Linstrom server communication +// +// # Guarantees +// +// - The Masto and ActivityPub API will remain stable +// - Frontend API might change, but the intended consumer (Main frontend) +// will always be up to date with the changes +// - Linstrom-RPC API is versioned and will keep +// a few versions of backwards compatibility +// +// TODO: Decide how long the Linstrom-RPC API will remain backwards compatible package webpublic import "net/http" diff --git a/web/shared/User.go b/web/shared/User.go index 5c11fc4..01775ba 100644 --- a/web/shared/User.go +++ b/web/shared/User.go @@ -39,7 +39,7 @@ type User struct { } // Compiler assertations for interface implementations -var _ shared.Santisable = &User{} +var _ shared.Sanitisable = &User{} var _ shared.Clonable = &User{} func (u *User) Sanitize() {