Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DXCDT-496] Update to go-auth0 v1 #783

Merged
merged 6 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/auth0/go-auth0 v0.17.2
github.com/auth0/go-auth0 v1.0.0
github.com/briandowns/spinner v1.23.0
github.com/charmbracelet/glamour v0.6.0
github.com/fsnotify/fsnotify v1.6.0
Expand All @@ -26,6 +26,7 @@ require (
github.com/tidwall/pretty v1.2.1
github.com/zalando/go-keyring v0.2.3
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
golang.org/x/net v0.12.0
golang.org/x/oauth2 v0.10.0
golang.org/x/sync v0.3.0
golang.org/x/sys v0.10.0
Expand All @@ -35,7 +36,7 @@ require (
)

require (
github.com/PuerkitoBio/rehttp v1.1.0 // indirect
github.com/PuerkitoBio/rehttp v1.2.0 // indirect
github.com/alecthomas/chroma v0.10.0 // indirect
github.com/alessio/shellescape v1.4.1 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
Expand Down Expand Up @@ -78,7 +79,6 @@ require (
github.com/yuin/goldmark-emoji v1.0.1 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkk
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
github.com/PuerkitoBio/rehttp v1.1.0 h1:JFZ7OeK+hbJpTxhNB0NDZT47AuXqCU0Smxfjtph7/Rs=
github.com/PuerkitoBio/rehttp v1.1.0/go.mod h1:LUwKPoDbDIA2RL5wYZCNsQ90cx4OJ4AWBmq6KzWZL1s=
github.com/PuerkitoBio/rehttp v1.2.0 h1:V8MGVcDwR+u/xwLlMrw5YZONDm3JISEKqwJTiIuJA+s=
github.com/PuerkitoBio/rehttp v1.2.0/go.mod h1:LUwKPoDbDIA2RL5wYZCNsQ90cx4OJ4AWBmq6KzWZL1s=
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0=
github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30=
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/auth0/go-auth0 v0.17.2 h1:qEttAY4yYeEJl6wu0iOwlet26wUKA2G5YOUomfuxcy4=
github.com/auth0/go-auth0 v0.17.2/go.mod h1:Hlp4kYcvn2JSD1tAmPQ8DD7MMoiO0bwVJwTHXqJbDDE=
github.com/auth0/go-auth0 v1.0.0 h1:YAsnl0MMl/8n3fEloUIjPEgTXcwWpIN+csT33d28IiQ=
github.com/auth0/go-auth0 v1.0.0/go.mod h1:VfORX7cl3o1RIzDNX8eDXgib8ioTyE17sUeL+LUK8is=
github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0 h1:0NmehRCgyk5rljDQLKUO+cRJCnduDyn11+zGZIc9Z48=
github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0/go.mod h1:6L7zgvqo0idzI7IO8de6ZC051AfXb5ipkIJ7bIA2tGA=
github.com/aymanbagabas/go-osc52 v1.0.3 h1:DTwqENW7X9arYimJrPeGZcV0ln14sGMt3pHZspWD+Mg=
Expand Down
20 changes: 12 additions & 8 deletions internal/auth0/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,45 @@

package auth0

import "github.com/auth0/go-auth0/management"
import (
"context"

"github.com/auth0/go-auth0/management"
)

type ActionAPI interface {
// Create a new action.
//
// See: https://auth0.com/docs/api/management/v2#!/Actions/post_action
Create(a *management.Action, opts ...management.RequestOption) error
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(id string, opts ...management.RequestOption) (*management.Action, error)
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(id string, a *management.Action, opts ...management.RequestOption) error
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(id string, opts ...management.RequestOption) error
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(opts ...management.RequestOption) (c *management.ActionList, err error)
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(opts ...management.RequestOption) (l *management.ActionTriggerList, err error)
Triggers(ctx context.Context, opts ...management.RequestOption) (l *management.ActionTriggerList, err error)

// Deploy an action.
//
// See: https://auth0.com/docs/api/management/v2/#!/Actions/post_deploy_action
Deploy(id string, opts ...management.RequestOption) (v *management.ActionVersion, err error)
Deploy(ctx context.Context, id string, opts ...management.RequestOption) (v *management.ActionVersion, err error)
}
10 changes: 7 additions & 3 deletions internal/auth0/anomaly.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package auth0

import "github.com/auth0/go-auth0/management"
import (
"context"

"github.com/auth0/go-auth0/management"
)

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(ip string, opts ...management.RequestOption) (isBlocked bool, err error)
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(ip string, opts ...management.RequestOption) (err error)
UnblockIP(ctx context.Context, ip string, opts ...management.RequestOption) (err error)
}
14 changes: 8 additions & 6 deletions internal/auth0/attack_protection.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package auth0

import (
"context"

"github.com/auth0/go-auth0/management"
)

Expand All @@ -10,7 +12,7 @@ type AttackProtectionAPI interface {
// Required scope: `read:attack_protection`
//
// See: https://auth0.com/docs/api/management/v2#!/Attack_Protection/get_breached_password_detection
GetBreachedPasswordDetection(
GetBreachedPasswordDetection(ctx context.Context,
opts ...management.RequestOption,
) (bpd *management.BreachedPasswordDetection, err error)

Expand All @@ -20,7 +22,7 @@ type AttackProtectionAPI interface {
//
// See: https://auth0.com/docs/api/management/v2#!/Attack_Protection/patch_breached_password_detection
UpdateBreachedPasswordDetection(
bpd *management.BreachedPasswordDetection,
ctx context.Context, bpd *management.BreachedPasswordDetection,
opts ...management.RequestOption,
) (err error)

Expand All @@ -30,7 +32,7 @@ type AttackProtectionAPI interface {
//
// See: https://auth0.com/docs/api/management/v2#!/Attack_Protection/get_brute_force_protection
GetBruteForceProtection(
opts ...management.RequestOption,
ctx context.Context, opts ...management.RequestOption,
) (bfp *management.BruteForceProtection, err error)

// UpdateBruteForceProtection updates the brute force configuration.
Expand All @@ -39,7 +41,7 @@ type AttackProtectionAPI interface {
//
// See: https://auth0.com/docs/api/management/v2#!/Attack_Protection/patch_brute_force_protection
UpdateBruteForceProtection(
bfp *management.BruteForceProtection,
ctx context.Context, bfp *management.BruteForceProtection,
opts ...management.RequestOption,
) (err error)

Expand All @@ -49,7 +51,7 @@ type AttackProtectionAPI interface {
//
// See: https://auth0.com/docs/api/management/v2#!/Attack_Protection/get_suspicious_ip_throttling
GetSuspiciousIPThrottling(
opts ...management.RequestOption,
ctx context.Context, opts ...management.RequestOption,
) (sit *management.SuspiciousIPThrottling, err error)

// UpdateSuspiciousIPThrottling updates the suspicious IP throttling configuration.
Expand All @@ -58,7 +60,7 @@ type AttackProtectionAPI interface {
//
// See: https://auth0.com/docs/api/management/v2#!/Attack_Protection/patch_suspicious_ip_throttling
UpdateSuspiciousIPThrottling(
sit *management.SuspiciousIPThrottling,
ctx context.Context, sit *management.SuspiciousIPThrottling,
opts ...management.RequestOption,
) (err error)
}
18 changes: 12 additions & 6 deletions internal/auth0/branding.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
//go:generate mockgen -source=branding.go -destination=mock/branding_mock.go -package=mock

package auth0

import "github.com/auth0/go-auth0/management"
import (
"context"

"github.com/auth0/go-auth0/management"
)

type BrandingAPI interface {
Read(opts ...management.RequestOption) (b *management.Branding, err error)
Update(t *management.Branding, opts ...management.RequestOption) (err error)
UniversalLogin(opts ...management.RequestOption) (ul *management.BrandingUniversalLogin, err error)
SetUniversalLogin(ul *management.BrandingUniversalLogin, opts ...management.RequestOption) (err error)
DeleteUniversalLogin(opts ...management.RequestOption) (err error)
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)
}
14 changes: 9 additions & 5 deletions internal/auth0/branding_prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@

package auth0

import "github.com/auth0/go-auth0/management"
import (
"context"

"github.com/auth0/go-auth0/management"
)

type PromptAPI interface {
// Read retrieves prompts settings.
//
// See: https://auth0.com/docs/api/management/v2#!/Prompts/get_prompts
Read(opts ...management.RequestOption) (p *management.Prompt, err error)
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(p *management.Prompt, opts ...management.RequestOption) error
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(p string, l string, opts ...management.RequestOption) (t map[string]interface{}, err error)
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(p string, l string, b map[string]interface{}, opts ...management.RequestOption) (err error)
SetCustomText(ctx context.Context, p string, l string, b map[string]interface{}, opts ...management.RequestOption) (err error)
}
18 changes: 11 additions & 7 deletions internal/auth0/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@

package auth0

import "github.com/auth0/go-auth0/management"
import (
"context"

"github.com/auth0/go-auth0/management"
)

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

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

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

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

// RotateSecret rotates a client secret.
RotateSecret(id string, opts ...management.RequestOption) (c *management.Client, err error)
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(id string, opts ...management.RequestOption) error
Delete(ctx context.Context, id string, opts ...management.RequestOption) error
}
8 changes: 6 additions & 2 deletions internal/auth0/client_grant.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package auth0

import "github.com/auth0/go-auth0/management"
import (
"context"

"github.com/auth0/go-auth0/management"
)

type ClientGrantAPI interface {
// List all client grants.
List(opts ...management.RequestOption) (*management.ClientGrantList, error)
List(ctx context.Context, opts ...management.RequestOption) (*management.ClientGrantList, error)
}
20 changes: 13 additions & 7 deletions internal/auth0/connection.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
//go:generate mockgen -source=connection.go -destination=mock/connection_mock.go -package=mock

package auth0

import "github.com/auth0/go-auth0/management"
import (
"context"

"github.com/auth0/go-auth0/management"
)

type ConnectionAPI interface {

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

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

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

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

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

// List all connections.
List(opts ...management.RequestOption) (ul *management.ConnectionList, err error)
List(ctx context.Context, opts ...management.RequestOption) (ul *management.ConnectionList, err error)
}
20 changes: 13 additions & 7 deletions internal/auth0/custom_domain.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
//go:generate mockgen -source=custom_domain.go -destination=mock/custom_domain_mock.go -package=mock

package auth0

import "github.com/auth0/go-auth0/management"
import (
"context"

"github.com/auth0/go-auth0/management"
)

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

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

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

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

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

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