userinvite

package
v0.0.0-...-f34f428 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const UAAClientAuthType = "uaa-client"

UAAClientAuthType is the Auth Type for client id/client secret

View Source
const UserInvitePluginConfigSetting = "userInvitationsEnabled"

UserInvitePluginConfigSetting is config value send back to the client to indicate if user invite is enabled

View Source
const UserInviteUserID = "00000000-1111-2222-3333-444444444455"

UserInviteUserID is the User ID for the user invitation token

Variables

This section is empty.

Functions

func Init

Init creates a new UserInvite

Types

type CFError

type CFError struct {
	Description string `json:"description"`
	ErrorCode   string `json:"error_code"`
	Code        int    `json:"code"`
}

CFError is the error info returned from the CF API

type ClientConfig

type ClientConfig struct {
	ID     string `configName:"INVITE_USER_CLIENT_ID"`
	Secret string `configName:"INVITE_USER_CLIENT_SECRET"`
}

UAA Client details used to create uaa & cf user

type Config

type Config struct {
	SMTP              *SMTPConfig
	TemplateConfig    *TemplateConfig
	PlainTextTemplate *text.Template
	HTMLTemplate      *html.Template
	SubjectTemplate   *text.Template
	Client            *ClientConfig
}

Config represents the configuration required

type EmailTemplateParams

type EmailTemplateParams struct {
	InviteLink   string
	EmailAddress string
	EndpointName string
	EndpointURL  string
}

EmailTemplateParams is the supported params for the email templates

type OrgRolesResponse

type OrgRolesResponse struct {
	Metadata struct {
		GUID string `json:"guid"`
	} `json:"metadata"`
	Entity struct {
		OrgRoles []string `json:"organization_roles"`
	} `json:"entity"`
}

type RetrieveOrgRolesResponse

type RetrieveOrgRolesResponse struct {
	TotalResults int                `json:"total_results"`
	Resources    []OrgRolesResponse `json:"resources"`
}

RetrieveOrgRolesResponse is the response from the CF GET Org Roles API

type SMTPConfig

type SMTPConfig struct {
	Auth        bool   `configName:"SMTP_AUTH"`
	FromAddress string `configName:"SMTP_FROM_ADDRESS"`
	Host        string `configName:"SMTP_HOST"`
	Password    string `configName:"SMTP_PASSWORD"`
	Port        int    `configName:"SMTP_PORT"`
	Username    string `configName:"SMTP_USER"`
}

SMTPConfig represents email configuration

type StatusResponse

type StatusResponse struct {
	EndpointGUID string `json:"endpoint_guid"`
	Enabled      bool   `json:"enabled"`
	ClientID     string `json:"client_id"`
}

type TemplateConfig

type TemplateConfig struct {
	TemplateDir       string `configName:"TEMPLATE_DIR"`
	HTMLTemplate      string `configName:"INVITE_USER_HTML_TEMPLATE"`
	PlainTextTemplate string `configName:"INVITE_USER_TEXT_TEMPLATE"`
	Subject           string `configName:"INVITE_USER_SUBJECT"`
}

TemplateConfig configures the templates for sending emails

type UAAUserInviteReq

type UAAUserInviteReq struct {
	Emails []string `json:"emails"`
}

UAAUserInviteReq is the structure to send to the UAA Invite Users API

type UserInvite

type UserInvite struct {
	Config *Config
	// contains filtered or unexported fields
}

UserInvite is a plugin to allow user invitations

func (*UserInvite) AddAdminGroupRoutes

func (userinvite *UserInvite) AddAdminGroupRoutes(echoGroup *echo.Group)

AddAdminGroupRoutes adds the admin routes for this plugin to the Echo server

func (*UserInvite) AddSessionGroupRoutes

func (userinvite *UserInvite) AddSessionGroupRoutes(echoGroup *echo.Group)

AddSessionGroupRoutes adds the session routes for this plugin to the Echo server

func (*UserInvite) AssociateSpaceRoleForUser

func (invite *UserInvite) AssociateSpaceRoleForUser(cnsiGUID, userID, newUserGUID, spaceGUID, roleName string) (*CFError, error)

AssociateSpaceRoleForUser associates a user in the space with the given role

func (*UserInvite) AssociateSpaceRoles

func (invite *UserInvite) AssociateSpaceRoles(cnsiGUID, userID, newUserGUID string, inviteRequest *UserInviteReq) (*CFError, error)

AssociateSpaceRoles will make the CF API call to associate the correct space roles for the user

func (*UserInvite) AssociateUserWithOrg

func (invite *UserInvite) AssociateUserWithOrg(cnsiGUID, userID, newUserGUID, orgGUID string) (*CFError, error)

AssociateUserWithOrg will make the CF API call to associate the given user with the given org

func (*UserInvite) Connect

func (invite *UserInvite) Connect(echoContext echo.Context, cnsiRecord interfaces.CNSIRecord, userId string) (*interfaces.TokenRecord, bool, error)

Connect is not implemented

func (*UserInvite) CreateCloudFoundryUser

func (invite *UserInvite) CreateCloudFoundryUser(cnsiGUID, userID, newUserGUID string) (*CFError, error)

CreateCloudFoundryUser will make the CF API call to create the user in CF

func (*UserInvite) GetEndpointPlugin

func (userinvite *UserInvite) GetEndpointPlugin() (interfaces.EndpointPlugin, error)

GetEndpointPlugin gets the endpoint plugin for this plugin

func (*UserInvite) GetMiddlewarePlugin

func (userinvite *UserInvite) GetMiddlewarePlugin() (interfaces.MiddlewarePlugin, error)

GetMiddlewarePlugin gets the middleware plugin for this plugin

func (*UserInvite) GetRoutePlugin

func (userinvite *UserInvite) GetRoutePlugin() (interfaces.RoutePlugin, error)

GetRoutePlugin gets the route plugin for this plugin

func (*UserInvite) GetType

func (invite *UserInvite) GetType() string

GetType - return empty string as we don't introduce a new enpoint type

func (*UserInvite) Info

func (invite *UserInvite) Info(apiEndpoint string, skipSSLValidation bool) (interfaces.CNSIRecord, interface{}, error)

Info is not implemented

func (*UserInvite) Init

func (userinvite *UserInvite) Init() error

Init performs plugin initialization

func (*UserInvite) LoadConfig

func (userinvite *UserInvite) LoadConfig(env env.VarSet) (*Config, error)

LoadConfig loads the configuration for inviting users

func (*UserInvite) RefreshToken

func (invite *UserInvite) RefreshToken(cfGUID, clientID, clientSecret string) (*interfaces.UAAResponse, *interfaces.TokenRecord, error)

RefreshToken will refresh the token for the client

func (*UserInvite) Register

func (invite *UserInvite) Register(echoContext echo.Context) error

Register is not implemented

func (*UserInvite) SendEmail

func (invite *UserInvite) SendEmail(emailAddress, inviteLink string, endpoint interfaces.CNSIRecord) error

SendEmail sends an invitation email to a user using the configured templates

func (*UserInvite) UAAUserInvite

func (invite *UserInvite) UAAUserInvite(c echo.Context, endpoint interfaces.CNSIRecord, uaaInviteReq *UserInviteReq) (*UserInviteResponse, error)

UAAUserInvite makes the request to the UAA to create accounts and invite links

func (*UserInvite) UpdateMetadata

func (invite *UserInvite) UpdateMetadata(info *interfaces.Info, userGUID string, echoContext echo.Context)

UpdateMetadata will add metadata for each Cloud Foundry endpoint to indicate if user invitation is allowed

func (*UserInvite) Validate

func (invite *UserInvite) Validate(userGUID string, cnsiRecord interfaces.CNSIRecord, tokenRecord interfaces.TokenRecord) error

func (*UserInvite) ValidateConfig

func (userinvite *UserInvite) ValidateConfig(c *Config) error

ValidateConfig will validate that enough configuration is available

type UserInviteReq

type UserInviteReq struct {
	Org        string `json:"org"`
	Space      string `json:"space"`
	SpaceRoles struct {
		Auditor   bool `json:"auditor"`
		Developer bool `json:"developer"`
		Manager   bool `json:"manager"`
	} `json:"spaceRoles"`
	Emails []string `json:"emails"`
}

UserInviteReq is the payload that is POSTed to request user invites to be generated

type UserInviteResponse

type UserInviteResponse struct {
	NewInvites    []UserInviteUser `json:"new_invites"`
	FailedInvites []UserInviteUser `json:"failed_invites"`
}

UserInviteResponse is the response from the UAA Invite Users API

type UserInviteUser

type UserInviteUser struct {
	Email        string `json:"email"`
	UserID       string `json:"userid"`
	Success      bool   `json:"success"`
	ErrorCode    string `json:"errorCode"`
	ErrorMessage string `json:"errorMessage"`
	InviteLink   string `json:"inviteLink"`
}

UserInviteUser is the individual response from the UAA Invite Users API

Jump to

Keyboard shortcuts

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