auth0

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Bool         = auth0.Bool
	BoolValue    = auth0.BoolValue
	String       = auth0.String
	StringValue  = auth0.StringValue
	Int          = auth0.Int
	IntValue     = auth0.IntValue
	Float64      = auth0.Float64
	Float64Value = auth0.Float64Value
	Time         = auth0.Time
	TimeValue    = auth0.TimeValue
)

Alias all the helper methods so we can keep just typing `auth0.Bool` and the compiler can autocomplete our internal package.

Functions

func Error added in v0.6.1

func Error(e error, message string) error

Types

type API

type API struct {
	Action           ActionAPI
	Anomaly          AnomalyAPI
	AttackProtection AttackProtectionAPI
	Branding         BrandingAPI
	BrandingTheme    BrandingThemeAPI
	Client           ClientAPI
	ClientGrant      ClientGrantAPI
	Connection       ConnectionAPI
	CustomDomain     CustomDomainAPI
	EmailTemplate    EmailTemplateAPI
	EmailProvider    EmailProviderAPI
	Log              LogAPI
	LogStream        LogStreamAPI
	Organization     OrganizationAPI
	Prompt           PromptAPI
	ResourceServer   ResourceServerAPI
	Role             RoleAPI
	Rule             RuleAPI
	Tenant           TenantAPI
	User             UserAPI
	Jobs             JobsAPI

	HTTPClient HTTPClientAPI
}

API mimics `management.Management`s general interface, except it refers to the interfaces instead of the concrete structs.

func NewAPI

func NewAPI(m *management.Management) *API

type ActionAPI

type ActionAPI interface {
	// Create a new action.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Actions/post_action
	Create(ctx context.Context, a *management.Action, opts ...management.RequestOption) error

	// Read action details.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Actions/get_action
	Read(ctx context.Context, id string, opts ...management.RequestOption) (*management.Action, error)

	// Update an existing action.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Actions/patch_action
	Update(ctx context.Context, id string, a *management.Action, opts ...management.RequestOption) error

	// Delete an action
	//
	// See: https://auth0.com/docs/api/management/v2#!/Actions/delete_action
	Delete(ctx context.Context, id string, opts ...management.RequestOption) error

	// List all actions.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Actions/get_actions
	List(ctx context.Context, opts ...management.RequestOption) (c *management.ActionList, err error)

	// Triggers available.
	//
	// https://auth0.com/docs/api/management/v2/#!/Actions/get_triggers
	Triggers(ctx context.Context, opts ...management.RequestOption) (l *management.ActionTriggerList, err error)

	// Bindings lists the bindings of a trigger.
	//
	// See: https://auth0.com/docs/api/management/v2/#!/Actions/get_bindings
	Bindings(ctx context.Context, triggerID string, opts ...management.RequestOption) (bl *management.ActionBindingList, err error)

	// Deploy an action.
	//
	// See: https://auth0.com/docs/api/management/v2/#!/Actions/post_deploy_action
	Deploy(ctx context.Context, id string, opts ...management.RequestOption) (v *management.ActionVersion, err error)
}

type AnomalyAPI added in v0.7.0

type AnomalyAPI interface {
	// Check if a given IP address is blocked via the multiple user accounts
	// trigger due to multiple failed logins.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Anomaly/get_ips_by_id
	CheckIP(ctx context.Context, ip string, opts ...management.RequestOption) (isBlocked bool, err error)

	// Unblock an IP address currently blocked by the multiple user accounts
	// trigger due to multiple failed logins.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Anomaly/delete_ips_by_id
	UnblockIP(ctx context.Context, ip string, opts ...management.RequestOption) (err error)
}

type AttackProtectionAPI added in v0.11.7

type AttackProtectionAPI interface {
	// GetBreachedPasswordDetection retrieves breached password detection settings.
	//
	// Required scope: `read:attack_protection`
	//
	// See: https://auth0.com/docs/api/management/v2#!/Attack_Protection/get_breached_password_detection
	GetBreachedPasswordDetection(ctx context.Context,
		opts ...management.RequestOption,
	) (bpd *management.BreachedPasswordDetection, err error)

	// UpdateBreachedPasswordDetection updates the breached password detection settings.
	//
	// Required scope: `update:attack_protection`
	//
	// See: https://auth0.com/docs/api/management/v2#!/Attack_Protection/patch_breached_password_detection
	UpdateBreachedPasswordDetection(
		ctx context.Context, bpd *management.BreachedPasswordDetection,
		opts ...management.RequestOption,
	) (err error)

	// GetBruteForceProtection retrieves the brute force configuration.
	//
	// Required scope: `read:attack_protection`
	//
	// See: https://auth0.com/docs/api/management/v2#!/Attack_Protection/get_brute_force_protection
	GetBruteForceProtection(
		ctx context.Context, opts ...management.RequestOption,
	) (bfp *management.BruteForceProtection, err error)

	// UpdateBruteForceProtection updates the brute force configuration.
	//
	// Required scope: `update:attack_protection`
	//
	// See: https://auth0.com/docs/api/management/v2#!/Attack_Protection/patch_brute_force_protection
	UpdateBruteForceProtection(
		ctx context.Context, bfp *management.BruteForceProtection,
		opts ...management.RequestOption,
	) (err error)

	// GetSuspiciousIPThrottling retrieves the suspicious IP throttling configuration.
	//
	// Required scope: `read:attack_protection`
	//
	// See: https://auth0.com/docs/api/management/v2#!/Attack_Protection/get_suspicious_ip_throttling
	GetSuspiciousIPThrottling(
		ctx context.Context, opts ...management.RequestOption,
	) (sit *management.SuspiciousIPThrottling, err error)

	// UpdateSuspiciousIPThrottling updates the suspicious IP throttling configuration.
	//
	// Required scope: `update:attack_protection`
	//
	// See: https://auth0.com/docs/api/management/v2#!/Attack_Protection/patch_suspicious_ip_throttling
	UpdateSuspiciousIPThrottling(
		ctx context.Context, sit *management.SuspiciousIPThrottling,
		opts ...management.RequestOption,
	) (err error)
}

type BrandingAPI added in v0.6.0

type BrandingAPI interface {
	Read(ctx context.Context, opts ...management.RequestOption) (b *management.Branding, err error)
	Update(ctx context.Context, t *management.Branding, opts ...management.RequestOption) (err error)
	UniversalLogin(ctx context.Context, opts ...management.RequestOption) (ul *management.BrandingUniversalLogin, err error)
	SetUniversalLogin(ctx context.Context, ul *management.BrandingUniversalLogin, opts ...management.RequestOption) (err error)
	DeleteUniversalLogin(ctx context.Context, opts ...management.RequestOption) (err error)
}

type BrandingThemeAPI added in v1.2.0

type BrandingThemeAPI interface {
	Default(ctx context.Context, opts ...management.RequestOption) (theme *management.BrandingTheme, err error)
	Create(ctx context.Context, theme *management.BrandingTheme, opts ...management.RequestOption) (err error)
	Read(ctx context.Context, id string, opts ...management.RequestOption) (theme *management.BrandingTheme, err error)
	Update(ctx context.Context, id string, theme *management.BrandingTheme, opts ...management.RequestOption) (err error)
	Delete(ctx context.Context, id string, opts ...management.RequestOption) (err error)
}

type ClientAPI

type ClientAPI interface {
	// Create a new client application.
	Create(ctx context.Context, c *management.Client, opts ...management.RequestOption) (err error)

	// Read a client by its id.
	Read(ctx context.Context, id string, opts ...management.RequestOption) (c *management.Client, err error)

	// List all client applications.
	List(ctx context.Context, opts ...management.RequestOption) (c *management.ClientList, err error)

	// Update a client.
	Update(ctx context.Context, id string, c *management.Client, opts ...management.RequestOption) (err error)

	// RotateSecret rotates a client secret.
	RotateSecret(ctx context.Context, id string, opts ...management.RequestOption) (c *management.Client, err error)

	// Delete a client and all its related assets (like rules, connections, etc)
	// given its id.
	Delete(ctx context.Context, id string, opts ...management.RequestOption) error
}

type ClientGrantAPI added in v1.0.0

type ClientGrantAPI interface {
	// List all client grants.
	List(ctx context.Context, opts ...management.RequestOption) (*management.ClientGrantList, error)
}

type ConnectionAPI added in v0.7.0

type ConnectionAPI interface {

	// Create a new connection.
	Create(ctx context.Context, c *management.Connection, opts ...management.RequestOption) (err error)

	// Read retrieves a connection by its id.
	Read(ctx context.Context, id string, opts ...management.RequestOption) (c *management.Connection, err error)

	// ReadByName retrieves a connection by its name.
	ReadByName(ctx context.Context, id string, opts ...management.RequestOption) (c *management.Connection, err error)

	// Update a connection.
	Update(ctx context.Context, id string, c *management.Connection, opts ...management.RequestOption) (err error)

	// Delete a connection.
	Delete(ctx context.Context, id string, opts ...management.RequestOption) (err error)

	// List all connections.
	List(ctx context.Context, opts ...management.RequestOption) (ul *management.ConnectionList, err error)
}

type CustomDomainAPI added in v0.6.0

type CustomDomainAPI interface {
	// Create a new custom domain.
	Create(ctx context.Context, c *management.CustomDomain, opts ...management.RequestOption) (err error)

	// Read retrieves a custom domain by its id.
	Read(ctx context.Context, id string, opts ...management.RequestOption) (c *management.CustomDomain, err error)

	// Update a custom domain.
	Update(ctx context.Context, id string, c *management.CustomDomain, opts ...management.RequestOption) (err error)

	// Delete a custom domain.
	Delete(ctx context.Context, id string, opts ...management.RequestOption) (err error)

	// Verify a custom domain.
	Verify(ctx context.Context, id string, opts ...management.RequestOption) (c *management.CustomDomain, err error)

	// List all custom domains.
	List(ctx context.Context, opts ...management.RequestOption) (c []*management.CustomDomain, err error)
}

type EmailProviderAPI added in v1.1.2

type EmailProviderAPI interface {
	// Read email provider details.
	// See: https://auth0.com/docs/api/management/v2#!/Emails/get_provider
	Read(ctx context.Context, opts ...management.RequestOption) (ep *management.EmailProvider, err error)
}

type EmailTemplateAPI added in v0.9.1

type EmailTemplateAPI interface {
	// Create an email template.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Email_Templates/post_email_templates
	Create(ctx context.Context, template *management.EmailTemplate, opts ...management.RequestOption) error

	// Read an email template by pre-defined name.
	//
	// These names are `verify_email`, `reset_email`, `welcome_email`,
	// `blocked_account`, `stolen_credentials`, `enrollment_email`, and
	// `mfa_oob_code`.
	//
	// The names `change_password`, and `password_reset` are also supported for
	// legacy scenarios.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName
	Read(ctx context.Context, template string, opts ...management.RequestOption) (e *management.EmailTemplate, err error)

	// Update an email template.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Email_Templates/patch_email_templates_by_templateName
	Update(ctx context.Context, template string, e *management.EmailTemplate, opts ...management.RequestOption) (err error)
}

type HTTPClientAPI added in v1.0.0

type HTTPClientAPI interface {
	// NewRequest returns a new HTTP request.
	// If the payload is not nil it will be encoded as JSON.
	NewRequest(ctx context.Context, method, uri string, payload interface{}, options ...management.RequestOption) (*http.Request, error)

	// Do triggers an HTTP request and returns an HTTP response,
	// handling any context cancellations or timeouts.
	Do(req *http.Request) (*http.Response, error)
}

type JobsAPI added in v0.11.6

type JobsAPI interface {
	VerifyEmail(ctx context.Context, j *management.Job, opts ...management.RequestOption) (err error)
	Read(ctx context.Context, id string, opts ...management.RequestOption) (j *management.Job, err error)
	ExportUsers(ctx context.Context, j *management.Job, opts ...management.RequestOption) (err error)
	ImportUsers(ctx context.Context, j *management.Job, opts ...management.RequestOption) (err error)
}

type LogAPI

type LogAPI interface {
	// Read the data related to the log entry identified by id. This returns a
	// single log entry representation as specified in the schema.
	Read(ctx context.Context, id string, opts ...management.RequestOption) (l *management.Log, err error)

	// List all log entries that match the specified search criteria (or lists all
	// log entries if no criteria are used). Set custom search criteria using the
	// `q` parameter, or search from a specific log id ("search from checkpoint").
	//
	// For more information on all possible event types, their respective acronyms
	// and descriptions, Log Data Event Listing.
	List(ctx context.Context, opts ...management.RequestOption) (l []*management.Log, err error)

	// Search is an alias for List.
	Search(ctx context.Context, opts ...management.RequestOption) ([]*management.Log, error)
}

type LogStreamAPI added in v0.8.0

type LogStreamAPI interface {
	// Create a log stream.
	Create(ctx context.Context, ls *management.LogStream, opts ...management.RequestOption) (err error)

	// Read a log stream.
	Read(ctx context.Context, id string, opts ...management.RequestOption) (ls *management.LogStream, err error)

	// Update a log stream.
	Update(ctx context.Context, id string, ls *management.LogStream, opts ...management.RequestOption) (err error)

	// List all log streams.
	List(ctx context.Context, opts ...management.RequestOption) (ls []*management.LogStream, err error)

	// Delete a log stream.
	Delete(ctx context.Context, id string, opts ...management.RequestOption) (err error)
}

type OrganizationAPI added in v0.10.0

type OrganizationAPI interface {
	// Create an Organization.
	//
	// See: https://auth0.com/docs/api/management/v2/#!/Organizations/post_organizations
	Create(ctx context.Context, o *management.Organization, opts ...management.RequestOption) error

	// Read a specific organization.
	//
	// See: https://auth0.com/docs/api/management/v2/#!/Organizations/get_organizations_by_id
	Read(ctx context.Context, id string, opts ...management.RequestOption) (*management.Organization, error)

	// Update an organization.
	//
	// See: https://auth0.com/docs/api/management/v2/#!/Organizations/patch_organizations_by_id
	Update(ctx context.Context, id string, o *management.Organization, opts ...management.RequestOption) error

	// Delete a specific organization.
	//
	// See: https://auth0.com/docs/api/management/v2/#!/Organizations/delete_organizations_by_id
	Delete(ctx context.Context, id string, opts ...management.RequestOption) error

	// List available organizations.
	//
	// See: https://auth0.com/docs/api/management/v2/#!/Organizations/get_organizations
	List(ctx context.Context, opts ...management.RequestOption) (c *management.OrganizationList, err error)

	// Members lists members of an organization.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Organizations/get_members
	Members(ctx context.Context, id string, opts ...management.RequestOption) (o *management.OrganizationMemberList, err error)

	// MemberRoles lists roles assigned to a member of an organization
	//
	// See: https://auth0.com/docs/api/management/v2#!/Organizations/get_organization_member_roles
	MemberRoles(ctx context.Context, id string, userID string, opts ...management.RequestOption) (r *management.OrganizationMemberRoleList, err error)

	// Connections retrieves connections enabled for an organization.
	//
	// See: https://auth0.com/docs/api/management/v2/#!/Organizations/get_enabled_connections
	Connections(ctx context.Context, id string, opts ...management.RequestOption) (c *management.OrganizationConnectionList, err error)
}

type PromptAPI added in v0.11.3

type PromptAPI interface {
	// Read retrieves prompts settings.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Prompts/get_prompts
	Read(ctx context.Context, opts ...management.RequestOption) (p *management.Prompt, err error)

	// Update prompts settings.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Prompts/patch_prompts
	Update(ctx context.Context, p *management.Prompt, opts ...management.RequestOption) error

	// CustomText retrieves the custom text for a specific prompt and language.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Prompts/get_custom_text_by_language
	CustomText(ctx context.Context, p string, l string, opts ...management.RequestOption) (t map[string]interface{}, err error)

	// SetCustomText sets the custom text for a specific prompt. Existing texts will be overwritten.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Prompts/put_custom_text_by_language
	SetCustomText(ctx context.Context, p string, l string, b map[string]interface{}, opts ...management.RequestOption) (err error)
}

type Quickstart added in v0.5.0

type Quickstart struct {
	Name                 string `json:"name"`
	AppType              string `json:"appType"`
	URL                  string `json:"url"`
	DownloadLink         string `json:"downloadLink"`
	DownloadInstructions string `json:"downloadInstructions"`
}

func (Quickstart) Download added in v1.0.0

func (q Quickstart) Download(ctx context.Context, downloadPath string, client *management.Client) error

func (Quickstart) SamplePath added in v1.0.0

func (q Quickstart) SamplePath(downloadPath string) (string, error)

type Quickstarts added in v1.0.0

type Quickstarts []Quickstart

func GetQuickstarts added in v1.0.0

func GetQuickstarts(ctx context.Context) (Quickstarts, error)

func (Quickstarts) FilterByType added in v1.0.0

func (q Quickstarts) FilterByType(qsType string) (Quickstarts, error)

func (Quickstarts) FindByStack added in v1.0.0

func (q Quickstarts) FindByStack(stack string) (Quickstart, error)

func (Quickstarts) Stacks added in v1.0.0

func (q Quickstarts) Stacks() []string

type ResourceServerAPI

type ResourceServerAPI interface {
	// Create a resource server.
	Create(ctx context.Context, rs *management.ResourceServer, opts ...management.RequestOption) (err error)

	// Read retrieves a resource server by its id or audience.
	Read(ctx context.Context, id string, opts ...management.RequestOption) (rs *management.ResourceServer, err error)

	// Update a resource server.
	Update(ctx context.Context, id string, rs *management.ResourceServer, opts ...management.RequestOption) (err error)

	// Delete a resource server.
	Delete(ctx context.Context, id string, opts ...management.RequestOption) (err error)

	// List all resource server.
	List(ctx context.Context, opts ...management.RequestOption) (rl *management.ResourceServerList, err error)
}

type RoleAPI added in v0.7.0

type RoleAPI interface {
	// Create a new role.
	Create(ctx context.Context, r *management.Role, opts ...management.RequestOption) (err error)

	// Retrieve a role.
	Read(ctx context.Context, id string, opts ...management.RequestOption) (r *management.Role, err error)

	// List all roles that can be assigned to users or groups.
	List(ctx context.Context, opts ...management.RequestOption) (r *management.RoleList, err error)

	// Update a role.
	Update(ctx context.Context, id string, r *management.Role, opts ...management.RequestOption) (err error)

	// Delete a role.
	Delete(ctx context.Context, id string, opts ...management.RequestOption) (err error)

	// AssociatePermissions associates permissions to a role.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Roles/post_role_permission_assignment
	AssociatePermissions(ctx context.Context, id string, permissions []*management.Permission, opts ...management.RequestOption) error

	// Permissions retrieves all permissions granted by a role.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Roles/get_role_permission
	Permissions(ctx context.Context, id string, opts ...management.RequestOption) (p *management.PermissionList, err error)

	// RemovePermissions removes permissions associated to a role.
	//
	// See: https://auth0.com/docs/api/management/v2#!/Roles/delete_role_permission_assignment
	RemovePermissions(ctx context.Context, id string, permissions []*management.Permission, opts ...management.RequestOption) error
}

type RuleAPI added in v0.3.0

type RuleAPI interface {
	// Create a new rule.
	//
	// Note: Changing a rule's stage of execution from the default `login_success`
	// can change the rule's function signature to have user omitted.
	Create(ctx context.Context, r *management.Rule, opts ...management.RequestOption) error

	// Retrieve rule details. Accepts a list of fields to include or exclude in the result.
	Read(ctx context.Context, id string, opts ...management.RequestOption) (r *management.Rule, err error)

	// Update an existing rule.
	Update(ctx context.Context, id string, r *management.Rule, opts ...management.RequestOption) error

	// Delete a rule.
	Delete(ctx context.Context, id string, opts ...management.RequestOption) error

	// List all rules.
	List(ctx context.Context, opts ...management.RequestOption) (r *management.RuleList, err error)
}

type TenantAPI added in v0.6.0

type TenantAPI interface {
	Read(ctx context.Context, opts ...management.RequestOption) (t *management.Tenant, err error)
}

type UserAPI added in v0.5.1

type UserAPI interface {
	// Blocks retrieves a list of blocked IP addresses of a particular user.
	Blocks(ctx context.Context, id string, opts ...management.RequestOption) ([]*management.UserBlock, error)

	// BlocksByIdentifier retrieves a list of blocked IP addresses of a particular user using any of the user identifiers: username, phone number or email.
	BlocksByIdentifier(ctx context.Context, identifier string, opts ...management.RequestOption) ([]*management.UserBlock, error)

	// Unblock a user that was blocked due to an excessive amount of incorrectly
	// provided credentials.
	Unblock(ctx context.Context, id string, opts ...management.RequestOption) error

	// UnblockByIdentifier a user that was blocked due to an excessive amount of incorrectly provided credentials using any of the user identifiers: username, phone number or email.
	UnblockByIdentifier(ctx context.Context, identifier string, opts ...management.RequestOption) error

	// Create a new user.
	Create(ctx context.Context, u *management.User, opts ...management.RequestOption) (err error)

	// Read user details for a given user.
	Read(ctx context.Context, id string, opts ...management.RequestOption) (u *management.User, err error)

	// Update user.
	Update(ctx context.Context, id string, u *management.User, opts ...management.RequestOption) (err error)

	// Delete a user.
	Delete(ctx context.Context, id string, opts ...management.RequestOption) (err error)

	// List all users.
	List(ctx context.Context, opts ...management.RequestOption) (ul *management.UserList, err error)

	// Search for users.
	Search(ctx context.Context, opts ...management.RequestOption) (us *management.UserList, err error)

	// Roles lists all roles associated with a user.
	Roles(ctx context.Context, id string, opts ...management.RequestOption) (r *management.RoleList, err error)

	// AssignRoles assigns roles to a user.
	AssignRoles(ctx context.Context, id string, roles []*management.Role, opts ...management.RequestOption) error

	// RemoveRoles removes roles from a user.
	RemoveRoles(ctx context.Context, id string, roles []*management.Role, opts ...management.RequestOption) error
}

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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