diff --git a/.gitignore b/.gitignore index d7fb509..a549da2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,8 @@ node_modules/ -passwordreset*.json mail/*.html -scss/*.css* -scss/bs4/*.css* -scss/bs5/*.css* -data/static/*.css -data/static/*.js -data/static/*.js.map -data/static/ts/ -data/static/modules/ -!data/static/setup.js -data/config-base.json -data/config-default.ini -data/*.html -data/*.txt -data/docs/ dist/* -jfa-go build/ -pkg/ -old/ version.go notes docs/* !docs/go.mod -js/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..dc91e2a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Harvey Tindall + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6ae9317 --- /dev/null +++ b/Makefile @@ -0,0 +1,61 @@ +configuration: + $(info Fixing config-base) + -mkdir -p build/data + python3 config/fixconfig.py -i config/config-base.json -o build/data/config-base.json + $(info Generating config-default.ini) + python3 config/generate_ini.py -i config/config-base.json -o build/data/config-default.ini + +email: + $(info Generating email html) + python3 mail/generate.py + +ts: + $(info compiling typescript) + -mkdir -p build/data/web/js + -npx esbuild ts/*.ts ts/modules/*.ts --sourcemap --outdir=./build/data/web/js/ + +ts-debug: + $(info compiling typescript w/ sourcemaps) + -mkdir -p build/data/web/js + -npx esbuild ts/*.ts ts/modules/*.ts --sourcemap --outdir=./build/data/web/js/ + -rm -r build/data/web/js/ts + $(info copying typescript) + cp -r ts build/data/web/js + +swagger: + go get github.com/swaggo/swag/cmd/swag + swag init -g main.go + +version: + python3 version.py auto version.go + +compile: + $(info Downloading deps) + go mod download + $(info Building) + mkdir -p build + CGO_ENABLED=0 go build -o build/jfa-go *.go + +compress: + upx --lzma build/jfa-go + +copy: + $(info copying css) + -mkdir -p build/data/web/css + cp -r css build/data/web/ + cp node_modules/a17t/dist/a17t.css build/data/web/css/ + cp -r node_modules/remixicon/fonts/remixicon.css node_modules/remixicon/fonts/remixicon.woff2 build/data/web/css/ + $(info copying html) + cp -r html build/data/ + $(info copying static data) + -mkdir -p build/data/web + cp -r static/* build/data/web/ + $(info copying language files) + cp -r lang build/data/ + + +install: + cp -r build $(DESTDIR)/jfa-go + +all: configuration email version ts swagger compile copy +debug: configuration email version ts-debug swagger compile copy diff --git a/README.md b/README.md index 32756ed..c27a77e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -This branch is for experimenting with [a17t](https://a17t.miles.land/) to possibly replace bootstrap in the future. Currently just working on the page structures, so none of this is actually usable in jfa-go yet. +This branch is for experimenting with [a17t](https://a17t.miles.land/) to replace bootstrap. Page structure is pretty much done (except setup.html), so i'm currently integrating this with the main app and existing web code. #### todo **general** @@ -15,7 +15,8 @@ This branch is for experimenting with [a17t](https://a17t.miles.land/) to possib * [ ] integration with existing code **invites** -* [ ] everything +* [x] page design +* [ ] integration with existing code #### screenshots ##### dark diff --git a/api.go b/api.go new file mode 100644 index 0000000..e01920f --- /dev/null +++ b/api.go @@ -0,0 +1,1264 @@ +package main + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "path/filepath" + "strconv" + "strings" + "time" + + "github.com/gin-gonic/gin" + "github.com/knz/strtime" + "github.com/lithammer/shortuuid/v3" + "gopkg.in/ini.v1" +) + +func respond(code int, message string, gc *gin.Context) { + resp := stringResponse{} + if code == 200 || code == 204 { + resp.Response = message + } else { + resp.Error = message + } + gc.JSON(code, resp) + gc.Abort() +} + +func respondBool(code int, val bool, gc *gin.Context) { + resp := boolResponse{} + if !val { + resp.Error = true + } else { + resp.Success = true + } + gc.JSON(code, resp) + gc.Abort() +} + +func (app *appContext) loadStrftime() { + app.datePattern = app.config.Section("email").Key("date_format").String() + app.timePattern = `%H:%M` + if val, _ := app.config.Section("email").Key("use_24h").Bool(); !val { + app.timePattern = `%I:%M %p` + } + return +} + +func (app *appContext) prettyTime(dt time.Time) (date, time string) { + date, _ = strtime.Strftime(dt, app.datePattern) + time, _ = strtime.Strftime(dt, app.timePattern) + return +} + +func (app *appContext) formatDatetime(dt time.Time) string { + d, t := app.prettyTime(dt) + return d + " " + t +} + +// https://stackoverflow.com/questions/36530251/time-since-with-months-and-years/36531443#36531443 THANKS +func timeDiff(a, b time.Time) (year, month, day, hour, min, sec int) { + if a.Location() != b.Location() { + b = b.In(a.Location()) + } + if a.After(b) { + a, b = b, a + } + y1, M1, d1 := a.Date() + y2, M2, d2 := b.Date() + + h1, m1, s1 := a.Clock() + h2, m2, s2 := b.Clock() + + year = int(y2 - y1) + month = int(M2 - M1) + day = int(d2 - d1) + hour = int(h2 - h1) + min = int(m2 - m1) + sec = int(s2 - s1) + + // Normalize negative values + if sec < 0 { + sec += 60 + min-- + } + if min < 0 { + min += 60 + hour-- + } + if hour < 0 { + hour += 24 + day-- + } + if day < 0 { + // days in month: + t := time.Date(y1, M1, 32, 0, 0, 0, 0, time.UTC) + day += 32 - t.Day() + month-- + } + if month < 0 { + month += 12 + year-- + } + return +} + +func (app *appContext) checkInvites() { + currentTime := time.Now() + app.storage.loadInvites() + changed := false + for code, data := range app.storage.invites { + expiry := data.ValidTill + if !currentTime.After(expiry) { + continue + } + app.debug.Printf("Housekeeping: Deleting old invite %s", code) + notify := data.Notify + if app.config.Section("notifications").Key("enabled").MustBool(false) && len(notify) != 0 { + app.debug.Printf("%s: Expiry notification", code) + for address, settings := range notify { + if !settings["notify-expiry"] { + continue + } + go func() { + msg, err := app.email.constructExpiry(code, data, app) + if err != nil { + app.err.Printf("%s: Failed to construct expiry notification", code) + app.debug.Printf("Error: %s", err) + } else if err := app.email.send(address, msg); err != nil { + app.err.Printf("%s: Failed to send expiry notification", code) + app.debug.Printf("Error: %s", err) + } else { + app.info.Printf("Sent expiry notification to %s", address) + } + }() + } + } + changed = true + delete(app.storage.invites, code) + } + if changed { + app.storage.storeInvites() + } +} + +func (app *appContext) checkInvite(code string, used bool, username string) bool { + currentTime := time.Now() + app.storage.loadInvites() + changed := false + inv, match := app.storage.invites[code] + if !match { + return false + } + expiry := inv.ValidTill + if currentTime.After(expiry) { + app.debug.Printf("Housekeeping: Deleting old invite %s", code) + notify := inv.Notify + if app.config.Section("notifications").Key("enabled").MustBool(false) && len(notify) != 0 { + app.debug.Printf("%s: Expiry notification", code) + for address, settings := range notify { + if settings["notify-expiry"] { + go func() { + msg, err := app.email.constructExpiry(code, inv, app) + if err != nil { + app.err.Printf("%s: Failed to construct expiry notification", code) + app.debug.Printf("Error: %s", err) + } else if err := app.email.send(address, msg); err != nil { + app.err.Printf("%s: Failed to send expiry notification", code) + app.debug.Printf("Error: %s", err) + } else { + app.info.Printf("Sent expiry notification to %s", address) + } + }() + } + } + } + changed = true + match = false + delete(app.storage.invites, code) + } else if used { + changed = true + del := false + newInv := inv + if newInv.RemainingUses == 1 { + del = true + delete(app.storage.invites, code) + } else if newInv.RemainingUses != 0 { + // 0 means infinite i guess? + newInv.RemainingUses -= 1 + } + newInv.UsedBy = append(newInv.UsedBy, []string{username, app.formatDatetime(currentTime)}) + if !del { + app.storage.invites[code] = newInv + } + } + if changed { + app.storage.storeInvites() + } + return match +} + +func (app *appContext) getOmbiUser(jfID string) (map[string]interface{}, int, error) { + ombiUsers, code, err := app.ombi.GetUsers() + if err != nil || code != 200 { + return nil, code, err + } + jfUser, code, err := app.jf.UserByID(jfID, false) + if err != nil || code != 200 { + return nil, code, err + } + username := jfUser["Name"].(string) + email := "" + if e, ok := app.storage.emails[jfID]; ok { + email = e.(string) + } + for _, ombiUser := range ombiUsers { + ombiAddr := "" + if a, ok := ombiUser["emailAddress"]; ok && a != nil { + ombiAddr = a.(string) + } + if ombiUser["userName"].(string) == username || (ombiAddr == email && email != "") { + return ombiUser, code, err + } + } + return nil, 400, fmt.Errorf("Couldn't find user") +} + +// Routes from now on! + +// @Summary Creates a new Jellyfin user without an invite. +// @Produce json +// @Param newUserDTO body newUserDTO true "New user request object" +// @Success 200 +// @Router /users [post] +// @Security Bearer +// @tags Users +func (app *appContext) NewUserAdmin(gc *gin.Context) { + var req newUserDTO + gc.BindJSON(&req) + existingUser, _, _ := app.jf.UserByName(req.Username, false) + if existingUser != nil { + msg := fmt.Sprintf("User already exists named %s", req.Username) + app.info.Printf("%s New user failed: %s", req.Username, msg) + respond(401, msg, gc) + return + } + user, status, err := app.jf.NewUser(req.Username, req.Password) + if !(status == 200 || status == 204) || err != nil { + app.err.Printf("%s New user failed: Jellyfin responded with %d", req.Username, status) + respond(401, "Unknown error", gc) + return + } + var id string + if user["Id"] != nil { + id = user["Id"].(string) + } + if len(app.storage.policy) != 0 { + status, err = app.jf.SetPolicy(id, app.storage.policy) + if !(status == 200 || status == 204 || err == nil) { + app.err.Printf("%s: Failed to set user policy: Code %d", req.Username, status) + app.debug.Printf("%s: Error: %s", req.Username, err) + } + } + if len(app.storage.configuration) != 0 && len(app.storage.displayprefs) != 0 { + status, err = app.jf.SetConfiguration(id, app.storage.configuration) + if (status == 200 || status == 204) && err == nil { + status, err = app.jf.SetDisplayPreferences(id, app.storage.displayprefs) + } + if !((status == 200 || status == 204) && err == nil) { + app.err.Printf("%s: Failed to set configuration template: Code %d", req.Username, status) + } + } + if app.config.Section("password_resets").Key("enabled").MustBool(false) { + app.storage.emails[id] = req.Email + app.storage.storeEmails() + } + if app.config.Section("ombi").Key("enabled").MustBool(false) { + app.storage.loadOmbiTemplate() + if len(app.storage.ombi_template) != 0 { + errors, code, err := app.ombi.NewUser(req.Username, req.Password, req.Email, app.storage.ombi_template) + if err != nil || code != 200 { + app.info.Printf("Failed to create Ombi user (%d): %s", code, err) + app.debug.Printf("Errors reported by Ombi: %s", strings.Join(errors, ", ")) + } else { + app.info.Println("Created Ombi user") + } + } + } + app.jf.CacheExpiry = time.Now() +} + +// @Summary Creates a new Jellyfin user via invite code +// @Produce json +// @Param newUserDTO body newUserDTO true "New user request object" +// @Success 200 {object} PasswordValidation +// @Failure 400 {object} PasswordValidation +// @Router /newUser [post] +// @tags Users +func (app *appContext) NewUser(gc *gin.Context) { + var req newUserDTO + gc.BindJSON(&req) + app.debug.Printf("%s: New user attempt", req.Code) + if !app.checkInvite(req.Code, false, "") { + app.info.Printf("%s New user failed: invalid code", req.Code) + respondBool(401, false, gc) + return + } + validation := app.validator.validate(req.Password) + valid := true + for _, val := range validation { + if !val { + valid = false + } + } + if !valid { + // 200 bcs idk what i did in js + app.info.Printf("%s New user failed: Invalid password", req.Code) + gc.JSON(200, validation) + gc.Abort() + return + } + existingUser, _, _ := app.jf.UserByName(req.Username, false) + if existingUser != nil { + msg := fmt.Sprintf("User already exists named %s", req.Username) + app.info.Printf("%s New user failed: %s", req.Code, msg) + respond(401, msg, gc) + return + } + user, status, err := app.jf.NewUser(req.Username, req.Password) + if !(status == 200 || status == 204) || err != nil { + app.err.Printf("%s New user failed: Jellyfin responded with %d", req.Code, status) + respond(401, "Unknown error", gc) + return + } + app.storage.loadProfiles() + invite := app.storage.invites[req.Code] + app.checkInvite(req.Code, true, req.Username) + if app.config.Section("notifications").Key("enabled").MustBool(false) { + for address, settings := range invite.Notify { + if settings["notify-creation"] { + go func() { + msg, err := app.email.constructCreated(req.Code, req.Username, req.Email, invite, app) + if err != nil { + app.err.Printf("%s: Failed to construct user creation notification", req.Code) + app.debug.Printf("%s: Error: %s", req.Code, err) + } else if err := app.email.send(address, msg); err != nil { + app.err.Printf("%s: Failed to send user creation notification", req.Code) + app.debug.Printf("%s: Error: %s", req.Code, err) + } else { + app.info.Printf("%s: Sent user creation notification to %s", req.Code, address) + } + }() + } + } + } + var id string + if user["Id"] != nil { + id = user["Id"].(string) + } + if invite.Profile != "" { + app.debug.Printf("Applying settings from profile \"%s\"", invite.Profile) + profile, ok := app.storage.profiles[invite.Profile] + if !ok { + profile = app.storage.profiles["Default"] + } + if len(profile.Policy) != 0 { + app.debug.Printf("Applying policy from profile \"%s\"", invite.Profile) + status, err = app.jf.SetPolicy(id, profile.Policy) + if !((status == 200 || status == 204) && err == nil) { + app.err.Printf("%s: Failed to set user policy: Code %d", req.Code, status) + app.debug.Printf("%s: Error: %s", req.Code, err) + } + } + if len(profile.Configuration) != 0 && len(profile.Displayprefs) != 0 { + app.debug.Printf("Applying homescreen from profile \"%s\"", invite.Profile) + status, err = app.jf.SetConfiguration(id, profile.Configuration) + if (status == 200 || status == 204) && err == nil { + status, err = app.jf.SetDisplayPreferences(id, profile.Displayprefs) + } + if !((status == 200 || status == 204) && err == nil) { + app.err.Printf("%s: Failed to set configuration template: Code %d", req.Code, status) + app.debug.Printf("%s: Error: %s", req.Code, err) + } + } + } + // if app.config.Section("password_resets").Key("enabled").MustBool(false) { + if req.Email != "" { + app.storage.emails[id] = req.Email + app.storage.storeEmails() + } + if app.config.Section("ombi").Key("enabled").MustBool(false) { + app.storage.loadOmbiTemplate() + if len(app.storage.ombi_template) != 0 { + errors, code, err := app.ombi.NewUser(req.Username, req.Password, req.Email, app.storage.ombi_template) + if err != nil || code != 200 { + app.info.Printf("Failed to create Ombi user (%d): %s", code, err) + app.debug.Printf("Errors reported by Ombi: %s", strings.Join(errors, ", ")) + } else { + app.info.Println("Created Ombi user") + } + } + } + code := 200 + for _, val := range validation { + if !val { + code = 400 + } + } + gc.JSON(code, validation) +} + +// @Summary Delete a list of users, optionally notifying them why. +// @Produce json +// @Param deleteUserDTO body deleteUserDTO true "User deletion request object" +// @Success 200 {object} boolResponse +// @Failure 400 {object} stringResponse +// @Failure 500 {object} errorListDTO "List of errors" +// @Router /users [delete] +// @Security Bearer +// @tags Users +func (app *appContext) DeleteUser(gc *gin.Context) { + var req deleteUserDTO + gc.BindJSON(&req) + errors := map[string]string{} + ombiEnabled := app.config.Section("ombi").Key("enabled").MustBool(false) + for _, userID := range req.Users { + if ombiEnabled { + ombiUser, code, err := app.getOmbiUser(userID) + if code == 200 && err == nil { + if id, ok := ombiUser["id"]; ok { + status, err := app.ombi.DeleteUser(id.(string)) + if err != nil || status != 200 { + app.err.Printf("Failed to delete ombi user: %d %s", status, err) + errors[userID] = fmt.Sprintf("Ombi: %d %s, ", status, err) + } + } + } + } + status, err := app.jf.DeleteUser(userID) + if !(status == 200 || status == 204) || err != nil { + msg := fmt.Sprintf("%d: %s", status, err) + if _, ok := errors[userID]; !ok { + errors[userID] = msg + } else { + errors[userID] += msg + } + } + if req.Notify { + addr, ok := app.storage.emails[userID] + if addr != nil && ok { + go func(userID, reason, address string) { + msg, err := app.email.constructDeleted(reason, app) + if err != nil { + app.err.Printf("%s: Failed to construct account deletion email", userID) + app.debug.Printf("%s: Error: %s", userID, err) + } else if err := app.email.send(address, msg); err != nil { + app.err.Printf("%s: Failed to send to %s", userID, address) + app.debug.Printf("%s: Error: %s", userID, err) + } else { + app.info.Printf("%s: Sent invite email to %s", userID, address) + } + }(userID, req.Reason, addr.(string)) + } + } + } + app.jf.CacheExpiry = time.Now() + if len(errors) == len(req.Users) { + respondBool(500, false, gc) + app.err.Printf("Account deletion failed: %s", errors[req.Users[0]]) + return + } else if len(errors) != 0 { + gc.JSON(500, errors) + return + } + respondBool(200, true, gc) +} + +// @Summary Create a new invite. +// @Produce json +// @Param generateInviteDTO body generateInviteDTO true "New invite request object" +// @Success 200 {object} boolResponse +// @Router /invites [post] +// @Security Bearer +// @tags Invites +func (app *appContext) GenerateInvite(gc *gin.Context) { + var req generateInviteDTO + app.debug.Println("Generating new invite") + app.storage.loadInvites() + gc.BindJSON(&req) + currentTime := time.Now() + validTill := currentTime.AddDate(0, 0, req.Days) + validTill = validTill.Add(time.Hour*time.Duration(req.Hours) + time.Minute*time.Duration(req.Minutes)) + // make sure code doesn't begin with number + inviteCode := shortuuid.New() + _, err := strconv.Atoi(string(inviteCode[0])) + for err == nil { + inviteCode = shortuuid.New() + _, err = strconv.Atoi(string(inviteCode[0])) + } + var invite Invite + invite.Created = currentTime + if req.MultipleUses { + if req.NoLimit { + invite.NoLimit = true + } else { + invite.RemainingUses = req.RemainingUses + } + } else { + invite.RemainingUses = 1 + } + invite.ValidTill = validTill + if req.Email != "" && app.config.Section("invite_emails").Key("enabled").MustBool(false) { + app.debug.Printf("%s: Sending invite email", inviteCode) + invite.Email = req.Email + msg, err := app.email.constructInvite(inviteCode, invite, app) + if err != nil { + invite.Email = fmt.Sprintf("Failed to send to %s", req.Email) + app.err.Printf("%s: Failed to construct invite email", inviteCode) + app.debug.Printf("%s: Error: %s", inviteCode, err) + } else if err := app.email.send(req.Email, msg); err != nil { + invite.Email = fmt.Sprintf("Failed to send to %s", req.Email) + app.err.Printf("%s: %s", inviteCode, invite.Email) + app.debug.Printf("%s: Error: %s", inviteCode, err) + } else { + app.info.Printf("%s: Sent invite email to %s", inviteCode, req.Email) + } + } + if req.Profile != "" { + if _, ok := app.storage.profiles[req.Profile]; ok { + invite.Profile = req.Profile + } else { + invite.Profile = "Default" + } + } + app.storage.invites[inviteCode] = invite + app.storage.storeInvites() + respondBool(200, true, gc) +} + +// @Summary Set profile for an invite +// @Produce json +// @Param inviteProfileDTO body inviteProfileDTO true "Invite profile object" +// @Success 200 {object} boolResponse +// @Failure 500 {object} stringResponse +// @Router /invites/profile [post] +// @Security Bearer +// @tags Profiles & Settings +func (app *appContext) SetProfile(gc *gin.Context) { + var req inviteProfileDTO + gc.BindJSON(&req) + app.debug.Printf("%s: Setting profile to \"%s\"", req.Invite, req.Profile) + // "" means "Don't apply profile" + if _, ok := app.storage.profiles[req.Profile]; !ok && req.Profile != "" { + app.err.Printf("%s: Profile \"%s\" not found", req.Invite, req.Profile) + respond(500, "Profile not found", gc) + return + } + inv := app.storage.invites[req.Invite] + inv.Profile = req.Profile + app.storage.invites[req.Invite] = inv + app.storage.storeInvites() + respondBool(200, true, gc) +} + +// @Summary Get a list of profiles +// @Produce json +// @Success 200 {object} getProfilesDTO +// @Router /profiles [get] +// @Security Bearer +// @tags Profiles & Settings +func (app *appContext) GetProfiles(gc *gin.Context) { + app.storage.loadProfiles() + app.debug.Println("Profiles requested") + out := getProfilesDTO{ + DefaultProfile: app.storage.defaultProfile, + Profiles: map[string]profileDTO{}, + } + for name, p := range app.storage.profiles { + out.Profiles[name] = profileDTO{ + Admin: p.Admin, + LibraryAccess: p.LibraryAccess, + FromUser: p.FromUser, + } + } + gc.JSON(200, out) +} + +// @Summary Set the default profile to use. +// @Produce json +// @Param profileChangeDTO body profileChangeDTO true "Default profile object" +// @Success 200 {object} boolResponse +// @Failure 500 {object} stringResponse +// @Router /profiles/default [post] +// @Security Bearer +// @tags Profiles & Settings +func (app *appContext) SetDefaultProfile(gc *gin.Context) { + req := profileChangeDTO{} + gc.BindJSON(&req) + app.info.Printf("Setting default profile to \"%s\"", req.Name) + if _, ok := app.storage.profiles[req.Name]; !ok { + app.err.Printf("Profile not found: \"%s\"", req.Name) + respond(500, "Profile not found", gc) + return + } + for name, profile := range app.storage.profiles { + if name == req.Name { + profile.Admin = true + app.storage.profiles[name] = profile + } else { + profile.Admin = false + } + } + app.storage.defaultProfile = req.Name + respondBool(200, true, gc) +} + +// @Summary Create a profile based on a Jellyfin user's settings. +// @Produce json +// @Param newProfileDTO body newProfileDTO true "New profile object" +// @Success 200 {object} boolResponse +// @Failure 500 {object} stringResponse +// @Router /profiles [post] +// @Security Bearer +// @tags Profiles & Settings +func (app *appContext) CreateProfile(gc *gin.Context) { + app.info.Println("Profile creation requested") + var req newProfileDTO + gc.BindJSON(&req) + user, status, err := app.jf.UserByID(req.ID, false) + if !(status == 200 || status == 204) || err != nil { + app.err.Printf("Failed to get user from Jellyfin: Code %d", status) + app.debug.Printf("Error: %s", err) + respond(500, "Couldn't get user", gc) + return + } + profile := Profile{ + FromUser: user["Name"].(string), + Policy: user["Policy"].(map[string]interface{}), + } + app.debug.Printf("Creating profile from user \"%s\"", user["Name"].(string)) + if req.Homescreen { + profile.Configuration = user["Configuration"].(map[string]interface{}) + profile.Displayprefs, status, err = app.jf.GetDisplayPreferences(req.ID) + if !(status == 200 || status == 204) || err != nil { + app.err.Printf("Failed to get DisplayPrefs: Code %d", status) + app.debug.Printf("Error: %s", err) + respond(500, "Couldn't get displayprefs", gc) + return + } + } + app.storage.loadProfiles() + app.storage.profiles[req.Name] = profile + app.storage.storeProfiles() + app.storage.loadProfiles() + respondBool(200, true, gc) +} + +// @Summary Delete an existing profile +// @Produce json +// @Param profileChangeDTO body profileChangeDTO true "Delete profile object" +// @Success 200 {object} boolResponse +// @Router /profiles [delete] +// @Security Bearer +// @tags Profiles & Settings +func (app *appContext) DeleteProfile(gc *gin.Context) { + req := profileChangeDTO{} + gc.BindJSON(&req) + name := req.Name + if _, ok := app.storage.profiles[name]; ok { + delete(app.storage.profiles, name) + } + app.storage.storeProfiles() + respondBool(200, true, gc) +} + +// @Summary Get invites. +// @Produce json +// @Success 200 {object} getInvitesDTO +// @Router /invites [get] +// @Security Bearer +// @tags Invites +func (app *appContext) GetInvites(gc *gin.Context) { + app.debug.Println("Invites requested") + currentTime := time.Now() + app.storage.loadInvites() + app.checkInvites() + var invites []inviteDTO + for code, inv := range app.storage.invites { + _, _, days, hours, minutes, _ := timeDiff(inv.ValidTill, currentTime) + invite := inviteDTO{ + Code: code, + Days: days, + Hours: hours, + Minutes: minutes, + Created: app.formatDatetime(inv.Created), + Profile: inv.Profile, + NoLimit: inv.NoLimit, + } + if len(inv.UsedBy) != 0 { + invite.UsedBy = inv.UsedBy + } + invite.RemainingUses = 1 + if inv.RemainingUses != 0 { + invite.RemainingUses = inv.RemainingUses + } + if inv.Email != "" { + invite.Email = inv.Email + } + if len(inv.Notify) != 0 { + var address string + if app.config.Section("ui").Key("jellyfin_login").MustBool(false) { + app.storage.loadEmails() + if addr := app.storage.emails[gc.GetString("jfId")]; addr != nil { + address = addr.(string) + } + } else { + address = app.config.Section("ui").Key("email").String() + } + if _, ok := inv.Notify[address]; ok { + if _, ok = inv.Notify[address]["notify-expiry"]; ok { + invite.NotifyExpiry = inv.Notify[address]["notify-expiry"] + } + if _, ok = inv.Notify[address]["notify-creation"]; ok { + invite.NotifyCreation = inv.Notify[address]["notify-creation"] + } + } + } + invites = append(invites, invite) + } + profiles := make([]string, len(app.storage.profiles)) + if len(app.storage.profiles) != 0 { + profiles[0] = app.storage.defaultProfile + i := 1 + if len(app.storage.profiles) > 1 { + for p := range app.storage.profiles { + if p != app.storage.defaultProfile { + profiles[i] = p + i++ + } + } + } + } + resp := getInvitesDTO{ + Profiles: profiles, + Invites: invites, + } + gc.JSON(200, resp) +} + +// @Summary Set notification preferences for an invite. +// @Produce json +// @Param setNotifyDTO body setNotifyDTO true "Map of invite codes to notification settings objects" +// @Success 200 +// @Failure 400 {object} stringResponse +// @Failure 500 {object} stringResponse +// @Router /invites/notify [post] +// @Security Bearer +// @tags Other +func (app *appContext) SetNotify(gc *gin.Context) { + var req map[string]map[string]bool + gc.BindJSON(&req) + changed := false + for code, settings := range req { + app.debug.Printf("%s: Notification settings change requested", code) + app.storage.loadInvites() + app.storage.loadEmails() + invite, ok := app.storage.invites[code] + if !ok { + app.err.Printf("%s Notification setting change failed: Invalid code", code) + respond(400, "Invalid invite code", gc) + return + } + var address string + if app.config.Section("ui").Key("jellyfin_login").MustBool(false) { + var ok bool + address, ok = app.storage.emails[gc.GetString("jfId")].(string) + if !ok { + app.err.Printf("%s: Couldn't find email address. Make sure it's set", code) + app.debug.Printf("%s: User ID \"%s\"", code, gc.GetString("jfId")) + respond(500, "Missing user email", gc) + return + } + } else { + address = app.config.Section("ui").Key("email").String() + } + if invite.Notify == nil { + invite.Notify = map[string]map[string]bool{} + } + if _, ok := invite.Notify[address]; !ok { + invite.Notify[address] = map[string]bool{} + } /*else { + if _, ok := invite.Notify[address]["notify-expiry"]; !ok { + */ + if _, ok := settings["notify-expiry"]; ok && invite.Notify[address]["notify-expiry"] != settings["notify-expiry"] { + invite.Notify[address]["notify-expiry"] = settings["notify-expiry"] + app.debug.Printf("%s: Set \"notify-expiry\" to %t for %s", code, settings["notify-expiry"], address) + changed = true + } + if _, ok := settings["notify-creation"]; ok && invite.Notify[address]["notify-creation"] != settings["notify-creation"] { + invite.Notify[address]["notify-creation"] = settings["notify-creation"] + app.debug.Printf("%s: Set \"notify-creation\" to %t for %s", code, settings["notify-creation"], address) + changed = true + } + if changed { + app.storage.invites[code] = invite + } + } + if changed { + app.storage.storeInvites() + } +} + +// @Summary Delete an invite. +// @Produce json +// @Param deleteInviteDTO body deleteInviteDTO true "Delete invite object" +// @Success 200 {object} boolResponse +// @Failure 400 {object} stringResponse +// @Router /invites [delete] +// @Security Bearer +// @tags Invites +func (app *appContext) DeleteInvite(gc *gin.Context) { + var req deleteInviteDTO + gc.BindJSON(&req) + app.debug.Printf("%s: Deletion requested", req.Code) + var ok bool + _, ok = app.storage.invites[req.Code] + if ok { + delete(app.storage.invites, req.Code) + app.storage.storeInvites() + app.info.Printf("%s: Invite deleted", req.Code) + respondBool(200, true, gc) + return + } + app.err.Printf("%s: Deletion failed: Invalid code", req.Code) + respond(400, "Code doesn't exist", gc) +} + +type dateToParse struct { + Parsed time.Time `json:"parseme"` +} + +func parseDT(date string) time.Time { + // decent method + dt, err := time.Parse("2006-01-02T15:04:05.000000", date) + if err == nil { + return dt + } + // magic method + // some stored dates from jellyfin have no timezone at the end, if not we assume UTC + if date[len(date)-1] != 'Z' { + date += "Z" + } + timeJSON := []byte("{ \"parseme\": \"" + date + "\" }") + var parsed dateToParse + // Magically turn it into a time.Time + json.Unmarshal(timeJSON, &parsed) + return parsed.Parsed +} + +// @Summary Get a list of Jellyfin users. +// @Produce json +// @Success 200 {object} getUsersDTO +// @Failure 500 {object} stringResponse +// @Router /users [get] +// @Security Bearer +// @tags Users +func (app *appContext) GetUsers(gc *gin.Context) { + app.debug.Println("Users requested") + var resp getUsersDTO + resp.UserList = []respUser{} + users, status, err := app.jf.GetUsers(false) + if !(status == 200 || status == 204) || err != nil { + app.err.Printf("Failed to get users from Jellyfin: Code %d", status) + app.debug.Printf("Error: %s", err) + respond(500, "Couldn't get users", gc) + return + } + for _, jfUser := range users { + var user respUser + user.LastActive = "n/a" + if jfUser["LastActivityDate"] != nil { + date := parseDT(jfUser["LastActivityDate"].(string)) + user.LastActive = app.formatDatetime(date) + // fmt.Printf("%s: %s, %s, %+v\n", jfUser["Name"].(string), jfUser["LastActivityDate"].(string), user.LastActive, date) + } + user.ID = jfUser["Id"].(string) + user.Name = jfUser["Name"].(string) + user.Admin = jfUser["Policy"].(map[string]interface{})["IsAdministrator"].(bool) + if email, ok := app.storage.emails[jfUser["Id"].(string)]; ok { + user.Email = email.(string) + } + + resp.UserList = append(resp.UserList, user) + } + gc.JSON(200, resp) +} + +// @Summary Get a list of Ombi users. +// @Produce json +// @Success 200 {object} ombiUsersDTO +// @Failure 500 {object} stringResponse +// @Router /ombi/users [get] +// @Security Bearer +// @tags Ombi +func (app *appContext) OmbiUsers(gc *gin.Context) { + app.debug.Println("Ombi users requested") + users, status, err := app.ombi.GetUsers() + if err != nil || status != 200 { + app.err.Printf("Failed to get users from Ombi: Code %d", status) + app.debug.Printf("Error: %s", err) + respond(500, "Couldn't get users", gc) + return + } + userlist := make([]ombiUser, len(users)) + for i, data := range users { + userlist[i] = ombiUser{ + Name: data["userName"].(string), + ID: data["id"].(string), + } + } + gc.JSON(200, ombiUsersDTO{Users: userlist}) +} + +// @Summary Set new user defaults for Ombi accounts. +// @Produce json +// @Param ombiUser body ombiUser true "User to source settings from" +// @Success 200 {object} boolResponse +// @Failure 500 {object} stringResponse +// @Router /ombi/defaults [post] +// @Security Bearer +// @tags Ombi +func (app *appContext) SetOmbiDefaults(gc *gin.Context) { + var req ombiUser + gc.BindJSON(&req) + template, code, err := app.ombi.TemplateByID(req.ID) + if err != nil || code != 200 || len(template) == 0 { + app.err.Printf("Couldn't get user from Ombi: %d %s", code, err) + respond(500, "Couldn't get user", gc) + return + } + app.storage.ombi_template = template + app.storage.storeOmbiTemplate() + respondBool(200, true, gc) +} + +// @Summary Modify user's email addresses. +// @Produce json +// @Param modifyEmailsDTO body modifyEmailsDTO true "Map of userIDs to email addresses" +// @Success 200 {object} boolResponse +// @Failure 500 {object} stringResponse +// @Router /users/emails [post] +// @Security Bearer +// @tags Users +func (app *appContext) ModifyEmails(gc *gin.Context) { + var req modifyEmailsDTO + gc.BindJSON(&req) + app.debug.Println("Email modification requested") + users, status, err := app.jf.GetUsers(false) + if !(status == 200 || status == 204) || err != nil { + app.err.Printf("Failed to get users from Jellyfin: Code %d", status) + app.debug.Printf("Error: %s", err) + respond(500, "Couldn't get users", gc) + return + } + ombiEnabled := app.config.Section("ombi").Key("enabled").MustBool(false) + for _, jfUser := range users { + id := jfUser["Id"].(string) + if address, ok := req[id]; ok { + app.storage.emails[jfUser["Id"].(string)] = address + if ombiEnabled { + ombiUser, code, err := app.getOmbiUser(id) + if code == 200 && err == nil { + ombiUser["emailAddress"] = address + code, err = app.ombi.ModifyUser(ombiUser) + if code != 200 || err != nil { + app.err.Printf("%s: Failed to change ombi email address: %d %s", ombiUser["userName"].(string), code, err) + } + } + } + } + } + app.storage.storeEmails() + app.info.Println("Email list modified") + respondBool(200, true, gc) +} + +// @Summary Apply settings to a list of users, either from a profile or from another user. +// @Produce json +// @Param userSettingsDTO body userSettingsDTO true "Parameters for applying settings" +// @Success 200 {object} errorListDTO +// @Failure 500 {object} errorListDTO "Lists of errors that occurred while applying settings" +// @Router /users/settings [post] +// @Security Bearer +// @tags Profiles & Settings +func (app *appContext) ApplySettings(gc *gin.Context) { + app.info.Println("User settings change requested") + var req userSettingsDTO + gc.BindJSON(&req) + applyingFrom := "profile" + var policy, configuration, displayprefs map[string]interface{} + if req.From == "profile" { + app.storage.loadProfiles() + if _, ok := app.storage.profiles[req.Profile]; !ok || len(app.storage.profiles[req.Profile].Policy) == 0 { + app.err.Printf("Couldn't find profile \"%s\" or profile was empty", req.Profile) + respond(500, "Couldn't find profile", gc) + return + } + if req.Homescreen { + if len(app.storage.profiles[req.Profile].Configuration) == 0 || len(app.storage.profiles[req.Profile].Displayprefs) == 0 { + app.err.Printf("No homescreen saved in profile \"%s\"", req.Profile) + respond(500, "No homescreen template available", gc) + return + } + configuration = app.storage.profiles[req.Profile].Configuration + displayprefs = app.storage.profiles[req.Profile].Displayprefs + } + policy = app.storage.profiles[req.Profile].Policy + } else if req.From == "user" { + applyingFrom = "user" + user, status, err := app.jf.UserByID(req.ID, false) + if !(status == 200 || status == 204) || err != nil { + app.err.Printf("Failed to get user from Jellyfin: Code %d", status) + app.debug.Printf("Error: %s", err) + respond(500, "Couldn't get user", gc) + return + } + applyingFrom = "\"" + user["Name"].(string) + "\"" + policy = user["Policy"].(map[string]interface{}) + if req.Homescreen { + displayprefs, status, err = app.jf.GetDisplayPreferences(req.ID) + if !(status == 200 || status == 204) || err != nil { + app.err.Printf("Failed to get DisplayPrefs: Code %d", status) + app.debug.Printf("Error: %s", err) + respond(500, "Couldn't get displayprefs", gc) + return + } + configuration = user["Configuration"].(map[string]interface{}) + } + } + app.info.Printf("Applying settings to %d user(s) from %s", len(req.ApplyTo), applyingFrom) + errors := errorListDTO{ + "policy": map[string]string{}, + "homescreen": map[string]string{}, + } + for _, id := range req.ApplyTo { + status, err := app.jf.SetPolicy(id, policy) + if !(status == 200 || status == 204) || err != nil { + errors["policy"][id] = fmt.Sprintf("%d: %s", status, err) + } + if req.Homescreen { + status, err = app.jf.SetConfiguration(id, configuration) + errorString := "" + if !(status == 200 || status == 204) || err != nil { + errorString += fmt.Sprintf("Configuration %d: %s ", status, err) + } else { + status, err = app.jf.SetDisplayPreferences(id, displayprefs) + if !(status == 200 || status == 204) || err != nil { + errorString += fmt.Sprintf("Displayprefs %d: %s ", status, err) + } + } + if errorString != "" { + errors["homescreen"][id] = errorString + } + } + } + code := 200 + if len(errors["policy"]) == len(req.ApplyTo) || len(errors["homescreen"]) == len(req.ApplyTo) { + code = 500 + } + gc.JSON(code, errors) +} + +// @Summary Get jfa-go configuration. +// @Produce json +// @Success 200 {object} configDTO "Uses the same format as config-base.json" +// @Router /config [get] +// @Security Bearer +// @tags Configuration +func (app *appContext) GetConfig(gc *gin.Context) { + app.info.Println("Config requested") + resp := map[string]interface{}{} + langPath := filepath.Join(app.localPath, "lang", "form") + app.lang.langFiles, _ = ioutil.ReadDir(langPath) + app.lang.langOptions = make([]string, len(app.lang.langFiles)) + chosenLang := app.config.Section("ui").Key("language").MustString("en-us") + ".json" + for i, f := range app.lang.langFiles { + if f.Name() == chosenLang { + app.lang.chosenIndex = i + } + var langFile map[string]interface{} + file, _ := ioutil.ReadFile(filepath.Join(langPath, f.Name())) + json.Unmarshal(file, &langFile) + + if meta, ok := langFile["meta"]; ok { + app.lang.langOptions[i] = meta.(map[string]interface{})["name"].(string) + } + } + for section, settings := range app.configBase { + if section == "order" { + resp[section] = settings.([]interface{}) + } else { + resp[section] = make(map[string]interface{}) + for key, values := range settings.(map[string]interface{}) { + if key == "order" { + resp[section].(map[string]interface{})[key] = values.([]interface{}) + } else { + resp[section].(map[string]interface{})[key] = values.(map[string]interface{}) + if key != "meta" { + dataType := resp[section].(map[string]interface{})[key].(map[string]interface{})["type"].(string) + configKey := app.config.Section(section).Key(key) + if dataType == "number" { + if val, err := configKey.Int(); err == nil { + resp[section].(map[string]interface{})[key].(map[string]interface{})["value"] = val + } + } else if dataType == "bool" { + resp[section].(map[string]interface{})[key].(map[string]interface{})["value"] = configKey.MustBool(false) + } else if dataType == "select" && key == "language" { + resp[section].(map[string]interface{})[key].(map[string]interface{})["options"] = app.lang.langOptions + resp[section].(map[string]interface{})[key].(map[string]interface{})["value"] = app.lang.langOptions[app.lang.chosenIndex] + } else { + resp[section].(map[string]interface{})[key].(map[string]interface{})["value"] = configKey.String() + } + } + } + } + } + } + // resp["jellyfin"].(map[string]interface{})["language"].(map[string]interface{})["options"].([]string) + gc.JSON(200, resp) +} + +// @Summary Modify app config. +// @Produce json +// @Param appConfig body configDTO true "Config split into sections as in config.ini, all values as strings." +// @Success 200 {object} boolResponse +// @Router /config [post] +// @Security Bearer +// @tags Configuration +func (app *appContext) ModifyConfig(gc *gin.Context) { + app.info.Println("Config modification requested") + var req configDTO + gc.BindJSON(&req) + tempConfig, _ := ini.Load(app.configPath) + for section, settings := range req { + if section != "restart-program" { + _, err := tempConfig.GetSection(section) + if err != nil { + tempConfig.NewSection(section) + } + for setting, value := range settings.(map[string]interface{}) { + if section == "ui" && setting == "language" { + for i, lang := range app.lang.langOptions { + if value.(string) == lang { + tempConfig.Section(section).Key(setting).SetValue(strings.Replace(app.lang.langFiles[i].Name(), ".json", "", 1)) + break + } + } + } else { + tempConfig.Section(section).Key(setting).SetValue(value.(string)) + } + } + } + } + tempConfig.SaveTo(app.configPath) + app.debug.Println("Config saved") + gc.JSON(200, map[string]bool{"success": true}) + if req["restart-program"] != nil && req["restart-program"].(bool) { + app.info.Println("Restarting...") + err := app.Restart() + if err != nil { + app.err.Printf("Couldn't restart, try restarting manually. (%s)", err) + } + } + app.loadConfig() + // Reinitialize password validator on config change, as opposed to every applicable request like in python. + if _, ok := req["password_validation"]; ok { + app.debug.Println("Reinitializing validator") + validatorConf := ValidatorConf{ + "characters": app.config.Section("password_validation").Key("min_length").MustInt(0), + "uppercase characters": app.config.Section("password_validation").Key("upper").MustInt(0), + "lowercase characters": app.config.Section("password_validation").Key("lower").MustInt(0), + "numbers": app.config.Section("password_validation").Key("number").MustInt(0), + "special characters": app.config.Section("password_validation").Key("special").MustInt(0), + } + if !app.config.Section("password_validation").Key("enabled").MustBool(false) { + for key := range validatorConf { + validatorConf[key] = 0 + } + } + app.validator.init(validatorConf) + } +} + +// @Summary Logout by deleting refresh token from cookies. +// @Produce json +// @Success 200 {object} boolResponse +// @Failure 500 {object} stringResponse +// @Router /logout [post] +// @tags Other +func (app *appContext) Logout(gc *gin.Context) { + cookie, err := gc.Cookie("refresh") + if err != nil { + app.debug.Printf("Couldn't get cookies: %s", err) + respond(500, "Couldn't fetch cookies", gc) + return + } + app.invalidTokens = append(app.invalidTokens, cookie) + gc.SetCookie("refresh", "invalid", -1, "/", gc.Request.URL.Hostname(), true, true) + respondBool(200, true, gc) +} + +// func Restart() error { +// defer func() { +// if r := recover(); r != nil { +// os.Exit(0) +// } +// }() +// cwd, err := os.Getwd() +// if err != nil { +// return err +// } +// args := os.Args +// // for _, key := range args { +// // fmt.Println(key) +// // } +// cmd := exec.Command(args[0], args[1:]...) +// cmd.Stdout = os.Stdout +// cmd.Stderr = os.Stderr +// cmd.Dir = cwd +// err = cmd.Start() +// if err != nil { +// return err +// } +// // cmd.Process.Release() +// panic(fmt.Errorf("restarting")) +// } + +// func (app *appContext) Restart() error { +// defer func() { +// if r := recover(); r != nil { +// signal.Notify(app.quit, os.Interrupt) +// <-app.quit +// } +// }() +// args := os.Args +// // After a single restart, args[0] gets messed up and isnt the real executable. +// // JFA_DEEP tells the new process its a child, and JFA_EXEC is the real executable +// if os.Getenv("JFA_DEEP") == "" { +// os.Setenv("JFA_DEEP", "1") +// os.Setenv("JFA_EXEC", args[0]) +// } +// env := os.Environ() +// err := syscall.Exec(os.Getenv("JFA_EXEC"), []string{""}, env) +// if err != nil { +// return err +// } +// panic(fmt.Errorf("restarting")) +// } + +// no need to syscall.exec anymore! +func (app *appContext) Restart() error { + RESTART <- true + return nil +} diff --git a/auth.go b/auth.go new file mode 100644 index 0000000..fc927c4 --- /dev/null +++ b/auth.go @@ -0,0 +1,228 @@ +package main + +import ( + "encoding/base64" + "fmt" + "os" + "strconv" + "strings" + "time" + + "github.com/dgrijalva/jwt-go" + "github.com/gin-gonic/gin" + "github.com/lithammer/shortuuid/v3" +) + +func (app *appContext) webAuth() gin.HandlerFunc { + return app.authenticate +} + +// CreateToken returns a web token as well as a refresh token, which can be used to obtain new tokens. +func CreateToken(userId, jfId string) (string, string, error) { + var token, refresh string + claims := jwt.MapClaims{ + "valid": true, + "id": userId, + "exp": strconv.FormatInt(time.Now().Add(time.Minute*20).Unix(), 10), + "jfid": jfId, + "type": "bearer", + } + + tk := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) + token, err := tk.SignedString([]byte(os.Getenv("JFA_SECRET"))) + if err != nil { + return "", "", err + } + claims["exp"] = strconv.FormatInt(time.Now().Add(time.Hour*24).Unix(), 10) + claims["type"] = "refresh" + tk = jwt.NewWithClaims(jwt.SigningMethodHS256, claims) + refresh, err = tk.SignedString([]byte(os.Getenv("JFA_SECRET"))) + if err != nil { + return "", "", err + } + return token, refresh, nil +} + +// Check header for token +func (app *appContext) authenticate(gc *gin.Context) { + header := strings.SplitN(gc.Request.Header.Get("Authorization"), " ", 2) + if header[0] != "Bearer" { + app.debug.Println("Invalid authorization header") + respond(401, "Unauthorized", gc) + return + } + token, err := jwt.Parse(string(header[1]), checkToken) + if err != nil { + app.debug.Printf("Auth denied: %s", err) + respond(401, "Unauthorized", gc) + return + } + claims, ok := token.Claims.(jwt.MapClaims) + expiryUnix, err := strconv.ParseInt(claims["exp"].(string), 10, 64) + if err != nil { + app.debug.Printf("Auth denied: %s", err) + respond(401, "Unauthorized", gc) + return + } + expiry := time.Unix(expiryUnix, 0) + if !(ok && token.Valid && claims["type"].(string) == "bearer" && expiry.After(time.Now())) { + app.debug.Printf("Auth denied: Invalid token") + respond(401, "Unauthorized", gc) + return + } + userID := claims["id"].(string) + jfID := claims["jfid"].(string) + match := false + for _, user := range app.users { + if user.UserID == userID { + match = true + break + } + } + if !match { + app.debug.Printf("Couldn't find user ID \"%s\"", userID) + respond(401, "Unauthorized", gc) + return + } + gc.Set("jfId", jfID) + gc.Set("userId", userID) + app.debug.Println("Auth succeeded") + gc.Next() +} + +func checkToken(token *jwt.Token) (interface{}, error) { + if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { + return nil, fmt.Errorf("Unexpected signing method %v", token.Header["alg"]) + } + return []byte(os.Getenv("JFA_SECRET")), nil +} + +type getTokenDTO struct { + Token string `json:"token" example:"kjsdklsfdkljfsjsdfklsdfkldsfjdfskjsdfjklsdf"` // API token for use with everything else. +} + +// @Summary Grabs an API token using username & password. +// @description Click the lock icon next to this, login with your normal jfa-go credentials. Click 'try it out', then 'execute' and an API Key will be returned, copy it (not including quotes). On any of the other routes, click the lock icon and set the API key as "Bearer `your api key`". +// @Produce json +// @Success 200 {object} getTokenDTO +// @Failure 401 {object} stringResponse +// @Router /token/login [get] +// @tags Auth +// @Security getTokenAuth +func (app *appContext) getTokenLogin(gc *gin.Context) { + app.info.Println("Token requested (login attempt)") + header := strings.SplitN(gc.Request.Header.Get("Authorization"), " ", 2) + auth, _ := base64.StdEncoding.DecodeString(header[1]) + creds := strings.SplitN(string(auth), ":", 2) + var userID, jfID string + if creds[0] == "" || creds[1] == "" { + app.debug.Println("Auth denied: blank username/password") + respond(401, "Unauthorized", gc) + return + } + match := false + for _, user := range app.users { + if user.Username == creds[0] && user.Password == creds[1] { + match = true + app.debug.Println("Found existing user") + userID = user.UserID + break + } + } + if !app.jellyfinLogin && !match { + app.info.Println("Auth denied: Invalid username/password") + respond(401, "Unauthorized", gc) + return + } + if !match { + var status int + var err error + var user map[string]interface{} + user, status, err = app.authJf.Authenticate(creds[0], creds[1]) + if status != 200 || err != nil { + if status == 401 || status == 400 { + app.info.Println("Auth denied: Invalid username/password (Jellyfin)") + respond(401, "Unauthorized", gc) + return + } + app.err.Printf("Auth failed: Couldn't authenticate with Jellyfin (%d/%s)", status, err) + respond(500, "Jellyfin error", gc) + return + } + jfID = user["Id"].(string) + if app.config.Section("ui").Key("admin_only").MustBool(true) { + if !user["Policy"].(map[string]interface{})["IsAdministrator"].(bool) { + app.debug.Printf("Auth denied: Users \"%s\" isn't admin", creds[0]) + respond(401, "Unauthorized", gc) + return + } + } + // New users are only added when using jellyfinLogin. + userID = shortuuid.New() + newUser := User{ + UserID: userID, + } + app.debug.Printf("Token generated for user \"%s\"", creds[0]) + app.users = append(app.users, newUser) + } + token, refresh, err := CreateToken(userID, jfID) + if err != nil { + app.err.Printf("getToken failed: Couldn't generate token (%s)", err) + respond(500, "Couldn't generate token", gc) + return + } + gc.SetCookie("refresh", refresh, (3600 * 24), "/", gc.Request.URL.Hostname(), true, true) + gc.JSON(200, getTokenDTO{token}) +} + +// @Summary Grabs an API token using a refresh token from cookies. +// @Produce json +// @Success 200 {object} getTokenDTO +// @Failure 401 {object} stringResponse +// @Router /token/refresh [get] +// @tags Auth +func (app *appContext) getTokenRefresh(gc *gin.Context) { + app.debug.Println("Token requested (refresh token)") + cookie, err := gc.Cookie("refresh") + if err != nil || cookie == "" { + app.debug.Printf("getTokenRefresh denied: Couldn't get token: %s", err) + respond(400, "Couldn't get token", gc) + return + } + for _, token := range app.invalidTokens { + if cookie == token { + app.debug.Println("getTokenRefresh: Invalid token") + respond(401, "Invalid token", gc) + return + } + } + token, err := jwt.Parse(cookie, checkToken) + if err != nil { + app.debug.Println("getTokenRefresh: Invalid token") + respond(400, "Invalid token", gc) + return + } + claims, ok := token.Claims.(jwt.MapClaims) + expiryUnix, err := strconv.ParseInt(claims["exp"].(string), 10, 64) + if err != nil { + app.debug.Printf("getTokenRefresh: Invalid token expiry: %s", err) + respond(401, "Invalid token", gc) + return + } + expiry := time.Unix(expiryUnix, 0) + if !(ok && token.Valid && claims["type"].(string) == "refresh" && expiry.After(time.Now())) { + app.debug.Printf("getTokenRefresh: Invalid token: %s", err) + respond(401, "Invalid token", gc) + return + } + userID := claims["id"].(string) + jfID := claims["jfid"].(string) + jwt, refresh, err := CreateToken(userID, jfID) + if err != nil { + app.err.Printf("getTokenRefresh failed: Couldn't generate token (%s)", err) + respond(500, "Couldn't generate token", gc) + return + } + gc.SetCookie("refresh", refresh, (3600 * 24), "/", gc.Request.URL.Hostname(), true, true) + gc.JSON(200, getTokenDTO{jwt}) +} diff --git a/common/common.go b/common/common.go new file mode 100644 index 0000000..ed94ad1 --- /dev/null +++ b/common/common.go @@ -0,0 +1,23 @@ +package common + +import ( + "fmt" + "log" +) + +// TimeoutHandler recovers from an http timeout. +type TimeoutHandler func() + +// NewTimeoutHandler returns a new Timeout handler. +func NewTimeoutHandler(name, addr string, noFail bool) TimeoutHandler { + return func() { + if r := recover(); r != nil { + out := fmt.Sprintf("Failed to authenticate with %s @ %s: Timed out", name, addr) + if noFail { + log.Print(out) + } else { + log.Fatalf(out) + } + } + } +} diff --git a/common/go.mod b/common/go.mod new file mode 100644 index 0000000..ec0c50a --- /dev/null +++ b/common/go.mod @@ -0,0 +1,3 @@ +module github.com/hrfee/jfa-go/common + +go 1.15 diff --git a/config.go b/config.go new file mode 100644 index 0000000..71e1724 --- /dev/null +++ b/config.go @@ -0,0 +1,86 @@ +package main + +import ( + "fmt" + "path/filepath" + "strconv" + "strings" + + "gopkg.in/ini.v1" +) + +/*var DeCamel ini.NameMapper = func(raw string) string { + out := make([]rune, 0, len(raw)) + upper := 0 + for _, c := range raw { + if unicode.IsUpper(c) { + upper++ + } + if upper == 2 { + out = append(out, '_') + upper = 0 + } + out = append(out, unicode.ToLower(c)) + } + return string(out) +} + +func (app *appContext) loadDefaults() (err error) { + var cfb []byte + cfb, err = ioutil.ReadFile(app.configBase_path) + if err != nil { + return + } + json.Unmarshal(cfb, app.defaults) + return +}*/ + +func (app *appContext) loadConfig() error { + var err error + app.config, err = ini.Load(app.configPath) + if err != nil { + return err + } + + app.config.Section("jellyfin").Key("public_server").SetValue(app.config.Section("jellyfin").Key("public_server").MustString(app.config.Section("jellyfin").Key("server").String())) + + for _, key := range app.config.Section("files").Keys() { + // if key.MustString("") == "" && key.Name() != "custom_css" { + // key.SetValue(filepath.Join(app.data_path, (key.Name() + ".json"))) + // } + if key.Name() != "html_templates" { + key.SetValue(key.MustString(filepath.Join(app.dataPath, (key.Name() + ".json")))) + } + } + for _, key := range []string{"user_configuration", "user_displayprefs", "user_profiles", "ombi_template"} { + // if app.config.Section("files").Key(key).MustString("") == "" { + // key.SetValue(filepath.Join(app.data_path, (key.Name() + ".json"))) + // } + app.config.Section("files").Key(key).SetValue(app.config.Section("files").Key(key).MustString(filepath.Join(app.dataPath, (key + ".json")))) + } + app.URLBase = strings.TrimSuffix(app.config.Section("ui").Key("url_base").MustString(""), "/") + app.config.Section("email").Key("no_username").SetValue(strconv.FormatBool(app.config.Section("email").Key("no_username").MustBool(false))) + + app.config.Section("password_resets").Key("email_html").SetValue(app.config.Section("password_resets").Key("email_html").MustString(filepath.Join(app.localPath, "email.html"))) + app.config.Section("password_resets").Key("email_text").SetValue(app.config.Section("password_resets").Key("email_text").MustString(filepath.Join(app.localPath, "email.txt"))) + + app.config.Section("invite_emails").Key("email_html").SetValue(app.config.Section("invite_emails").Key("email_html").MustString(filepath.Join(app.localPath, "invite-email.html"))) + app.config.Section("invite_emails").Key("email_text").SetValue(app.config.Section("invite_emails").Key("email_text").MustString(filepath.Join(app.localPath, "invite-email.txt"))) + + app.config.Section("notifications").Key("expiry_html").SetValue(app.config.Section("notifications").Key("expiry_html").MustString(filepath.Join(app.localPath, "expired.html"))) + app.config.Section("notifications").Key("expiry_text").SetValue(app.config.Section("notifications").Key("expiry_text").MustString(filepath.Join(app.localPath, "expired.txt"))) + + app.config.Section("notifications").Key("created_html").SetValue(app.config.Section("notifications").Key("created_html").MustString(filepath.Join(app.localPath, "created.html"))) + app.config.Section("notifications").Key("created_text").SetValue(app.config.Section("notifications").Key("created_text").MustString(filepath.Join(app.localPath, "created.txt"))) + + app.config.Section("deletion").Key("email_html").SetValue(app.config.Section("deletion").Key("email_html").MustString(filepath.Join(app.localPath, "deleted.html"))) + app.config.Section("deletion").Key("email_text").SetValue(app.config.Section("deletion").Key("email_text").MustString(filepath.Join(app.localPath, "deleted.txt"))) + + app.config.Section("jellyfin").Key("version").SetValue(VERSION) + app.config.Section("jellyfin").Key("device").SetValue("jfa-go") + app.config.Section("jellyfin").Key("device_id").SetValue(fmt.Sprintf("jfa-go-%s-%s", VERSION, COMMIT)) + + app.email = NewEmailer(app) + + return nil +} diff --git a/config/README.md b/config/README.md new file mode 100644 index 0000000..db64f2b --- /dev/null +++ b/config/README.md @@ -0,0 +1,11 @@ +### fixconfig + +Python's `json` library retains the order of data in a JSON file, which meant settings sent to the web page would be in the right order. Go's `encoding/json` and maps do not retain order, so this script opens the json file, and for each section, adds an "order" list which tells the web page in which order to display settings. + +Specify the input and output files with `-i` and `-o` respectively. + +### jsontostruct + +Generates a go struct from `config-base.json`. I wrote this because i was annoyed with the `ini` library, but i've since realised mapping the ini values onto it is painful. + + diff --git a/config/config-base.json b/config/config-base.json new file mode 100644 index 0000000..21e95a2 --- /dev/null +++ b/config/config-base.json @@ -0,0 +1,668 @@ +{ + "jellyfin": { + "meta": { + "name": "Jellyfin", + "description": "Settings for connecting to Jellyfin" + }, + "username": { + "name": "Jellyfin Username", + "required": true, + "requires_restart": true, + "type": "text", + "value": "username", + "description": "It is recommended to create a limited admin account for this program." + }, + "password": { + "name": "Jellyfin Password", + "required": true, + "requires_restart": true, + "type": "password", + "value": "password" + }, + "server": { + "name": "Server address", + "required": true, + "requires_restart": true, + "type": "text", + "value": "http://jellyfin.local:8096", + "description": "Jellyfin server address. Can be public, or local for security purposes." + }, + "public_server": { + "name": "Public address", + "required": false, + "requires_restart": false, + "type": "text", + "value": "https://jellyf.in:443", + "description": "Publicly accessible Jellyfin address for invite form. Leave blank to reuse the above address." + }, + "client": { + "name": "Client Name", + "required": true, + "requires_restart": true, + "type": "text", + "value": "jfa-go", + "description": "The name of the client that will show up in the Jellyfin dashboard." + }, + "cache_timeout": { + "name": "User cache timeout (minutes)", + "required": false, + "requires_restart": true, + "type": "number", + "value": 30, + "description": "Timeout of user cache in minutes. Set to 0 to disable." + } + }, + "ui": { + "meta": { + "name": "General", + "description": "Settings related to the UI and program functionality." + }, + "language": { + "name": "Language", + "required": false, + "requires_restart": true, + "type": "select", + "options": [ + "en-us" + ], + "value": "en-US", + "description": "UI Language. Currently only implemented for account creation form. Submit a PR on github if you'd like to translate." + }, + "theme": { + "name": "Default Look", + "required": false, + "requires_restart": true, + "type": "select", + "options": [ + "Bootstrap (Light)", + "Jellyfin (Dark)", + "Custom CSS" + ], + "value": "Jellyfin (Dark)", + "description": "Default appearance for all users." + }, + "host": { + "name": "Address", + "required": true, + "requires_restart": true, + "type": "text", + "value": "0.0.0.0", + "description": "Set 0.0.0.0 to run on localhost" + }, + "port": { + "name": "Port", + "required": true, + "requires_restart": true, + "type": "number", + "value": 8056 + }, + "jellyfin_login": { + "name": "Use Jellyfin for authentication", + "required": false, + "requires_restart": true, + "type": "bool", + "value": true, + "description": "Enable this to use Jellyfin users instead of the below username and pw." + }, + "admin_only": { + "name": "Allow admin users only", + "required": false, + "requires_restart": true, + "depends_true": "jellyfin_login", + "type": "bool", + "value": true, + "description": "Allows only admin users on Jellyfin to access the admin page." + }, + "username": { + "name": "Web Username", + "required": true, + "requires_restart": true, + "depends_false": "jellyfin_login", + "type": "text", + "value": "your username", + "description": "Username for admin page (Leave blank if using jellyfin_login)" + }, + "password": { + "name": "Web Password", + "required": true, + "requires_restart": true, + "depends_false": "jellyfin_login", + "type": "password", + "value": "your password", + "description": "Password for admin page (Leave blank if using jellyfin_login)" + }, + "email": { + "name": "Admin email address", + "required": false, + "requires_restart": false, + "depends_false": "jellyfin_login", + "type": "text", + "value": "example@example.com", + "description": "Address to send notifications to (Leave blank if using jellyfin_login)" + }, + "debug": { + "name": "Debug logging", + "required": false, + "requires_restart": true, + "type": "bool", + "value": false, + "description": "Enables debug logging and exposes pprof as a route (Don't use in production!)" + }, + "contact_message": { + "name": "Contact message", + "required": false, + "requires_restart": false, + "type": "text", + "value": "Need help? contact me.", + "description": "Displayed at bottom of all pages except admin" + }, + "help_message": { + "name": "Help message", + "required": false, + "requires_restart": false, + "type": "text", + "value": "Enter your details to create an account.", + "description": "Displayed at top of invite form." + }, + "success_message": { + "name": "Success message", + "required": false, + "requires_restart": false, + "type": "text", + "value": "Your account has been created. Click below to continue to Jellyfin.", + "description": "Displayed when a user creates an account" + }, + "bs5": { + "name": "Use Bootstrap 5", + "required": false, + "requires_restart": true, + "type": "bool", + "value": false, + "description": "Use the Bootstrap 5 Alpha. Looks better and removes the need for jQuery, so the page should load faster." + }, + "url_base": { + "name": "URL Base", + "required": false, + "requires_restart": true, + "type": "text", + "value": "", + "description": "URL base for when running jfa-go with a reverse proxy in a subfolder." + } + }, + "password_validation": { + "meta": { + "name": "Password Validation", + "description": "Password validation (minimum length, etc.)" + }, + "enabled": { + "name": "Enabled", + "required": false, + "requires_restart": false, + "type": "bool", + "value": true + }, + "min_length": { + "name": "Minimum Length", + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "8" + }, + "upper": { + "name": "Minimum uppercase characters", + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "1" + }, + "lower": { + "name": "Minimum lowercase characters", + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "0" + }, + "number": { + "name": "Minimum number count", + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "1" + }, + "special": { + "name": "Minimum number of special characters", + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "0" + } + }, + "email": { + "meta": { + "name": "Email", + "description": "General email settings. Ignore if not using email features." + }, + "no_username": { + "name": "Use email addresses as username", + "required": false, + "requires_restart": false, + "depends_true": "method", + "type": "bool", + "value": false, + "description": "Use email address from invite form as username on Jellyfin." + }, + "use_24h": { + "name": "Use 24h time", + "required": false, + "requires_restart": false, + "depends_true": "method", + "type": "bool", + "value": true + }, + "date_format": { + "name": "Date format", + "required": false, + "requires_restart": false, + "depends_true": "method", + "type": "text", + "value": "%d/%m/%y", + "description": "Date format used in emails. Follows datetime.strftime format." + }, + "message": { + "name": "Help message", + "required": false, + "requires_restart": false, + "depends_true": "method", + "type": "text", + "value": "Need help? contact me.", + "description": "Message displayed at bottom of emails." + }, + "method": { + "name": "Email method", + "required": false, + "requires_restart": false, + "type": "select", + "options": [ + "smtp", + "mailgun" + ], + "value": "smtp", + "description": "Method of sending email to use." + }, + "address": { + "name": "Sent from (address)", + "required": false, + "requires_restart": false, + "depends_true": "method", + "type": "email", + "value": "jellyfin@jellyf.in", + "description": "Address to send emails from" + }, + "from": { + "name": "Sent from (name)", + "required": false, + "requires_restart": false, + "depends_true": "method", + "type": "text", + "value": "Jellyfin", + "description": "The name of the sender" + } + }, + "password_resets": { + "meta": { + "name": "Password Resets", + "description": "Settings for the password reset handler." + }, + "enabled": { + "name": "Enabled", + "required": false, + "requires_restart": true, + "type": "bool", + "value": true, + "description": "Enable to store provided email addresses, monitor Jellyfin directory for pw-resets, and send reset pins" + }, + "watch_directory": { + "name": "Jellyfin directory", + "required": false, + "requires_restart": true, + "depends_true": "enabled", + "type": "text", + "value": "/path/to/jellyfin", + "description": "Path to the folder Jellyfin puts password-reset files." + }, + "email_html": { + "name": "Custom email (HTML)", + "required": false, + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "", + "description": "Path to custom email html" + }, + "email_text": { + "name": "Custom email (plaintext)", + "required": false, + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "", + "description": "Path to custom email in plain text" + }, + "subject": { + "name": "Email subject", + "required": false, + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "Password Reset - Jellyfin", + "description": "Subject of password reset emails." + } + }, + "invite_emails": { + "meta": { + "name": "Invite emails", + "description": "Settings for sending invites directly to users." + }, + "enabled": { + "name": "Enabled", + "required": false, + "requires_restart": false, + "type": "bool", + "value": true + }, + "email_html": { + "name": "Custom email (HTML)", + "required": false, + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "", + "description": "Path to custom email HTML" + }, + "email_text": { + "name": "Custom email (plaintext)", + "required": false, + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "", + "description": "Path to custom email in plain text" + }, + "subject": { + "name": "Email subject", + "required": true, + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "Invite - Jellyfin", + "description": "Subject of invite emails." + }, + "url_base": { + "name": "URL Base", + "required": true, + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "http://accounts.jellyf.in:8056/invite", + "description": "Base URL for jfa-go. This is necessary because using a reverse proxy means the program has no way of knowing the URL itself." + } + }, + "notifications": { + "meta": { + "name": "Notifications", + "description": "Notification related settings." + }, + "enabled": { + "name": "Enabled", + "required": "false", + "requires_restart": true, + "type": "bool", + "value": true, + "description": "Enabling adds optional toggles to invites to notify on expiry and user creation." + }, + "expiry_html": { + "name": "Expiry email (HTML)", + "required": false, + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "", + "description": "Path to expiry notification email HTML." + }, + "expiry_text": { + "name": "Expiry email (Plaintext)", + "required": false, + "requires_restart": "false", + "depends_true": "enabled", + "type": "text", + "value": "", + "description": "Path to expiry notification email in plaintext." + }, + "created_html": { + "name": "User created email (HTML)", + "required": false, + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "", + "description": "Path to user creation notification email HTML." + }, + "created_text": { + "name": "User created email (Plaintext)", + "required": false, + "requires_restart": false, + "depends_true": "enabled", + "type": "text", + "value": "", + "description": "Path to user creation notification email in plaintext." + } + }, + "mailgun": { + "meta": { + "name": "Mailgun (Email)", + "description": "Mailgun API connection settings" + }, + "api_url": { + "name": "API URL", + "required": false, + "requires_restart": false, + "type": "text", + "value": "https://api.mailgun.net..." + }, + "api_key": { + "name": "API Key", + "required": false, + "requires_restart": false, + "type": "text", + "value": "your api key" + } + }, + "smtp": { + "meta": { + "name": "SMTP (Email)", + "description": "SMTP Server connection settings." + }, + "username": { + "name": "Username", + "required": false, + "requires_restart": false, + "type": "text", + "value": "", + "description": "Username for SMTP. Leave blank to user send from address as username." + }, + "encryption": { + "name": "Encryption Method", + "required": false, + "requires_restart": false, + "type": "select", + "options": [ + "ssl_tls", + "starttls" + ], + "value": "starttls", + "description": "Your email provider should provide different ports for each encryption method. Generally 465 for ssl_tls, 587 for starttls." + }, + "server": { + "name": "Server address", + "required": false, + "requires_restart": false, + "type": "text", + "value": "smtp.jellyf.in", + "description": "SMTP Server address." + }, + "port": { + "name": "Port", + "required": false, + "requires_restart": false, + "type": "number", + "value": 465 + }, + "password": { + "name": "Password", + "required": false, + "requires_restart": false, + "type": "password", + "value": "smtp password" + } + }, + "ombi": { + "meta": { + "name": "Ombi Integration", + "description": "Connect to Ombi to automatically create both Ombi and Jellyfin accounts for new users. You'll need to create a user template for this to work. Once enabled, refresh to see an option in settings for this." + }, + "enabled": { + "name": "Enabled", + "required": false, + "requires_restart": true, + "type": "bool", + "value": false, + "description": "Enable to create an Ombi account for new Jellyfin users" + }, + "server": { + "name": "URL", + "required": false, + "requires_restart": true, + "type": "text", + "value": "localhost:5000", + "depends_true": "enabled", + "description": "Ombi server URL, including http(s)://." + }, + "api_key": { + "name": "API Key", + "required": false, + "requires_restart": true, + "type": "text", + "value": "", + "depends_true": "enabled", + "description": "API Key. Get this from the first tab in Ombi settings." + } + }, + "deletion": { + "meta": { + "name": "Account Deletion", + "description": "Subject/email files for account deletion emails." + }, + "subject": { + "name": "Email subject", + "required": false, + "requires_restart": false, + "type": "text", + "value": "Your account was deleted - Jellyfin", + "description": "Subject of account deletion emails." + }, + "email_html": { + "name": "Custom email (HTML)", + "required": false, + "requires_restart": false, + "type": "text", + "value": "", + "description": "Path to custom email html" + }, + "email_text": { + "name": "Custom email (plaintext)", + "required": false, + "requires_restart": false, + "type": "text", + "value": "", + "description": "Path to custom email in plain text" + } + }, + "files": { + "meta": { + "name": "File Storage", + "description": "Optional settings for changing storage locations." + }, + "invites": { + "name": "Invite Storage", + "required": false, + "requires_restart": true, + "type": "text", + "value": "", + "description": "Location of stored invites (json)." + }, + "emails": { + "name": "Email Addresses", + "required": false, + "requires_restart": true, + "type": "text", + "value": "", + "description": "Location of stored email addresses (json)." + }, + "ombi_template": { + "name": "Ombi user template", + "required": false, + "requires_restart": false, + "type": "text", + "value": "", + "description": "Location of stored Ombi user template." + }, + "user_template": { + "name": "User Template (Deprecated)", + "required": false, + "requires_restart": true, + "type": "text", + "value": "", + "description": "Deprecated in favor of User Profiles. Location of stored user policy template (json)." + }, + "user_configuration": { + "name": "userConfiguration (Deprecated)", + "required": false, + "requires_restart": true, + "type": "text", + "value": "", + "description": "Deprecated in favor of User Profiles. Location of stored user configuration template (used for setting homescreen layout) (json)" + }, + "user_displayprefs": { + "name": "displayPreferences (Deprecated)", + "required": false, + "requires_restart": true, + "type": "text", + "value": "", + "description": "Deprecated in favor of User Profiles. Location of stored displayPreferences template (also used for homescreen layout) (json)" + }, + "user_profiles": { + "name": "User Profiles", + "required": false, + "requires_restart": true, + "type": "text", + "value": "", + "description": "Location of stored user profiles (encompasses template and configuration and displayprefs) (json)" + }, + "custom_css": { + "name": "Custom CSS", + "required": false, + "requires_restart": true, + "type": "text", + "value": "", + "description": "Location of custom bootstrap CSS." + }, + "html_templates": { + "name": "Custom HTML Template Directory", + "required": false, + "requires_restart": true, + "type": "text", + "value": "", + "description": "Path to directory containing custom versions of web ui pages. See wiki for more info." + } + } +} diff --git a/config/configStruct.go b/config/configStruct.go new file mode 100644 index 0000000..a58b2d9 --- /dev/null +++ b/config/configStruct.go @@ -0,0 +1,541 @@ +package main + +type Metadata struct{ + Name string `json:"name"` + Description string `json:"description"` +} + +type Config struct{ + Order []string `json:"order"` + Jellyfin struct{ + Order []string `json:"order"` + Meta Metadata `json:"meta"` + Username struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"username"` + } `json:"username" cfg:"username"` + Password struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"password"` + } `json:"password" cfg:"password"` + Server struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"server"` + } `json:"server" cfg:"server"` + PublicServer struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"public_server"` + } `json:"public_server" cfg:"public_server"` + Client struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"client"` + } `json:"client" cfg:"client"` + Version struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"version"` + } `json:"version" cfg:"version"` + Device struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"device"` + } `json:"device" cfg:"device"` + DeviceId struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"device_id"` + } `json:"device_id" cfg:"device_id"` + } `json:"jellyfin"` + Ui struct{ + Order []string `json:"order"` + Meta Metadata `json:"meta"` + Theme struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Options []string `json:"options"` + Value string `json:"value" cfg:"theme"` + } `json:"theme" cfg:"theme"` + Host struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"host"` + } `json:"host" cfg:"host"` + Port struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value int `json:"value" cfg:"port"` + } `json:"port" cfg:"port"` + JellyfinLogin struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value bool `json:"value" cfg:"jellyfin_login"` + } `json:"jellyfin_login" cfg:"jellyfin_login"` + AdminOnly struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value bool `json:"value" cfg:"admin_only"` + } `json:"admin_only" cfg:"admin_only"` + Username struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"username"` + } `json:"username" cfg:"username"` + Password struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"password"` + } `json:"password" cfg:"password"` + Email struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"email"` + } `json:"email" cfg:"email"` + Debug struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value bool `json:"value" cfg:"debug"` + } `json:"debug" cfg:"debug"` + ContactMessage struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"contact_message"` + } `json:"contact_message" cfg:"contact_message"` + HelpMessage struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"help_message"` + } `json:"help_message" cfg:"help_message"` + SuccessMessage struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"success_message"` + } `json:"success_message" cfg:"success_message"` + Bs5 struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value bool `json:"value" cfg:"bs5"` + } `json:"bs5" cfg:"bs5"` + } `json:"ui"` + PasswordValidation struct{ + Order []string `json:"order"` + Meta Metadata `json:"meta"` + Enabled struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value bool `json:"value" cfg:"enabled"` + } `json:"enabled" cfg:"enabled"` + MinLength struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"min_length"` + } `json:"min_length" cfg:"min_length"` + Upper struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"upper"` + } `json:"upper" cfg:"upper"` + Lower struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"lower"` + } `json:"lower" cfg:"lower"` + Number struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"number"` + } `json:"number" cfg:"number"` + Special struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"special"` + } `json:"special" cfg:"special"` + } `json:"password_validation"` + Email struct{ + Order []string `json:"order"` + Meta Metadata `json:"meta"` + NoUsername struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value bool `json:"value" cfg:"no_username"` + } `json:"no_username" cfg:"no_username"` + Use24H struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value bool `json:"value" cfg:"use_24h"` + } `json:"use_24h" cfg:"use_24h"` + DateFormat struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"date_format"` + } `json:"date_format" cfg:"date_format"` + Message struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"message"` + } `json:"message" cfg:"message"` + Method struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Options []string `json:"options"` + Value string `json:"value" cfg:"method"` + } `json:"method" cfg:"method"` + Address struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"address"` + } `json:"address" cfg:"address"` + From struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"from"` + } `json:"from" cfg:"from"` + } `json:"email"` + PasswordResets struct{ + Order []string `json:"order"` + Meta Metadata `json:"meta"` + Enabled struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value bool `json:"value" cfg:"enabled"` + } `json:"enabled" cfg:"enabled"` + WatchDirectory struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"watch_directory"` + } `json:"watch_directory" cfg:"watch_directory"` + EmailHtml struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"email_html"` + } `json:"email_html" cfg:"email_html"` + EmailText struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"email_text"` + } `json:"email_text" cfg:"email_text"` + Subject struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"subject"` + } `json:"subject" cfg:"subject"` + } `json:"password_resets"` + InviteEmails struct{ + Order []string `json:"order"` + Meta Metadata `json:"meta"` + Enabled struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value bool `json:"value" cfg:"enabled"` + } `json:"enabled" cfg:"enabled"` + EmailHtml struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"email_html"` + } `json:"email_html" cfg:"email_html"` + EmailText struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"email_text"` + } `json:"email_text" cfg:"email_text"` + Subject struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"subject"` + } `json:"subject" cfg:"subject"` + UrlBase struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"url_base"` + } `json:"url_base" cfg:"url_base"` + } `json:"invite_emails"` + Notifications struct{ + Order []string `json:"order"` + Meta Metadata `json:"meta"` + Enabled struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value bool `json:"value" cfg:"enabled"` + } `json:"enabled" cfg:"enabled"` + ExpiryHtml struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"expiry_html"` + } `json:"expiry_html" cfg:"expiry_html"` + ExpiryText struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"expiry_text"` + } `json:"expiry_text" cfg:"expiry_text"` + CreatedHtml struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"created_html"` + } `json:"created_html" cfg:"created_html"` + CreatedText struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"created_text"` + } `json:"created_text" cfg:"created_text"` + } `json:"notifications"` + Mailgun struct{ + Order []string `json:"order"` + Meta Metadata `json:"meta"` + ApiUrl struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"api_url"` + } `json:"api_url" cfg:"api_url"` + ApiKey struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"api_key"` + } `json:"api_key" cfg:"api_key"` + } `json:"mailgun"` + Smtp struct{ + Order []string `json:"order"` + Meta Metadata `json:"meta"` + Encryption struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Options []string `json:"options"` + Value string `json:"value" cfg:"encryption"` + } `json:"encryption" cfg:"encryption"` + Server struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"server"` + } `json:"server" cfg:"server"` + Port struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value int `json:"value" cfg:"port"` + } `json:"port" cfg:"port"` + Password struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"password"` + } `json:"password" cfg:"password"` + } `json:"smtp"` + Files struct{ + Order []string `json:"order"` + Meta Metadata `json:"meta"` + Invites struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"invites"` + } `json:"invites" cfg:"invites"` + Emails struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"emails"` + } `json:"emails" cfg:"emails"` + UserTemplate struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"user_template"` + } `json:"user_template" cfg:"user_template"` + UserConfiguration struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"user_configuration"` + } `json:"user_configuration" cfg:"user_configuration"` + UserDisplayprefs struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"user_displayprefs"` + } `json:"user_displayprefs" cfg:"user_displayprefs"` + CustomCss struct{ + Name string `json:"name"` + Required bool `json:"required"` + Restart bool `json:"requires_restart"` + Description string `json:"description"` + Type string `json:"type"` + Value string `json:"value" cfg:"custom_css"` + } `json:"custom_css" cfg:"custom_css"` + } `json:"files"` +} diff --git a/config/fixconfig.py b/config/fixconfig.py new file mode 100644 index 0000000..180f2e4 --- /dev/null +++ b/config/fixconfig.py @@ -0,0 +1,27 @@ +import json, argparse + +parser = argparse.ArgumentParser() +parser.add_argument("-i", "--input", help="input config base from jf-accounts") +parser.add_argument("-o", "--output", help="output config base for jfa-go") + +args = parser.parse_args() + +with open(args.input, 'r') as f: + config = json.load(f) + +newconfig = {"order": []} + +for sect in config: + newconfig["order"].append(sect) + newconfig[sect] = {} + newconfig[sect]["order"] = [] + newconfig[sect]["meta"] = config[sect]["meta"] + for setting in config[sect]: + if setting != "meta": + newconfig[sect]["order"].append(setting) + newconfig[sect][setting] = config[sect][setting] + +with open(args.output, 'w') as f: + f.write(json.dumps(newconfig, indent=4)) + + diff --git a/config/generate_ini.py b/config/generate_ini.py new file mode 100644 index 0000000..efc8c0a --- /dev/null +++ b/config/generate_ini.py @@ -0,0 +1,42 @@ +# Generates config file +import configparser +import json +import argparse +from pathlib import Path + + +def generate_ini(base_file, ini_file): + """ + Generates .ini file from config-base file. + """ + with open(Path(base_file), "r") as f: + config_base = json.load(f) + + ini = configparser.RawConfigParser(allow_no_value=True) + + for section in config_base: + ini.add_section(section) + for entry in config_base[section]: + if "description" in config_base[section][entry]: + ini.set(section, "; " + config_base[section][entry]["description"]) + if entry != "meta": + value = config_base[section][entry]["value"] + if isinstance(value, bool): + value = str(value).lower() + else: + value = str(value) + ini.set(section, entry, value) + + with open(Path(ini_file), "w") as config_file: + ini.write(config_file) + return True + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-i", "--input", help="input config base from jf-accounts") + parser.add_argument("-o", "--output", help="output ini") + + args = parser.parse_args() + + print(generate_ini(base_file=args.input, ini_file=args.output)) diff --git a/config/jsontostruct.py b/config/jsontostruct.py new file mode 100644 index 0000000..b99be2b --- /dev/null +++ b/config/jsontostruct.py @@ -0,0 +1,57 @@ +import json + +with open("config-formatted.json", "r") as f: + config = json.load(f) + +indent = 0 + + +def writeln(ln): + global indent + if "}" in ln and "{" not in ln: + indent -= 1 + s.write(("\t" * indent) + ln + "\n") + if "{" in ln and "}" not in ln: + indent += 1 + + +with open("configStruct.go", "w") as s: + writeln("package main") + writeln("") + writeln("type Metadata struct{") + writeln('Name string `json:"name"`') + writeln('Description string `json:"description"`') + writeln("}") + writeln("") + writeln("type Config struct{") + if "order" in config: + writeln('Order []string `json:"order"`') + for section in [x for x in config.keys() if x != "order"]: + title = "".join([x.title() for x in section.split("_")]) + writeln(title + " struct{") + if "order" in config[section]: + writeln('Order []string `json:"order"`') + if "meta" in config[section]: + writeln('Meta Metadata `json:"meta"`') + for setting in [ + x for x in config[section].keys() if x != "order" and x != "meta" + ]: + name = "".join([x.title() for x in setting.split("_")]) + writeln(name + " struct{") + writeln('Name string `json:"name"`') + writeln('Required bool `json:"required"`') + writeln('Restart bool `json:"requires_restart"`') + writeln('Description string `json:"description"`') + writeln('Type string `json:"type"`') + dt = config[section][setting]["type"] + if dt == "select": + dt = "string" + writeln('Options []string `json:"options"`') + elif dt == "number": + dt = "int" + elif dt != "bool": + dt = "string" + writeln(f'Value {dt} `json:"value" cfg:"{setting}"`') + writeln("} " + f'`json:"{setting}" cfg:"{setting}"`') + writeln("} " + f'`json:"{section}"`') + writeln("}") diff --git a/css/base.css b/css/base.css index 227b7e4..447b575 100644 --- a/css/base.css +++ b/css/base.css @@ -1,5 +1,5 @@ -@import "../node_modules/a17t/dist/a17t.css"; -@import "../node_modules/remixicon/fonts/remixicon.css"; +@import "a17t.css"; +@import "remixicon.css"; @import "modal.css"; @import "dark.css"; @import "tooltip.css"; diff --git a/daemon.go b/daemon.go new file mode 100644 index 0000000..51299dc --- /dev/null +++ b/daemon.go @@ -0,0 +1,50 @@ +package main + +import "time" + +// https://bbengfort.github.io/snippets/2016/06/26/background-work-goroutines-timer.html THANKS + +type repeater struct { + Stopped bool + ShutdownChannel chan string + Interval time.Duration + period time.Duration + app *appContext +} + +func newRepeater(interval time.Duration, app *appContext) *repeater { + return &repeater{ + Stopped: false, + ShutdownChannel: make(chan string), + Interval: interval, + period: interval, + app: app, + } +} + +func (rt *repeater) run() { + rt.app.info.Println("Invite daemon started") + for { + select { + case <-rt.ShutdownChannel: + rt.ShutdownChannel <- "Down" + return + case <-time.After(rt.period): + break + } + started := time.Now() + rt.app.storage.loadInvites() + rt.app.debug.Println("Daemon: Checking invites") + rt.app.checkInvites() + finished := time.Now() + duration := finished.Sub(started) + rt.period = rt.Interval - duration + } +} + +func (rt *repeater) shutdown() { + rt.Stopped = true + rt.ShutdownChannel <- "Down" + <-rt.ShutdownChannel + close(rt.ShutdownChannel) +} diff --git a/docs/go.mod b/docs/go.mod new file mode 100644 index 0000000..fd8b7c6 --- /dev/null +++ b/docs/go.mod @@ -0,0 +1,8 @@ +module github.com/hrfee/jfa-go/docs + +go 1.15 + +require ( + github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 + github.com/swaggo/swag v1.6.7 +) diff --git a/email.go b/email.go new file mode 100644 index 0000000..10bd6c0 --- /dev/null +++ b/email.go @@ -0,0 +1,317 @@ +package main + +import ( + "bytes" + "context" + "crypto/tls" + "fmt" + "html/template" + "net/smtp" + "strings" + "time" + + jEmail "github.com/jordan-wright/email" + "github.com/knz/strtime" + "github.com/mailgun/mailgun-go/v4" +) + +// implements email sending, right now via smtp or mailgun. +type emailClient interface { + send(address, fromName, fromAddr string, email *Email) error +} + +// Mailgun client implements emailClient. +type Mailgun struct { + client *mailgun.MailgunImpl +} + +func (mg *Mailgun) send(address, fromName, fromAddr string, email *Email) error { + message := mg.client.NewMessage( + fmt.Sprintf("%s <%s>", fromName, fromAddr), + email.subject, + email.text, + address, + ) + message.SetHtml(email.html) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) + defer cancel() + _, _, err := mg.client.Send(ctx, message) + return err +} + +// SMTP supports SSL/TLS and STARTTLS; implements emailClient. +type SMTP struct { + sslTLS bool + server string + port int + auth smtp.Auth +} + +func (sm *SMTP) send(address, fromName, fromAddr string, email *Email) error { + e := jEmail.NewEmail() + e.Subject = email.subject + e.From = fmt.Sprintf("%s <%s>", fromName, fromAddr) + e.To = []string{address} + e.Text = []byte(email.text) + e.HTML = []byte(email.html) + server := fmt.Sprintf("%s:%d", sm.server, sm.port) + tlsConfig := &tls.Config{ + InsecureSkipVerify: false, + ServerName: sm.server, + } + var err error + fmt.Println(server) + // err = e.Send(server, sm.auth) + if sm.sslTLS { + err = e.SendWithTLS(server, sm.auth, tlsConfig) + } else { + err = e.SendWithStartTLS(server, sm.auth, tlsConfig) + } + return err +} + +// Emailer contains the email sender, email content, and methods to construct message content. +type Emailer struct { + fromAddr, fromName string + sender emailClient +} + +// Email stores content. +type Email struct { + subject string + html, text string +} + +func (emailer *Emailer) formatExpiry(expiry time.Time, tzaware bool, datePattern, timePattern string) (d, t, expiresIn string) { + d, _ = strtime.Strftime(expiry, datePattern) + t, _ = strtime.Strftime(expiry, timePattern) + currentTime := time.Now() + if tzaware { + currentTime = currentTime.UTC() + } + _, _, days, hours, minutes, _ := timeDiff(expiry, currentTime) + if days != 0 { + expiresIn += fmt.Sprintf("%dd ", days) + } + if hours != 0 { + expiresIn += fmt.Sprintf("%dh ", hours) + } + if minutes != 0 { + expiresIn += fmt.Sprintf("%dm ", minutes) + } + expiresIn = strings.TrimSuffix(expiresIn, " ") + return +} + +// NewEmailer configures and returns a new emailer. +func NewEmailer(app *appContext) *Emailer { + emailer := &Emailer{ + fromAddr: app.config.Section("email").Key("address").String(), + fromName: app.config.Section("email").Key("from").String(), + } + method := app.config.Section("email").Key("method").String() + if method == "smtp" { + sslTls := false + if app.config.Section("smtp").Key("encryption").String() == "ssl_tls" { + sslTls = true + } + username := "" + if u := app.config.Section("smtp").Key("username").MustString(""); u != "" { + username = u + } else { + username = emailer.fromAddr + } + emailer.NewSMTP(app.config.Section("smtp").Key("server").String(), app.config.Section("smtp").Key("port").MustInt(465), username, app.config.Section("smtp").Key("password").String(), sslTls) + } else if method == "mailgun" { + emailer.NewMailgun(app.config.Section("mailgun").Key("api_url").String(), app.config.Section("mailgun").Key("api_key").String()) + } + return emailer +} + +// NewMailgun returns a Mailgun emailClient. +func (emailer *Emailer) NewMailgun(url, key string) { + sender := &Mailgun{ + client: mailgun.NewMailgun(strings.Split(emailer.fromAddr, "@")[1], key), + } + // Mailgun client takes the base url, so we need to trim off the end (e.g 'v3/messages' + if strings.Contains(url, "messages") { + url = url[0:strings.LastIndex(url, "/")] + url = url[0:strings.LastIndex(url, "/")] + } + sender.client.SetAPIBase(url) + emailer.sender = sender +} + +// NewSMTP returns an SMTP emailClient. +func (emailer *Emailer) NewSMTP(server string, port int, username, password string, sslTLS bool) { + emailer.sender = &SMTP{ + auth: smtp.PlainAuth("", username, password, server), + server: server, + port: port, + sslTLS: sslTLS, + } +} + +func (emailer *Emailer) constructInvite(code string, invite Invite, app *appContext) (*Email, error) { + email := &Email{ + subject: app.config.Section("invite_emails").Key("subject").String(), + } + expiry := invite.ValidTill + d, t, expiresIn := emailer.formatExpiry(expiry, false, app.datePattern, app.timePattern) + message := app.config.Section("email").Key("message").String() + inviteLink := app.config.Section("invite_emails").Key("url_base").String() + inviteLink = fmt.Sprintf("%s/%s", inviteLink, code) + + for _, key := range []string{"html", "text"} { + fpath := app.config.Section("invite_emails").Key("email_" + key).String() + tpl, err := template.ParseFiles(fpath) + if err != nil { + return nil, err + } + var tplData bytes.Buffer + err = tpl.Execute(&tplData, map[string]string{ + "expiry_date": d, + "expiry_time": t, + "expires_in": expiresIn, + "invite_link": inviteLink, + "message": message, + }) + if err != nil { + return nil, err + } + if key == "html" { + email.html = tplData.String() + } else { + email.text = tplData.String() + } + } + return email, nil +} + +func (emailer *Emailer) constructExpiry(code string, invite Invite, app *appContext) (*Email, error) { + email := &Email{ + subject: "Notice: Invite expired", + } + expiry := app.formatDatetime(invite.ValidTill) + for _, key := range []string{"html", "text"} { + fpath := app.config.Section("notifications").Key("expiry_" + key).String() + tpl, err := template.ParseFiles(fpath) + if err != nil { + return nil, err + } + var tplData bytes.Buffer + err = tpl.Execute(&tplData, map[string]string{ + "code": code, + "expiry": expiry, + }) + if err != nil { + return nil, err + } + if key == "html" { + email.html = tplData.String() + } else { + email.text = tplData.String() + } + } + return email, nil +} + +func (emailer *Emailer) constructCreated(code, username, address string, invite Invite, app *appContext) (*Email, error) { + email := &Email{ + subject: "Notice: User created", + } + created := app.formatDatetime(invite.Created) + var tplAddress string + if app.config.Section("email").Key("no_username").MustBool(false) { + tplAddress = "n/a" + } else { + tplAddress = address + } + for _, key := range []string{"html", "text"} { + fpath := app.config.Section("notifications").Key("created_" + key).String() + tpl, err := template.ParseFiles(fpath) + if err != nil { + return nil, err + } + var tplData bytes.Buffer + err = tpl.Execute(&tplData, map[string]string{ + "code": code, + "username": username, + "address": tplAddress, + "time": created, + }) + if err != nil { + return nil, err + } + if key == "html" { + email.html = tplData.String() + } else { + email.text = tplData.String() + } + } + return email, nil +} + +func (emailer *Emailer) constructReset(pwr PasswordReset, app *appContext) (*Email, error) { + email := &Email{ + subject: app.config.Section("password_resets").Key("subject").MustString("Password reset - Jellyfin"), + } + d, t, expiresIn := emailer.formatExpiry(pwr.Expiry, true, app.datePattern, app.timePattern) + message := app.config.Section("email").Key("message").String() + for _, key := range []string{"html", "text"} { + fpath := app.config.Section("password_resets").Key("email_" + key).String() + tpl, err := template.ParseFiles(fpath) + if err != nil { + return nil, err + } + var tplData bytes.Buffer + err = tpl.Execute(&tplData, map[string]string{ + "username": pwr.Username, + "expiry_date": d, + "expiry_time": t, + "expires_in": expiresIn, + "pin": pwr.Pin, + "message": message, + }) + if err != nil { + return nil, err + } + if key == "html" { + email.html = tplData.String() + } else { + email.text = tplData.String() + } + } + return email, nil +} + +func (emailer *Emailer) constructDeleted(reason string, app *appContext) (*Email, error) { + email := &Email{ + subject: app.config.Section("deletion").Key("subject").MustString("Your account was deleted - Jellyfin"), + } + for _, key := range []string{"html", "text"} { + fpath := app.config.Section("deletion").Key("email_" + key).String() + tpl, err := template.ParseFiles(fpath) + if err != nil { + return nil, err + } + var tplData bytes.Buffer + err = tpl.Execute(&tplData, map[string]string{ + "reason": reason, + }) + if err != nil { + return nil, err + } + if key == "html" { + email.html = tplData.String() + } else { + email.text = tplData.String() + } + } + return email, nil +} + +// calls the send method in the underlying emailClient. +func (emailer *Emailer) send(address string, email *Email) error { + return emailer.sender.send(address, emailer.fromName, emailer.fromAddr, email) +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..d9eae46 --- /dev/null +++ b/go.mod @@ -0,0 +1,54 @@ +module github.com/hrfee/jfa-go + +go 1.14 + +replace github.com/hrfee/jfa-go/docs => ./docs + +replace github.com/hrfee/jfa-go/jfapi => ./jfapi + +replace github.com/hrfee/jfa-go/common => ./common + +replace github.com/hrfee/jfa-go/ombi => ./ombi + +require ( + github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect + github.com/dgrijalva/jwt-go v3.2.0+incompatible + github.com/fsnotify/fsnotify v1.4.9 + github.com/gin-contrib/pprof v1.3.0 + github.com/gin-contrib/static v0.0.0-20200916080430-d45d9a37d28e + github.com/gin-gonic/gin v1.6.3 + github.com/go-chi/chi v4.1.2+incompatible // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-playground/validator/v10 v10.4.1 // indirect + github.com/gofrs/uuid v3.3.0+incompatible // indirect + github.com/golang/protobuf v1.4.3 + github.com/google/uuid v1.1.2 // indirect + github.com/hrfee/jfa-go/common v0.0.0-20201112212552-b6f3cd7c1f71 + github.com/hrfee/jfa-go/docs v0.0.0-20201112212552-b6f3cd7c1f71 + github.com/hrfee/jfa-go/jfapi v0.0.0-20201112212552-b6f3cd7c1f71 + github.com/hrfee/jfa-go/ombi v0.0.0-20201112212552-b6f3cd7c1f71 + github.com/jordan-wright/email v4.0.1-0.20200917010138-e1c00e156980+incompatible + github.com/json-iterator/go v1.1.10 // indirect + github.com/knz/strtime v0.0.0-20200924090105-187c67f2bf5e + github.com/lithammer/shortuuid/v3 v3.0.4 + github.com/logrusorgru/aurora/v3 v3.0.0 + github.com/mailgun/mailgun-go/v4 v4.3.0 + github.com/mailru/easyjson v0.7.6 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/pdrum/swagger-automation v0.0.0-20190629163613-c8c7c80ba858 + github.com/pkg/errors v0.9.1 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14 + github.com/swaggo/gin-swagger v1.3.0 + github.com/swaggo/swag v1.7.0 // indirect + github.com/ugorji/go v1.2.0 // indirect + github.com/urfave/cli/v2 v2.3.0 // indirect + golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9 // indirect + golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect + golang.org/x/sys v0.0.0-20201113233024-12cec1faf1ba // indirect + golang.org/x/text v0.3.4 // indirect + google.golang.org/protobuf v1.25.0 // indirect + gopkg.in/ini.v1 v1.62.0 + gopkg.in/yaml.v2 v2.3.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..421c4c0 --- /dev/null +++ b/go.sum @@ -0,0 +1,431 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= +github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= +github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v1.0.2 h1:KPldsxuKGsS2FPWsNeg9ZO18aCrGKujPoWXn2yo+KQM= +github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= +github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= +github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/gzip v0.0.1/go.mod h1:fGBJBCdt6qCZuCAOwWuFhBB4OOq9EFqlo5dEaFhhu5w= +github.com/gin-contrib/pprof v1.3.0 h1:G9eK6HnbkSqDZBYbzG4wrjCsA4e+cvYAHUZw6W+W9K0= +github.com/gin-contrib/pprof v1.3.0/go.mod h1:waMjT1H9b179t3CxuG1cV3DHpga6ybizwfBaM5OXaB0= +github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= +github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-contrib/static v0.0.0-20191128031702-f81c604d8ac2 h1:xLG16iua01X7Gzms9045s2Y2niNpvSY/Zb1oBwgNYZY= +github.com/gin-contrib/static v0.0.0-20191128031702-f81c604d8ac2/go.mod h1:VhW/Ch/3FhimwZb8Oj+qJmdMmoB8r7lmJ5auRjm50oQ= +github.com/gin-contrib/static v0.0.0-20200815103939-31fb0c56a3d1 h1:plQYoJeO9lI8Ag0xZy7dDF8FMwIOHsQylKjcclknvIc= +github.com/gin-contrib/static v0.0.0-20200815103939-31fb0c56a3d1/go.mod h1:VhW/Ch/3FhimwZb8Oj+qJmdMmoB8r7lmJ5auRjm50oQ= +github.com/gin-contrib/static v0.0.0-20200916080430-d45d9a37d28e h1:8bZpGwoPxkaivQPrAbWl+7zjjUcbFUnYp7yQcx2r2N0= +github.com/gin-contrib/static v0.0.0-20200916080430-d45d9a37d28e/go.mod h1:VhW/Ch/3FhimwZb8Oj+qJmdMmoB8r7lmJ5auRjm50oQ= +github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y= +github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= +github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do= +github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= +github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/go-chi/chi v4.0.0+incompatible h1:SiLLEDyAkqNnw+T/uDTf3aFB9T4FTrwMpuYrgaRcnW4= +github.com/go-chi/chi v4.0.0+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= +github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec= +github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= +github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= +github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= +github.com/go-openapi/jsonreference v0.19.3 h1:5cxNfTy0UVC3X8JL5ymxzyoUZmo8iZb+jeTWn7tUa8o= +github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= +github.com/go-openapi/jsonreference v0.19.4 h1:3Vw+rh13uq2JFNxgnMTGE1rnoieU9FmyE1gvnyylsYg= +github.com/go-openapi/jsonreference v0.19.4/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= +github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/spec v0.19.4 h1:ixzUSnHTd6hCemgtAJgluaTSGYpLNpJY4mA2DIkdOAo= +github.com/go-openapi/spec v0.19.4/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= +github.com/go-openapi/spec v0.19.9 h1:9z9cbFuZJ7AcvOHKIY+f6Aevb4vObNDkTEyoMfO7rAc= +github.com/go-openapi/spec v0.19.9/go.mod h1:vqK/dIdLGCosfvYsQV3WfC7N3TiZSnGY2RZKoFK7X28= +github.com/go-openapi/spec v0.19.10 h1:pcNevfYytLaOQuTju0wm6OqcqU/E/pRwuSGigrLTI28= +github.com/go-openapi/spec v0.19.10/go.mod h1:vqK/dIdLGCosfvYsQV3WfC7N3TiZSnGY2RZKoFK7X28= +github.com/go-openapi/spec v0.19.12 h1:OO9WrvhDwtiMY/Opr1j1iFZzirI3JW4/bxNFRcntAr4= +github.com/go-openapi/spec v0.19.12/go.mod h1:gwrgJS15eCUgjLpMjBJmbZezCsw88LmgeEip0M63doA= +github.com/go-openapi/spec v0.19.13 h1:AcZVcWsrfW7LqyHKVbTZYpFF7jQcMxmAsWrw2p/b9ew= +github.com/go-openapi/spec v0.19.13/go.mod h1:gwrgJS15eCUgjLpMjBJmbZezCsw88LmgeEip0M63doA= +github.com/go-openapi/spec v0.19.14 h1:r4fbYFo6N4ZelmSX8G6p+cv/hZRXzcuqQIADGT1iNKM= +github.com/go-openapi/spec v0.19.14/go.mod h1:gwrgJS15eCUgjLpMjBJmbZezCsw88LmgeEip0M63doA= +github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= +github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.9 h1:1IxuqvBUU3S2Bi4YC7tlP9SJF1gVpCvqN0T2Qof4azE= +github.com/go-openapi/swag v0.19.9/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= +github.com/go-openapi/swag v0.19.10 h1:A1SWXruroGP15P1sOiegIPbaKio+G9N5TwWTFaVPmAU= +github.com/go-openapi/swag v0.19.10/go.mod h1:Uc0gKkdR+ojzsEpjh39QChyu92vPgIr72POcgHMAgSY= +github.com/go-openapi/swag v0.19.11 h1:RFTu/dlFySpyVvJDfp/7674JY4SDglYWKztbiIGFpmc= +github.com/go-openapi/swag v0.19.11/go.mod h1:Uc0gKkdR+ojzsEpjh39QChyu92vPgIr72POcgHMAgSY= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= +github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/go-playground/validator/v10 v10.3.0 h1:nZU+7q+yJoFmwvNgv/LnPUkwPal62+b2xXj0AU1Es7o= +github.com/go-playground/validator/v10 v10.3.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/go-playground/validator/v10 v10.4.0 h1:72qIR/m8ybvL8L5TIyfgrigqkrw7kVYAvjEvpT85l70= +github.com/go-playground/validator/v10 v10.4.0/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= +github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= +github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= +github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/jordan-wright/email v0.0.0-20200602115436-fd8a7622303e h1:OGunVjqY7y4U4laftpEHv+mvZBlr7UGimJXKEGQtg48= +github.com/jordan-wright/email v0.0.0-20200602115436-fd8a7622303e/go.mod h1:Fy2gCFfZhay8jplf/Csj6cyH/oshQTkLQYZbKkcV+SY= +github.com/jordan-wright/email v4.0.1-0.20200917010138-e1c00e156980+incompatible h1:CL0ooBNfbNyJTJATno+m0h+zM5bW6v7fKlboKUGP/dI= +github.com/jordan-wright/email v4.0.1-0.20200917010138-e1c00e156980+incompatible/go.mod h1:1c7szIrayyPPB/987hsnvNzLushdWf4o/79s3P08L8A= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/knz/strtime v0.0.0-20200318182718-be999391ffa9 h1:GQE1iatYDRrIidq4Zf/9ZzKWyrTk2sXOYc1JADbkAjQ= +github.com/knz/strtime v0.0.0-20200318182718-be999391ffa9/go.mod h1:4ZxfWkxwtc7dBeifERVVWRy9F9rTU9p0yCDgeCtlius= +github.com/knz/strtime v0.0.0-20200924090105-187c67f2bf5e h1:ViPE0JEOvtw5I0EGUiFSr2VNKGNU+3oBT+oHbDXHbxk= +github.com/knz/strtime v0.0.0-20200924090105-187c67f2bf5e/go.mod h1:4ZxfWkxwtc7dBeifERVVWRy9F9rTU9p0yCDgeCtlius= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= +github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= +github.com/labstack/gommon v0.2.9 h1:heVeuAYtevIQVYkGj6A41dtfT91LrvFG220lavpWhrU= +github.com/labstack/gommon v0.2.9/go.mod h1:E8ZTmW9vw5az5/ZyHWCp0Lw4OH2ecsaBP1C/NKavGG4= +github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/lithammer/shortuuid v1.0.0 h1:kdcbvjGVEgqeVeDIRtnANOi/F6ftbKrtbxY+cjQmK1Q= +github.com/lithammer/shortuuid v3.0.0+incompatible h1:NcD0xWW/MZYXEHa6ITy6kaXN5nwm/V115vj2YXfhS0w= +github.com/lithammer/shortuuid/v3 v3.0.4 h1:uj4xhotfY92Y1Oa6n6HUiFn87CdoEHYUlTy0+IgbLrs= +github.com/lithammer/shortuuid/v3 v3.0.4/go.mod h1:RviRjexKqIzx/7r1peoAITm6m7gnif/h+0zmolKJjzw= +github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= +github.com/logrusorgru/aurora/v3 v3.0.0 h1:R6zcoZZbvVcGMvDCKo45A9U/lzYyzl5NfYIvznmDfE4= +github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc= +github.com/mailgun/mailgun-go v1.1.1 h1:mjMcm4qz+SbjAYbGJ6DKROViKtO5S0YjpuOUxQfdr2A= +github.com/mailgun/mailgun-go v2.0.0+incompatible h1:0FoRHWwMUctnd8KIR3vtZbqdfjpIMxOZgcSa51s8F8o= +github.com/mailgun/mailgun-go/v4 v4.1.3 h1:KLa5EZaOMMeyvY/lfAhWxv9ealB3mtUsMz0O9XmTtP0= +github.com/mailgun/mailgun-go/v4 v4.1.3/go.mod h1:R9kHUQBptF4iSEjhriCQizplCDwrnDShy8w/iPiOfaM= +github.com/mailgun/mailgun-go/v4 v4.2.0 h1:AAt7TwR98Pog7zAYK61SW7ikykFFmCovtix3vvS2cK4= +github.com/mailgun/mailgun-go/v4 v4.2.0/go.mod h1:R9kHUQBptF4iSEjhriCQizplCDwrnDShy8w/iPiOfaM= +github.com/mailgun/mailgun-go/v4 v4.3.0 h1:9nAF7LI3k6bfDPbMZQMMl63Q8/vs+dr1FUN8eR1XMhk= +github.com/mailgun/mailgun-go/v4 v4.3.0/go.mod h1:fWuBI2iaS/pSSyo6+EBpHjatQO3lV8onwqcRy7joSJI= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM= +github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= +github.com/mailru/easyjson v0.7.2 h1:V9ecaZWDYm7v9uJ15RZD6DajMu5sE0hdep0aoDwT9g4= +github.com/mailru/easyjson v0.7.2/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.7.3 h1:M6wcO9gFHCIPynXGu4iA+NMs//FCgFUWR2jxqV3/+Xk= +github.com/mailru/easyjson v0.7.3/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/pdrum/swagger-automation v0.0.0-20190629163613-c8c7c80ba858 h1:lgbJiJQx8bXo+eM88AFdd0VxUvaTLzCBXpK+H9poJ+Y= +github.com/pdrum/swagger-automation v0.0.0-20190629163613-c8c7c80ba858/go.mod h1:y02HeaN0visd95W6cEX2NXDv5sCwyqfzucWTdDGEwYY= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14 h1:PyYN9JH5jY9j6av01SpfRMb+1DWg/i3MbGOKPxJ2wjM= +github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14/go.mod h1:gxQT6pBGRuIGunNf/+tSOB5OHvguWi8Tbt82WOkf35E= +github.com/swaggo/gin-swagger v1.2.0 h1:YskZXEiv51fjOMTsXrOetAjrMDfFaXD79PEoQBOe2W0= +github.com/swaggo/gin-swagger v1.2.0/go.mod h1:qlH2+W7zXGZkczuL+r2nEBR2JTT+/lX05Nn6vPhc7OI= +github.com/swaggo/gin-swagger v1.3.0 h1:eOmp7r57oUgZPw2dJOjcGNMse9cvXcI4tTqBcnZtPsI= +github.com/swaggo/gin-swagger v1.3.0/go.mod h1:oy1BRA6WvgtCp848lhxce7BnWH4C8Bxa0m5SkWx+cS0= +github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y= +github.com/swaggo/swag v1.6.7 h1:e8GC2xDllJZr3omJkm9YfmK0Y56+rMO3cg0JBKNz09s= +github.com/swaggo/swag v1.6.7/go.mod h1:xDhTyuFIujYiN3DKWC/H/83xcfHp+UE/IzWWampG7Zc= +github.com/swaggo/swag v1.6.8 h1:z3ZNcpJs/NLMpZcKqXUsBELmmY2Ocy09JXKx5gu3L4M= +github.com/swaggo/swag v1.6.8/go.mod h1:a0IpNeMfGidNOcm2TsqODUh9JHdHu3kxDA0UlGbBKjI= +github.com/swaggo/swag v1.6.9 h1:BukKRwZjnEcUxQt7Xgfrt9fpav0hiWw9YimdNO9wssw= +github.com/swaggo/swag v1.6.9/go.mod h1:a0IpNeMfGidNOcm2TsqODUh9JHdHu3kxDA0UlGbBKjI= +github.com/swaggo/swag v1.7.0 h1:5bCA/MTLQoIqDXXyHfOpMeDvL9j68OY/udlK4pQoo4E= +github.com/swaggo/swag v1.7.0/go.mod h1:BdPIL73gvS9NBsdi7M1JOxLvlbfvNRaBP8m6WT6Aajo= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/ugorji/go v1.1.5-pre/go.mod h1:FwP/aQVg39TXzItUBMwnWp9T9gPQnXw4Poh4/oBQZ/0= +github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go v1.1.9 h1:SObrQTaSuP8WOv2WNCj8gECiNSJIUvk3Q7N26c96Gws= +github.com/ugorji/go v1.1.9/go.mod h1:chLrngdsg43geAaeId+nXO57YsDdl5OZqd/QtBiD19g= +github.com/ugorji/go v1.1.13/go.mod h1:jxau1n+/wyTGLQoCkjok9r5zFa/FxT6eI5HiHKQszjc= +github.com/ugorji/go v1.2.0 h1:6eXlzYLLwZwXroJx9NyqbYcbv/d93twiOzQLDewE6qM= +github.com/ugorji/go v1.2.0/go.mod h1:1ny++pKMXhLWrwWV5Nf+CbOuZJhMoaFD+0GMFfd8fEc= +github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/ugorji/go/codec v1.1.5-pre/go.mod h1:tULtS6Gy1AE1yCENaw4Vb//HLH5njI2tfCQDUqRd8fI= +github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/ugorji/go/codec v1.1.9 h1:J/7hhpkQwgypRNvaeh/T5gzJ2gEI/l8S3qyRrdEa1fA= +github.com/ugorji/go/codec v1.1.9/go.mod h1:+SWgpdqOgdW5sBaiDfkHilQ1SxQ1hBkq/R+kHfL7Suo= +github.com/ugorji/go/codec v1.1.13/go.mod h1:oNVt3Dq+FO91WNQ/9JnHKQP2QJxTzoN7wCBFCq1OeuU= +github.com/ugorji/go/codec v1.2.0 h1:As6RccOIlbm9wHuWYMlB30dErcI+4WiKWsYsmPkyrUw= +github.com/ugorji/go/codec v1.2.0/go.mod h1:dXvG35r7zTX6QImXOSFhGMmKtX+wJ7VTWzGvYQGIjBs= +github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k= +github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= +github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4= +github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= +github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= +github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8= +github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9 h1:umElSU9WZirRdgu2yFHY0ayQkEnKiOC1TtM3fWXFnoU= +golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= +golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200923182212-328152dc79b1 h1:Iu68XRPd67wN4aRGGWwwq6bZo/25jR6uu52l/j2KkUE= +golang.org/x/net v0.0.0-20200923182212-328152dc79b1/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200927032502-5d4f70055728 h1:5wtQIAulKU5AbLQOkjxl32UufnIOqgBX72pS0AV14H0= +golang.org/x/net v0.0.0-20200927032502-5d4f70055728/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0 h1:wBouT66WTYFXdxfVdz9sVWARVd/2vfGcmI45D2gj45M= +golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201016165138-7b1cca2348c0 h1:5kGOVHlq0euqwzgTC9Vu15p6fV1Wi0ArVi8da2urnVg= +golang.org/x/net v0.0.0-20201016165138-7b1cca2348c0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102 h1:42cLlJJdEh+ySyeUUbEQ5bsTiq8voBeTuweGVkY6Puw= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1 h1:sIky/MyNRSHTrdxfsiUSS4WIAMvInbeXljJz+jDjeYE= +golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed h1:J22ig1FUekjjkmZUM7pTKixYm8DvrYsvrBZdunYeIuQ= +golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200929083018-4d22bbb62b3c h1:/h0vtH0PyU0xAoZJVcRw1k0Ng+U0JAy3QDiFmppIlIE= +golang.org/x/sys v0.0.0-20200929083018-4d22bbb62b3c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201113233024-12cec1faf1ba h1:xmhUJGQGbxlod18iJGqVEp9cHIPLl7QiX2aA3to708s= +golang.org/x/sys v0.0.0-20201113233024-12cec1faf1ba/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59 h1:QjA/9ArTfVTLfEhClDCG7SGrZkZixxWpwNCDiwJfh88= +golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200820010801-b793a1359eac/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200923182640-463111b69878 h1:VUw1+Jf6KJPf82mbTQMia6HCnNMv2BbAipkEZ4KTcqQ= +golang.org/x/tools v0.0.0-20200923182640-463111b69878/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20200924182824-0f1c53950d78 h1:3JUoxVhcskhsIDEc7vg0MUUEpmPPN5TfG+E97z/Fn90= +golang.org/x/tools v0.0.0-20200924182824-0f1c53950d78/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20200929191002-f1e51e6b9437 h1:XSFqH8m531iIGazX5lrUC9j3slbwsZ1GFByqdUrLqmI= +golang.org/x/tools v0.0.0-20200929191002-f1e51e6b9437/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20201008184944-d01b322e6f06 h1:w9ail9jFLaySAm61Zjhciu0LQ5i8YTy2pimlNLx4uuk= +golang.org/x/tools v0.0.0-20201008184944-d01b322e6f06/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20201017001424-6003fad69a88 h1:ZB1XYzdDo7c/O48jzjMkvIjnC120Z9/CwgDWhePjQdQ= +golang.org/x/tools v0.0.0-20201017001424-6003fad69a88/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9 h1:sEvmEcJVKBNUvgCUClbUQeHOAa9U0I2Ce1BooMvVCY4= +golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201103235415-b653051172e4 h1:Qe0EMgvVYb6tmJhJHljCj3gS96hvSTkGNaIzp/ivq10= +golang.org/x/tools v0.0.0-20201103235415-b653051172e4/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201113202037-1643af1435f3 h1:7R7+wzd5VuLvCNyHZ/MG511kkoP/DBEzkbh8qUsFbY8= +golang.org/x/tools v0.0.0-20201113202037-1643af1435f3/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201114224030-61ea331ec02b h1:Ych5r0Z6MLML1fgf5hTg9p5bV56Xqx9xv9hLgMBATWs= +golang.org/x/tools v0.0.0-20201114224030-61ea331ec02b/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201120155355-20be4ac4bd6e h1:t96dS3DO8DGjawSLJL/HIdz8CycAd2v07XxqB3UPTi0= +golang.org/x/tools v0.0.0-20201120155355-20be4ac4bd6e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= +gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= +gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= +gopkg.in/ini.v1 v1.57.0 h1:9unxIsFcTt4I55uWluz+UmL95q4kdJ0buvQ1ZIqVQww= +gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.60.0 h1:P5ZzC7RJO04094NJYlEnBdFK2wwmnCAy/+7sAzvWs60= +gopkg.in/ini.v1 v1.60.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.61.0 h1:LBCdW4FmFYL4s/vDZD1RQYX7oAR6IjujCYgMdbHBR10= +gopkg.in/ini.v1 v1.61.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= +gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/html/404.html b/html/404.html new file mode 100644 index 0000000..22593ad --- /dev/null +++ b/html/404.html @@ -0,0 +1,21 @@ + + +
+Version a17t-redesign
-Commit cb28097
+Version {{ .version }}
+Commit {{ .commit }}
Available under the MIT License.
diff --git a/html/form-base.html b/html/form-base.html new file mode 100644 index 0000000..d95a708 --- /dev/null +++ b/html/form-base.html @@ -0,0 +1,10 @@ +{{ define "form-base" }} + + + +{{ end }} diff --git a/html/form-loader.html b/html/form-loader.html new file mode 100644 index 0000000..6585322 --- /dev/null +++ b/html/form-loader.html @@ -0,0 +1 @@ +{{ template "form.html" . }} diff --git a/form.html b/html/form.html similarity index 84% rename from form.html rename to html/form.html index 8d0a0b5..d224b30 100644 --- a/form.html +++ b/html/form.html @@ -2,7 +2,8 @@ -A user was created using code {{ .code }}.
+Reason: {{ .reason }}
+Hi {{ .username }},
+Someone has recently requested a password reset on Jellyfin.
+If this was you, enter the below pin into the prompt.
+The code will expire on {{ .expiry_date }}, at {{ .expiry_time }} UTC, which is in {{ .expires_in }}.
+If this wasn't you, please ignore this email.
+