auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoginRoute            = "Login"
	LogoutRoute           = "Logout"
	RedirectRoute         = "Redirect"
	OAuth2CallbackRoute   = "OAuth2Callback"
	UnsubscribeRoute      = "Unsubscribe"
	ApproveRedirectRoute  = "ApproveRedirect"
	ListRedirectURLsRoute = "ListRedirectURLs"
	ReplaceFCMRoute       = "ReplaceFCM"
	TestUpdateUserRoute   = "TestUpdateUser"
)

Variables

View Source
var (
	TestMode     = false
	HTMLAPILevel = 1
)
View Source
var (
	RedirectURLResource *Resource
)
View Source
var UserConfigResource = &Resource{
	Load:     loadUserConfig,
	Update:   updateUserConfig,
	FullPath: "/User/{user_id}/UserConfig",
}

Functions

func APILevel

func APILevel(r Request) int

func DecodeBytes

func DecodeBytes(ctx context.Context, b []byte) ([]byte, error)

func DecodeString

func DecodeString(ctx context.Context, s string) (string, error)

func EncodeBytes

func EncodeBytes(ctx context.Context, b []byte) ([]byte, error)

func EncodeString

func EncodeString(ctx context.Context, s string) (string, error)

func EncodeToken

func EncodeToken(ctx context.Context, user *User) (string, error)

func GetUnsubscribeURL

func GetUnsubscribeURL(ctx context.Context, r *mux.Router, host string, userId string) (*url.URL, error)

func PP

func PP(i interface{}) string

func SetOAuth

func SetOAuth(ctx context.Context, oAuth *OAuth) error

func SetSuperusers

func SetSuperusers(ctx context.Context, superusers *Superusers) error

func SetupRouter

func SetupRouter(r *mux.Router)

func UserConfigID

func UserConfigID(ctx context.Context, userID *datastore.Key) *datastore.Key

func UserID

func UserID(ctx context.Context, userID string) *datastore.Key

Types

type FCMNotificationConfig

type FCMNotificationConfig struct {
	ClickActionTemplate string `methods:"PUT" datastore:",noindex"`
	TitleTemplate       string `methods:"PUT" datastore:",noindex"`
	BodyTemplate        string `methods:"PUT" datastore:",noindex"`
}

func (*FCMNotificationConfig) Customize

func (f *FCMNotificationConfig) Customize(ctx context.Context, notif *fcm.NotificationPayload, data interface{})

func (*FCMNotificationConfig) Validate

func (f *FCMNotificationConfig) Validate() error

type FCMToken

type FCMToken struct {
	Value         string                `methods:"PUT"`
	Disabled      bool                  `methods:"PUT"`
	Note          string                `methods:"PUT" datastore:",noindex"`
	App           string                `methods:"PUT"`
	MessageConfig FCMNotificationConfig `methods:"PUT"`
	PhaseConfig   FCMNotificationConfig `methods:"PUT"`
	ReplaceToken  string                `methods:"PUT"`
}

type FCMValue

type FCMValue struct {
	Value string
}

type MailConfig

type MailConfig struct {
	Enabled           bool                   `methods:"PUT"`
	UnsubscribeConfig UnsubscribeConfig      `methods:"PUT"`
	MessageConfig     MailNotificationConfig `methods:"PUT"`
	PhaseConfig       MailNotificationConfig `methods:"PUT"`
}

func (*MailConfig) Validate

func (m *MailConfig) Validate() error

type MailNotificationConfig

type MailNotificationConfig struct {
	SubjectTemplate  string `methods:"PUT" datastore:",noindex"`
	TextBodyTemplate string `methods:"PUT" datastore:",noindex"`
	HTMLBodyTemplate string `methods:"PUT" datastore:",noindex"`
}

func (*MailNotificationConfig) Customize

func (m *MailNotificationConfig) Customize(ctx context.Context, msg *sendgrid.SGMail, data interface{})

func (*MailNotificationConfig) Validate

func (m *MailNotificationConfig) Validate() error

type OAuth

type OAuth struct {
	ClientID string
	Secret   string
}

type RedirectURL

type RedirectURL struct {
	UserId      string
	RedirectURL string
}

func (*RedirectURL) ID

func (r *RedirectURL) ID(ctx context.Context) *datastore.Key

func (*RedirectURL) Item

func (u *RedirectURL) Item(r Request) *Item

type RedirectURLs

type RedirectURLs []RedirectURL

func (RedirectURLs) Item

func (u RedirectURLs) Item(r Request, userId string) *Item

type Superusers

type Superusers struct {
	UserIds string
}

func GetSuperusers

func GetSuperusers(ctx context.Context) (*Superusers, error)

func (*Superusers) Includes

func (s *Superusers) Includes(userId string) bool

type UnsubscribeConfig

type UnsubscribeConfig struct {
	RedirectTemplate string `methods:"PUT"`
	HTMLTemplate     string `methods:"PUT"`
}

func (*UnsubscribeConfig) Validate

func (u *UnsubscribeConfig) Validate() error

type User

type User struct {
	Email         string
	FamilyName    string
	Gender        string
	GivenName     string
	Hd            string
	Id            string
	Link          string
	Locale        string
	Name          string
	Picture       string
	VerifiedEmail bool
	ValidUntil    time.Time
}

func (*User) ID

func (u *User) ID(ctx context.Context) *datastore.Key

type UserConfig

type UserConfig struct {
	UserId     string
	FCMTokens  []FCMToken `methods:"PUT"`
	MailConfig MailConfig `methods:"PUT"`
	Colors     []string   `methods:"PUT"`
}

func (*UserConfig) ID

func (u *UserConfig) ID(ctx context.Context) *datastore.Key

func (*UserConfig) Item

func (u *UserConfig) Item(r Request) *Item

Jump to

Keyboard shortcuts

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