userinvite

package
v0.0.0-...-447887d Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func Init(portalProxy api.PortalProxy) (api.StratosPlugin, error)

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 user-facing error info, populated from a CF v3 error envelope.

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 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 assigns a v3 space_<role> via POST /v3/roles. The roleName argument accepts the legacy v2 plural form ("auditors", "managers", "developers") and is mapped to the v3 role type. A 422 response whose error envelope indicates the role already exists is treated as success.

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 assigns the organization_user role via POST /v3/roles. A 422 response whose error envelope indicates the role already exists is treated as success.

func (*UserInvite) Connect

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

Connect is not implemented

func (*UserInvite) CreateCloudFoundryUser

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

CreateCloudFoundryUser creates a CF user via POST /v3/users. A 422 response whose error envelope indicates the user already exists is treated as success (idempotent re-invite).

func (*UserInvite) GetEndpointPlugin

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

GetEndpointPlugin gets the endpoint plugin for this plugin

func (*UserInvite) GetMiddlewarePlugin

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

GetMiddlewarePlugin gets the middleware plugin for this plugin

func (*UserInvite) GetRoutePlugin

func (userinvite *UserInvite) GetRoutePlugin() (api.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, caCert string) (api.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) (*api.UAAResponse, *api.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 api.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 api.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 *api.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 api.CNSIRecord, tokenRecord api.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