services

package
v0.0.0-...-db47865 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	Username string `json:"username"`
	HasMFA   bool   `json:"has_mfa"`
	jwt.StandardClaims
}

Claims is used Used for the session cookie

type DataProtector

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

func NewDataProtector

func NewDataProtector(config *models.Config) *DataProtector

NewDataProtector creates an instance of DataProtector

func (*DataProtector) Decrypt

func (d *DataProtector) Decrypt(encryptedString string) (string, error)

func (*DataProtector) Encrypt

func (d *DataProtector) Encrypt(stringToEncrypt string) (string, error)

type GoogleProvider

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

func NewGoogleProvider

func NewGoogleProvider(redirectDomain string, tenantID string, clientID string, clientSecret string) *GoogleProvider

func (*GoogleProvider) GetURL

func (p *GoogleProvider) GetURL(state string) string

func (*GoogleProvider) GetUserInfo

func (p *GoogleProvider) GetUserInfo(code string) (OAuth2User, error)

type MicrosoftProvider

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

func NewMicrosoftProvider

func NewMicrosoftProvider(redirectDomain string, tenantID string, clientID string, clientSecret string) *MicrosoftProvider

func (*MicrosoftProvider) GetURL

func (p *MicrosoftProvider) GetURL(state string) string

func (*MicrosoftProvider) GetUserInfo

func (p *MicrosoftProvider) GetUserInfo(code string) (OAuth2User, error)

type NotificationsManager

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

func NewNotificationsManager

func NewNotificationsManager(db *gorm.DB, config *models.Config, bus *EventBus.Bus) *NotificationsManager

New creates an instance of the controller and sets its DB handle

func (*NotificationsManager) NotifyUser

func (n *NotificationsManager) NotifyUser(user *models.User, sourceIP string) (bool, *uuid.UUID, error)

func (*NotificationsManager) PublishBrowserProof

func (n *NotificationsManager) PublishBrowserProof(identity string, sourceIP string, nonce uuid.UUID)

func (*NotificationsManager) WaitForBrowserProof

func (n *NotificationsManager) WaitForBrowserProof(user *models.User, sourceIP string, nonce uuid.UUID) bool

WaitForBrowserProof waits for browser to reply with a request having a valid session token, and a body containing the same nonce value that was sent with the Push or SSE notification.

type OAuth2Provider

type OAuth2Provider interface {
	GetURL(state string) string
	GetUserInfo(code string) (OAuth2User, error)
}

type OAuth2User

type OAuth2User struct {
	Id            string `json:"sub"`
	Email         string `json:"email"`
	EmailVerified string `json:"email_verified"`
}

type SessionInfo

type SessionInfo struct {
	Identity            string // user identity (email)
	Issuer              string // Name of the connection
	EnableNotifications bool
	FullyAuthenticated  bool   // Whether authentication fully complies with requirement (ie MFA)
	SessionExpiry       int64  // Unix timestamp
	IconURL             string // LOGOURL
}

type UserManager

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

func NewUserManager

func NewUserManager(db *gorm.DB, config *models.Config) *UserManager

New creates an instance of UserManager and sets its DB handle

func (*UserManager) AddMFA

func (m *UserManager) AddMFA(user *models.User, mfaType string, data string, userAgent string) (*models.UserMFA, error)

AddMFA Creates a new `UserMFA`, and encrypts the `data` field

func (*UserManager) AddUserSubscription

func (m *UserManager) AddUserSubscription(user *models.User, subscription *models.UserSubscription) (*models.UserSubscription, error)

func (*UserManager) CheckOrCreate

func (m *UserManager) CheckOrCreate(email string) (*models.User, error)

Check that the user exists and has a valid OTP setup. User is created if it doesn't exist. Returns false if the user doesn't have a verified TOTP secret

func (*UserManager) CheckVpnSession

func (m *UserManager) CheckVpnSession(identity string, ip string) (*models.User, *models.VpnSession, bool, error)

func (*UserManager) CleanupConnectionsLog

func (m *UserManager) CleanupConnectionsLog() error

CleanupConnections deletes connection entries older than configured value

func (*UserManager) CreateSession

func (m *UserManager) CreateSession(user *models.User, hasMFA bool, w http.ResponseWriter) error

CreateSession generates and sends the JWT token cookie.

func (*UserManager) CreateVpnSession

func (m *UserManager) CreateVpnSession(user *models.User, ip string) error

CreateVpnSession Creates a new VPN "Session" for the `User` from the specified IP address.

func (*UserManager) DeleteSession

func (m *UserManager) DeleteSession(w http.ResponseWriter) error

func (*UserManager) DeleteUserSubscription

func (m *UserManager) DeleteUserSubscription(subscription *models.UserSubscription) error

func (*UserManager) DeleteVpnSession

func (m *UserManager) DeleteVpnSession(identity string, ip string) error

func (*UserManager) Get

func (m *UserManager) Get(email string) (*models.User, error)

func (*UserManager) UpdateMFA

func (m *UserManager) UpdateMFA(userMFA models.UserMFA) (*models.UserMFA, error)

UpdateMFA updates a `UserMFA`. It assumes that the `data` field need to be encrypted again.

func (*UserManager) ValidateMFA

func (m *UserManager) ValidateMFA(mfa *models.UserMFA, data string) (*models.UserMFA, error)

ValidateMFA sets the UserMFA as validated and saves any data if present.

Jump to

Keyboard shortcuts

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