domain

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DNSChallenge = "_frontier-domain-verification=%s"

	DefaultTokenExpiry = time.Hour * 24 * 7 // 7 days

)

Variables

View Source
var (
	ErrNotExist          = errors.New("org domain request does not exist")
	ErrInvalidDomain     = errors.New("invalid domain. No such host found")
	ErrTXTrecordNotFound = errors.New("required TXT record not found for domain verification")
	ErrDomainsMisMatch   = errors.New("user domain does not match the organization domain")
	ErrInvalidId         = errors.New("invalid domain id")
	ErrDuplicateKey      = errors.New("domain name already exists for that organization")
)

Functions

This section is empty.

Types

type Domain

type Domain struct {
	ID        string
	Name      string
	OrgID     string
	Token     string
	State     Status
	UpdatedAt time.Time
	CreatedAt time.Time
}

type Filter

type Filter struct {
	OrgID string
	State Status
	Name  string
}

type OrgService

type OrgService interface {
	ListByUser(ctx context.Context, userID string, filter organization.Filter) ([]organization.Organization, error)
	AddMember(ctx context.Context, orgID, relationName string, principal authenticate.Principal) error
	Get(ctx context.Context, id string) (organization.Organization, error)
}

type Repository

type Repository interface {
	Create(ctx context.Context, domain Domain) (Domain, error)
	Get(ctx context.Context, id string) (Domain, error)
	Update(ctx context.Context, domain Domain) (Domain, error)
	List(ctx context.Context, flt Filter) ([]Domain, error)
	Delete(ctx context.Context, id string) error
	DeleteExpiredDomainRequests(ctx context.Context) error
}

type Service

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

func NewService

func NewService(logger log.Logger, repository Repository, userService UserService, orgService OrgService) *Service

func (Service) Close

func (s Service) Close() error

func (Service) Create

func (s Service) Create(ctx context.Context, domain Domain) (Domain, error)

Creates a record for the domain in the database and returns the TXT record that needs to be added to the DNS for the domain verification

func (Service) Delete

func (s Service) Delete(ctx context.Context, id string) error

Remove an organization's whitelisted domain from the database

func (Service) Get

func (s Service) Get(ctx context.Context, id string) (Domain, error)

Get an organization's whitelisted domain from the database

func (Service) InitDomainVerification

func (s Service) InitDomainVerification(ctx context.Context) error

InitDomainVerification starts a cron job that runs once a day to delete expired domain requests which are still in pending state after 7 days of creation

func (Service) Join

func (s Service) Join(ctx context.Context, orgID string, userId string) error

Join an organization as a member if the user domain matches the org whitelisted domains

func (Service) List

func (s Service) List(ctx context.Context, flt Filter) ([]Domain, error)

List all whitelisted domains for an organization (filter by verified boolean)

func (Service) ListJoinableOrgsByDomain added in v0.7.3

func (s Service) ListJoinableOrgsByDomain(ctx context.Context, email string) ([]string, error)

func (Service) VerifyDomain

func (s Service) VerifyDomain(ctx context.Context, id string) (Domain, error)

VerifyDomain checks if the TXT record for the domain matches the token generated by Frontier for the domain verification

type Status

type Status string
const (
	Pending  Status = "pending"
	Verified Status = "verified"
)

func (Status) String

func (s Status) String() string

type UserService

type UserService interface {
	GetByID(ctx context.Context, id string) (user.User, error)
}

Jump to

Keyboard shortcuts

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