Documentation ¶
Index ¶
- Constants
- func CORSMiddleware() gin.HandlerFunc
- func CancelEncryptBackupHandler(c *gin.Context)
- func DecryptBackupHandler(c *gin.Context)
- func EncryptBackupHandler(c *gin.Context)
- func GetClient(ctx context.Context, config *oauth2.Config) *http.Client
- func GetOrCreateFolder(srv *drive.Service, folderName string) (string, error)
- func GetTokenFromWeb(config *oauth2.Config) *oauth2.Token
- func SaveToken(file string, token *oauth2.Token)
- func TokenAuthMiddleware() gin.HandlerFunc
- func UploadFile(fileBytes []byte, token *oauth2.Token) (*oauth2.Token, error)
- func VerifyGoogleAccessToekn(access_token string) (bool, error)
- type BackupSetting
- type DecryptBackupInfo
- type GoogleDriveCredentials
- type GoogleTokenVerifyResponse
- type GoogleUserInfo
- type PortwardenServer
- type PortwardenUser
Constants ¶
View Source
const ( ErrBindingFromGin = "(debugging message) error binding json" ErrRetrievingOauthCode = "error retrieving oauth login credentials; try again" ErrCreatingPortwardenUser = "error creating a portwarden user" ErrGettingPortwardenUser = "error getting a portwarden user" ErrMergingPortwardenUser = "error merging a portwarden user" ErrLoginWithBitwarden = "error logging in with Bitwarden" ErrSettingupBackup = "error setting up backup" ErrBackupNotCancelled = "error cancelling back up" MsgSuccessfullyCancelledBackingUp = "successfully cancelled backup process" FrontEndBaseAddressTest = "http://localhost:8000/" FrontEndBaseAddressProd = "" )
View Source
const (
ErrWillNotSetupBackupByUser = "err the user stopped backing up"
)
View Source
const (
GoogleOauth2TokenContextVariableName = "GoogleOauth2TokenContextVariableName"
)
Variables ¶
This section is empty.
Functions ¶
func CORSMiddleware ¶
func CORSMiddleware() gin.HandlerFunc
func DecryptBackupHandler ¶
func EncryptBackupHandler ¶
func GetClient ¶
GetClient uses a Context and Config to retrieve a Token then generate a Client. It returns the generated Client.
func GetOrCreateFolder ¶
func GetTokenFromWeb ¶
GetTokenFromWeb uses Config to request a Token. It returns the retrieved Token.
func TokenAuthMiddleware ¶
func TokenAuthMiddleware() gin.HandlerFunc
func UploadFile ¶
UploadFile upload the fileBytes to Google Drive's portwarden folder https://gist.github.com/tzmartin/f5732091783752660b671c20479f519a
func VerifyGoogleAccessToekn ¶
Types ¶
type BackupSetting ¶
type DecryptBackupInfo ¶
type DecryptBackupInfo struct { File *multipart.FileHeader `form:"file"` Passphrase string `form:"passphrase"` }
type GoogleDriveCredentials ¶
type GoogleTokenVerifyResponse ¶
type GoogleTokenVerifyResponse struct { IssuedTo string `json:"issued_to"` Audience string `json:"audience"` UserID string `json:"user_id"` Scope string `json:"scope"` ExpiresIn int64 `json:"expires_in"` Email string `json:"email"` VerifiedEmail bool `json:"verified_email"` AccessType string `json:"access_type"` }
type GoogleUserInfo ¶
type GoogleUserInfo struct { ID string `json:"id"` Email string `json:"email"` Name string `json:"name"` GivenName string `json:"given_name"` FamilyName string `json:"family_name"` Link string `json:"link"` Picture string `json:"picture"` Locale string `json:"locale"` }
func RetrieveUserEmail ¶
func RetrieveUserEmail(token *oauth2.Token) (GoogleUserInfo, error)
type PortwardenServer ¶
type PortwardenServer struct { Port int Router *gin.Engine GoogleDriveContext context.Context GoogleDriveAppCredentials []byte GoogleDriveAppConfig *oauth2.Config }
func (*PortwardenServer) GetGoogleDriveLoginHandler ¶
func (ps *PortwardenServer) GetGoogleDriveLoginHandler(c *gin.Context)
func (*PortwardenServer) GetGoogleDriveLoginURLHandler ¶
func (ps *PortwardenServer) GetGoogleDriveLoginURLHandler(c *gin.Context)
TODO: GoogleDriveHandler() will return Json with the google login url Not sure if it's supposed to call UploadFile() directly
func (*PortwardenServer) Run ¶
func (ps *PortwardenServer) Run()
type PortwardenUser ¶
type PortwardenUser struct { Email string `json:"email"` BitwardenDataJSON []byte `json:"bitwarden_data_json"` BitwardenSessionKey string `json:"bitwarden_session_key"` BackupSetting BackupSetting `json:"backup_setting"` BitwardenLoginCredentials *portwarden.LoginCredentials `json:"bitwarden_login_credentials"` // Not stored in Redis GoogleUserInfo GoogleUserInfo GoogleToken *oauth2.Token }
func (*PortwardenUser) CreateWithGoogle ¶
func (pu *PortwardenUser) CreateWithGoogle() error
func (*PortwardenUser) Get ¶
func (pu *PortwardenUser) Get() error
func (*PortwardenUser) LoginWithBitwarden ¶
func (pu *PortwardenUser) LoginWithBitwarden() error
func (*PortwardenUser) Set ¶
func (pu *PortwardenUser) Set() error
func (*PortwardenUser) SetupAutomaticBackup ¶
func (pu *PortwardenUser) SetupAutomaticBackup(eta *time.Time) error
Click to show internal directories.
Click to hide internal directories.