transport

package
v0.0.0-...-7f3aa20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2023 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolString

func BoolString(b *bool) string

BoolString is a little hack to make handling tri-state bool in go templates trivial

func GetClientId

func GetClientId(r *http.Request) (*types.ClientApplication, bool)

func InitApp

func InitApp(l *logrus.Entry, conf *config.Config, db *sql.DB, pgdb *pgxpool.Pool, authBotSession, notificationBotSession *discordgo.Session, rsu *resumableuploadservice.ResumableUploadService)

func NoCache

func NoCache(h http.Handler) http.Handler

func ScopeIsValid

func ScopeIsValid(routeScope string, tokenScope string) bool

Types

type App

type App struct {
	Conf    *config.Config
	CC      utils.CookieCutter
	Service *service.SiteService

	DFStorage         *DeviceFlowStorage
	AuthCodeStorage   *AuthCodeStorage
	AdminModePassword string
	// contains filtered or unexported fields
}

App is App

func (*App) AdminPassAuth

func (a *App) AdminPassAuth(next func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)

func (*App) GetSecretFromCookie

func (a *App) GetSecretFromCookie(ctx context.Context, r *http.Request) (string, error)

func (*App) GetServerUser

func (a *App) GetServerUser(w http.ResponseWriter, r *http.Request)

func (*App) GetUserIDFromCookie

func (a *App) GetUserIDFromCookie(r *http.Request) (int64, error)

func (*App) HandleApplyContentPatchPage

func (a *App) HandleApplyContentPatchPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleApproveDevice

func (a *App) HandleApproveDevice(w http.ResponseWriter, r *http.Request)

func (*App) HandleCommentReceiverBatch

func (a *App) HandleCommentReceiverBatch(w http.ResponseWriter, r *http.Request)

func (*App) HandleDeleteGame

func (a *App) HandleDeleteGame(w http.ResponseWriter, r *http.Request)

func (*App) HandleDeleteUserSessions

func (a *App) HandleDeleteUserSessions(w http.ResponseWriter, r *http.Request)

func (*App) HandleDeletedGames

func (a *App) HandleDeletedGames(w http.ResponseWriter, r *http.Request)

func (*App) HandleDeveloperDumpUpload

func (a *App) HandleDeveloperDumpUpload(w http.ResponseWriter, r *http.Request)

func (*App) HandleDeveloperPage

func (a *App) HandleDeveloperPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleDeveloperTagDescFromValidator

func (a *App) HandleDeveloperTagDescFromValidator(w http.ResponseWriter, r *http.Request)

func (*App) HandleDiscordAuth

func (a *App) HandleDiscordAuth(w http.ResponseWriter, r *http.Request)

func (*App) HandleDiscordCallback

func (a *App) HandleDiscordCallback(w http.ResponseWriter, r *http.Request)

func (*App) HandleDownloadCurationImage

func (a *App) HandleDownloadCurationImage(w http.ResponseWriter, r *http.Request)

func (*App) HandleDownloadFlashfreezeRootFile

func (a *App) HandleDownloadFlashfreezeRootFile(w http.ResponseWriter, r *http.Request)

func (*App) HandleDownloadSubmissionBatch

func (a *App) HandleDownloadSubmissionBatch(w http.ResponseWriter, r *http.Request)

func (*App) HandleDownloadSubmissionFile

func (a *App) HandleDownloadSubmissionFile(w http.ResponseWriter, r *http.Request)

func (*App) HandleFetchGames

func (a *App) HandleFetchGames(w http.ResponseWriter, r *http.Request)

func (*App) HandleFlashfreezeReceiverResumable

func (a *App) HandleFlashfreezeReceiverResumable(w http.ResponseWriter, r *http.Request)

func (*App) HandleFlashfreezeSubmitPage

func (a *App) HandleFlashfreezeSubmitPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleFreezeGame

func (a *App) HandleFreezeGame(w http.ResponseWriter, r *http.Request)

func (*App) HandleFreezeSubmission

func (a *App) HandleFreezeSubmission(w http.ResponseWriter, r *http.Request)

func (*App) HandleGameCountSinceDate

func (a *App) HandleGameCountSinceDate(w http.ResponseWriter, r *http.Request)

func (*App) HandleGameDataEditPage

func (a *App) HandleGameDataEditPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleGameDataIndexPage

func (a *App) HandleGameDataIndexPage(w http.ResponseWriter, r *http.Request)
func (a *App) HandleGameLogo(w http.ResponseWriter, r *http.Request)

func (*App) HandleGamePage

func (a *App) HandleGamePage(w http.ResponseWriter, r *http.Request)

func (*App) HandleGameScreenshot

func (a *App) HandleGameScreenshot(w http.ResponseWriter, r *http.Request)

func (*App) HandleGamesPage

func (a *App) HandleGamesPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleGetUploadProgress

func (a *App) HandleGetUploadProgress(w http.ResponseWriter, r *http.Request)

func (*App) HandleGetUserStatistics

func (a *App) HandleGetUserStatistics(w http.ResponseWriter, r *http.Request)

func (*App) HandleGetUsers

func (a *App) HandleGetUsers(w http.ResponseWriter, r *http.Request)

func (*App) HandleHelpPage

func (a *App) HandleHelpPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleIndexUnindexedFlashfreeze

func (a *App) HandleIndexUnindexedFlashfreeze(w http.ResponseWriter, r *http.Request)

func (*App) HandleIngestFlashfreeze

func (a *App) HandleIngestFlashfreeze(w http.ResponseWriter, r *http.Request)

func (*App) HandleIngestUnknownFlashfreeze

func (a *App) HandleIngestUnknownFlashfreeze(w http.ResponseWriter, r *http.Request)

HandleIngestUnknownFlashfreeze ingests flashfreeze files which are in the flashfreeze directory, but not in the database. This should not be needed and such files are a result of a bug or human error.

func (*App) HandleInternalPage

func (a *App) HandleInternalPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleLogout

func (a *App) HandleLogout(w http.ResponseWriter, r *http.Request)

func (*App) HandleMatchingIndexHash

func (a *App) HandleMatchingIndexHash(w http.ResponseWriter, r *http.Request)

func (*App) HandleMetadataStats

func (a *App) HandleMetadataStats(w http.ResponseWriter, r *http.Request)

func (*App) HandleMinLauncherVersion

func (a *App) HandleMinLauncherVersion(w http.ResponseWriter, r *http.Request)

func (*App) HandleMySubmissionsPage

func (a *App) HandleMySubmissionsPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleNukeSessionTable

func (a *App) HandleNukeSessionTable(w http.ResponseWriter, r *http.Request)

func (*App) HandleOauthAuthorize

func (a *App) HandleOauthAuthorize(w http.ResponseWriter, r *http.Request)

func (*App) HandleOauthDevice

func (a *App) HandleOauthDevice(w http.ResponseWriter, r *http.Request)

func (*App) HandleOauthDeviceResponse

func (a *App) HandleOauthDeviceResponse(w http.ResponseWriter, r *http.Request)

func (*App) HandleOauthToken

func (a *App) HandleOauthToken(w http.ResponseWriter, r *http.Request)

func (*App) HandleOverrideBot

func (a *App) HandleOverrideBot(w http.ResponseWriter, r *http.Request)

func (*App) HandleOwnedClientApplication

func (a *App) HandleOwnedClientApplication(w http.ResponseWriter, r *http.Request)

func (*App) HandleOwnedClientApplications

func (a *App) HandleOwnedClientApplications(w http.ResponseWriter, r *http.Request)

func (*App) HandlePlatformsPage

func (a *App) HandlePlatformsPage(w http.ResponseWriter, r *http.Request)

func (*App) HandlePollDeviceAuth

func (a *App) HandlePollDeviceAuth(w http.ResponseWriter, ctx context.Context, deviceCode string, clientID string)

func (*App) HandlePostTag

func (a *App) HandlePostTag(w http.ResponseWriter, r *http.Request)

func (*App) HandleProfilePage

func (a *App) HandleProfilePage(w http.ResponseWriter, r *http.Request)

func (*App) HandleReceiverResumableTestChunk

func (a *App) HandleReceiverResumableTestChunk(w http.ResponseWriter, r *http.Request)

func (*App) HandleRecomputeSubmissionCacheAll

func (a *App) HandleRecomputeSubmissionCacheAll(w http.ResponseWriter, r *http.Request)

func (*App) HandleRestoreGame

func (a *App) HandleRestoreGame(w http.ResponseWriter, r *http.Request)

func (*App) HandleRootPage

func (a *App) HandleRootPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleSearchFlashfreezePage

func (a *App) HandleSearchFlashfreezePage(w http.ResponseWriter, r *http.Request)

func (*App) HandleSendRemindersAboutRequestedChanges

func (a *App) HandleSendRemindersAboutRequestedChanges(w http.ResponseWriter, r *http.Request)

func (*App) HandleSessionPage

func (a *App) HandleSessionPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleSessionsPage

func (a *App) HandleSessionsPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleSoftDeleteComment

func (a *App) HandleSoftDeleteComment(w http.ResponseWriter, r *http.Request)

func (*App) HandleSoftDeleteSubmission

func (a *App) HandleSoftDeleteSubmission(w http.ResponseWriter, r *http.Request)

func (*App) HandleSoftDeleteSubmissionFile

func (a *App) HandleSoftDeleteSubmissionFile(w http.ResponseWriter, r *http.Request)

func (*App) HandleStatisticsPage

func (a *App) HandleStatisticsPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleSubmissionReceiverResumable

func (a *App) HandleSubmissionReceiverResumable(w http.ResponseWriter, r *http.Request)

func (*App) HandleSubmissionsPage

func (a *App) HandleSubmissionsPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleSubmitPage

func (a *App) HandleSubmitPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleTagEditPage

func (a *App) HandleTagEditPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleTagPage

func (a *App) HandleTagPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleTagsPage

func (a *App) HandleTagsPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleUnfreezeGame

func (a *App) HandleUnfreezeGame(w http.ResponseWriter, r *http.Request)

func (*App) HandleUnfreezeSubmission

func (a *App) HandleUnfreezeSubmission(w http.ResponseWriter, r *http.Request)

func (*App) HandleUpdateMasterDB

func (a *App) HandleUpdateMasterDB(w http.ResponseWriter, r *http.Request)

func (*App) HandleUpdateNotificationSettings

func (a *App) HandleUpdateNotificationSettings(w http.ResponseWriter, r *http.Request)

func (*App) HandleUpdateSubscriptionSettings

func (a *App) HandleUpdateSubscriptionSettings(w http.ResponseWriter, r *http.Request)

func (*App) HandleUserStatisticsPage

func (a *App) HandleUserStatisticsPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleViewSubmissionFilesPage

func (a *App) HandleViewSubmissionFilesPage(w http.ResponseWriter, r *http.Request)

func (*App) HandleViewSubmissionPage

func (a *App) HandleViewSubmissionPage(w http.ResponseWriter, r *http.Request)

func (*App) IsAction

func (a *App) IsAction(r *http.Request, action string) (bool, error)

func (*App) IsResourceFrozen

func (a *App) IsResourceFrozen(r *http.Request, resourceKey string) (bool, error)

IsResourceFrozen accepts resource that is frozen, or if any of them is when multiple are given

func (*App) IsResourceMarkedAsAdded

func (a *App) IsResourceMarkedAsAdded(r *http.Request, resourceKey string) (bool, error)

IsResourceMarkedAsAdded accepts submisison that is marked as added

func (*App) IsUserWithinResourceLimit

func (a *App) IsUserWithinResourceLimit(r *http.Request, uid int64, resourceKey string, resourceAmount int) (bool, error)

IsUserWithinResourceLimit accepts if user has no more than given amount of given resource(s)

func (*App) RenderTemplates

func (a *App) RenderTemplates(ctx context.Context, w http.ResponseWriter, r *http.Request, data interface{}, filenames ...string)

RenderTemplates is a helper for rendering templates

func (*App) RequestData

func (a *App) RequestData(next func(http.ResponseWriter, *http.Request), slimService bool) func(http.ResponseWriter, *http.Request)

func (*App) RequestJSON

func (a *App) RequestJSON(next func(http.ResponseWriter, *http.Request), slimService bool) func(http.ResponseWriter, *http.Request)

func (*App) RequestScope

func (a *App) RequestScope(next func(http.ResponseWriter, *http.Request), scope string) func(http.ResponseWriter, *http.Request)

func (*App) RequestWeb

func (a *App) RequestWeb(next func(http.ResponseWriter, *http.Request), slimService bool) func(http.ResponseWriter, *http.Request)

func (*App) UserAuthMux

func (a *App) UserAuthMux(next func(http.ResponseWriter, *http.Request), authorizers ...func(*http.Request, int64) (bool, error)) func(http.ResponseWriter, *http.Request)

UserAuthMux takes many authorization middlewares and accepts if any of them does not return error

func (*App) UserCanCommentAction

func (a *App) UserCanCommentAction(r *http.Request, uid int64) (bool, error)

UserCanCommentAction accepts user that has all of requiredRoles and owns given resource(s)

func (*App) UserHasAllRoles

func (a *App) UserHasAllRoles(r *http.Request, uid int64, requiredRoles []string) (bool, error)

UserHasAllRoles accepts user that has at least all requiredRoles

func (*App) UserHasAnyRole

func (a *App) UserHasAnyRole(r *http.Request, uid int64, roles []string) (bool, error)

UserHasAnyRole accepts user that has at least one of requiredRoles

func (*App) UserOwnsResource

func (a *App) UserOwnsResource(r *http.Request, uid int64, resourceKey string) (bool, error)

UserOwnsResource accepts user that owns given resource(s)

type AuthCodeStorage

type AuthCodeStorage struct {
	// contains filtered or unexported fields
}

func NewAuthCodeStorage

func NewAuthCodeStorage() *AuthCodeStorage

func (*AuthCodeStorage) Cleanup

func (s *AuthCodeStorage) Cleanup()

func (*AuthCodeStorage) Delete

func (s *AuthCodeStorage) Delete(deviceCode string)

func (*AuthCodeStorage) Get

func (s *AuthCodeStorage) Get(code string) (*types.AuthCodeToken, error)

func (*AuthCodeStorage) NewToken

func (s *AuthCodeStorage) NewToken(uid int64, clientId string, redirectUri string, scope string, ipAddr string) (*types.AuthCodeToken, error)

func (*AuthCodeStorage) Save

func (s *AuthCodeStorage) Save(token *types.AuthCodeToken) error

type DeviceFlowStorage

type DeviceFlowStorage struct {
	// contains filtered or unexported fields
}

func NewDeviceFlowStorage

func NewDeviceFlowStorage(baseUrl string) *DeviceFlowStorage

func (*DeviceFlowStorage) Cleanup

func (s *DeviceFlowStorage) Cleanup()

func (*DeviceFlowStorage) Delete

func (s *DeviceFlowStorage) Delete(deviceCode string)

func (*DeviceFlowStorage) Get

func (s *DeviceFlowStorage) Get(userCode string) (*types.DeviceFlowToken, error)

func (*DeviceFlowStorage) GetUserAuthToken

func (s *DeviceFlowStorage) GetUserAuthToken(deviceCode string, clientID string) *types.DeviceFlowToken

func (*DeviceFlowStorage) GetUserAuthTokens

func (s *DeviceFlowStorage) GetUserAuthTokens(uid int64) *[]DeviceFlowUserAuthToken

func (*DeviceFlowStorage) NewToken

func (s *DeviceFlowStorage) NewToken(scope string, client *types.ClientApplication) (*types.DeviceFlowToken, error)

func (*DeviceFlowStorage) Save

func (s *DeviceFlowStorage) Save(token *types.DeviceFlowToken) error

func (*DeviceFlowStorage) SaveUserAuthToken

func (s *DeviceFlowStorage) SaveUserAuthToken(uid int64, token string, deviceCode string)

type DeviceFlowUserAuthToken

type DeviceFlowUserAuthToken struct {
	AuthToken  string
	DeviceCode string
}

type OauthState

type OauthState struct {
	RedirectURI string `json:"redirect_uri"`
	Scope       string `json:"scope"`
	ClientID    string `json:"client_id"`
	State       string `json:"state"`
}

type State

type State struct {
	Nonce string `json:"nonce"`
	Dest  string `json:"dest"`
}

type StateKeeper

type StateKeeper struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*StateKeeper) Clean

func (sk *StateKeeper) Clean()

func (*StateKeeper) Consume

func (sk *StateKeeper) Consume(b string) (string, bool)

Consume consumes base64-encoded state and returns destination URL

func (*StateKeeper) Generate

func (sk *StateKeeper) Generate(dest string) (string, error)

Generate generates state and returns base64-encoded form

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL