From f5da1ffd86a571dc5f90adf455e2edf6a90fa16c Mon Sep 17 00:00:00 2001 From: Cyril David Date: Fri, 14 May 2021 17:10:59 -0700 Subject: [PATCH] fix: remove stale actions code (#295) * tidy / vendor * surgery: remove actions from logs and refs to it --- go.mod | 4 - go.sum | 9 +- internal/auth0/actions.go | 33 - internal/auth0/actions/actions.go | 43 - internal/auth0/actions_mock.go | 376 --------- internal/auth0/auth0.go | 44 +- internal/cli/logs.go | 29 +- internal/display/logs.go | 8 +- .../mitchellh/mapstructure/.travis.yml | 8 + .../mitchellh/mapstructure/CHANGELOG.md | 52 -- .../mitchellh/mapstructure/decode_hooks.go | 71 +- .../github.com/mitchellh/mapstructure/go.mod | 2 - .../mitchellh/mapstructure/mapstructure.go | 479 ++--------- vendor/gopkg.in/auth0.v5/.gitignore | 5 +- vendor/gopkg.in/auth0.v5/CHANGELOG.md | 46 +- vendor/gopkg.in/auth0.v5/README.md | 18 +- vendor/gopkg.in/auth0.v5/go.mod | 5 +- vendor/gopkg.in/auth0.v5/go.sum | 4 +- .../gopkg.in/auth0.v5/management/actions.go | 273 ------ .../gopkg.in/auth0.v5/management/anomaly.go | 49 ++ vendor/gopkg.in/auth0.v5/management/client.go | 63 +- .../auth0.v5/management/connection.go | 239 +++--- vendor/gopkg.in/auth0.v5/management/grant.go | 9 +- .../gopkg.in/auth0.v5/management/guardian.go | 154 +++- vendor/gopkg.in/auth0.v5/management/log.go | 4 +- .../auth0.v5/management/management.gen.go | 780 +++++++++++++++++- .../auth0.v5/management/management.go | 32 +- vendor/gopkg.in/auth0.v5/management/prompt.go | 3 + .../auth0.v5/management/signing_key.go | 82 ++ vendor/gopkg.in/auth0.v5/management/user.go | 115 ++- vendor/modules.txt | 5 +- 31 files changed, 1598 insertions(+), 1446 deletions(-) delete mode 100644 internal/auth0/actions.go delete mode 100644 internal/auth0/actions/actions.go delete mode 100644 internal/auth0/actions_mock.go create mode 100644 vendor/github.com/mitchellh/mapstructure/.travis.yml delete mode 100644 vendor/gopkg.in/auth0.v5/management/actions.go create mode 100644 vendor/gopkg.in/auth0.v5/management/anomaly.go create mode 100644 vendor/gopkg.in/auth0.v5/management/signing_key.go diff --git a/go.mod b/go.mod index c5c44df17..a6cfbb6ef 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,3 @@ require ( gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) - -// replace gopkg.in/auth0.v5 => ../auth0 - -replace gopkg.in/auth0.v5 => github.com/go-auth0/auth0 v1.3.1-0.20210128024326-898cafab69ba diff --git a/go.sum b/go.sum index 5c417670c..0161ee09e 100644 --- a/go.sum +++ b/go.sum @@ -138,8 +138,6 @@ github.com/getsentry/sentry-go v0.10.0/go.mod h1:kELm/9iCblqUYh+ZRML7PNdCvEuw24w github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= -github.com/go-auth0/auth0 v1.3.1-0.20210128024326-898cafab69ba h1:q5mOa+S8JFpV5JzwTX5FImMekMxOkIGjWiH2OmSo92M= -github.com/go-auth0/auth0 v1.3.1-0.20210128024326-898cafab69ba/go.mod h1:QQ9fgGj2Wpza15+Ho3mM6amMeKfhzHo2cixcOqdkoKk= github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= @@ -262,6 +260,8 @@ github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/ github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7UaeZTSWddIk= github.com/iris-contrib/pongo2 v0.0.1/go.mod h1:Ssh+00+3GAZqSQb30AvBRNxBx7rf0GqwkjqxNd0u65g= github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= +github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -356,9 +356,8 @@ github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eI github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -784,6 +783,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/auth0.v5 v5.17.0 h1:QBY9DJh/LNE1qEQc8r7Bg6edj+AyNb+r0UxZplx598g= +gopkg.in/auth0.v5 v5.17.0/go.mod h1:ZUc29HB1p9iYkA1ti2uz/kVL3I9vg+Hs+qFjHKub9SM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= diff --git a/internal/auth0/actions.go b/internal/auth0/actions.go deleted file mode 100644 index df83b57a1..000000000 --- a/internal/auth0/actions.go +++ /dev/null @@ -1,33 +0,0 @@ -//go:generate mockgen -source=actions.go -destination=actions_mock.go -package=auth0 -package auth0 - -import "gopkg.in/auth0.v5/management" - -type ActionAPI interface { - Create(a *management.Action) error - Read(id string) (*management.Action, error) - Update(id string, a *management.Action) error - Delete(id string, opts ...management.RequestOption) error - List(opts ...management.RequestOption) (c *management.ActionList, err error) -} - -type ActionVersionAPI interface { - Create(actionID string, v *management.ActionVersion) error - Read(actionID string, id string) (*management.ActionVersion, error) - UpsertDraft(actionID string, v *management.ActionVersion) error - ReadDraft(actionID string) (*management.ActionVersion, error) - Delete(actionID string, id string, opts ...management.RequestOption) error - List(actionID string, opts ...management.RequestOption) (c *management.ActionVersionList, err error) - Test(actionID string, id string, payload management.Object) (management.Object, error) - Deploy(actionID string, id string) (*management.ActionVersion, error) -} - -type ActionBindingAPI interface { - Create(triggerID management.TriggerID, action *management.Action) (ab *management.ActionBinding, err error) - List(triggerID management.TriggerID, opts ...management.RequestOption) (c *management.ActionBindingList, err error) - Update(triggerID management.TriggerID, v []*management.ActionBinding) (list *management.ActionBindingList, err error) -} - -type ActionExecutionAPI interface { - Read(id string) (*management.ActionExecution, error) -} diff --git a/internal/auth0/actions/actions.go b/internal/auth0/actions/actions.go deleted file mode 100644 index 4564a3ff6..000000000 --- a/internal/auth0/actions/actions.go +++ /dev/null @@ -1,43 +0,0 @@ -package actions - -import ( - "errors" - "time" - - "github.com/auth0/auth0-cli/internal/auth0" - "gopkg.in/auth0.v5/management" -) - -// NewSampledExecutionAPI creates a decorated ActionExecutionAPI which -// implements a leaky bucket based on the given interval. -func NewSampledExecutionAPI(api auth0.ActionExecutionAPI, interval time.Duration) auth0.ActionExecutionAPI { - return &sampledExecutionAPI{ - api: api, - interval: interval, - timer: time.NewTimer(0), - } -} - -type sampledExecutionAPI struct { - auth0.ActionExecutionAPI - - api auth0.ActionExecutionAPI - - interval time.Duration - timer *time.Timer -} - -// errRateLimited is returned whenever the leaky bucket isn't ready to drip. -var errRateLimited = errors.New("actions: rate limited") - -// Read checks if the leaky bucket is ready to drip: if not, then an -// errRateLimited is returned. -func (a *sampledExecutionAPI) Read(id string) (*management.ActionExecution, error) { - select { - case <-a.timer.C: - a.timer.Reset(a.interval) - return a.api.Read(id) - default: - return nil, errRateLimited - } -} diff --git a/internal/auth0/actions_mock.go b/internal/auth0/actions_mock.go deleted file mode 100644 index 4c19b92d1..000000000 --- a/internal/auth0/actions_mock.go +++ /dev/null @@ -1,376 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: actions.go - -// Package auth0 is a generated GoMock package. -package auth0 - -import ( - gomock "github.com/golang/mock/gomock" - management "gopkg.in/auth0.v5/management" - reflect "reflect" -) - -// MockActionAPI is a mock of ActionAPI interface -type MockActionAPI struct { - ctrl *gomock.Controller - recorder *MockActionAPIMockRecorder -} - -// MockActionAPIMockRecorder is the mock recorder for MockActionAPI -type MockActionAPIMockRecorder struct { - mock *MockActionAPI -} - -// NewMockActionAPI creates a new mock instance -func NewMockActionAPI(ctrl *gomock.Controller) *MockActionAPI { - mock := &MockActionAPI{ctrl: ctrl} - mock.recorder = &MockActionAPIMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockActionAPI) EXPECT() *MockActionAPIMockRecorder { - return m.recorder -} - -// Create mocks base method -func (m *MockActionAPI) Create(a *management.Action) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", a) - ret0, _ := ret[0].(error) - return ret0 -} - -// Create indicates an expected call of Create -func (mr *MockActionAPIMockRecorder) Create(a interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockActionAPI)(nil).Create), a) -} - -// Read mocks base method -func (m *MockActionAPI) Read(id string) (*management.Action, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Read", id) - ret0, _ := ret[0].(*management.Action) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Read indicates an expected call of Read -func (mr *MockActionAPIMockRecorder) Read(id interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockActionAPI)(nil).Read), id) -} - -// Update mocks base method -func (m *MockActionAPI) Update(id string, a *management.Action) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Update", id, a) - ret0, _ := ret[0].(error) - return ret0 -} - -// Update indicates an expected call of Update -func (mr *MockActionAPIMockRecorder) Update(id, a interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockActionAPI)(nil).Update), id, a) -} - -// Delete mocks base method -func (m *MockActionAPI) Delete(id string, opts ...management.RequestOption) error { - m.ctrl.T.Helper() - varargs := []interface{}{id} - for _, a := range opts { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "Delete", varargs...) - ret0, _ := ret[0].(error) - return ret0 -} - -// Delete indicates an expected call of Delete -func (mr *MockActionAPIMockRecorder) Delete(id interface{}, opts ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{id}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockActionAPI)(nil).Delete), varargs...) -} - -// List mocks base method -func (m *MockActionAPI) List(opts ...management.RequestOption) (*management.ActionList, error) { - m.ctrl.T.Helper() - varargs := []interface{}{} - for _, a := range opts { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "List", varargs...) - ret0, _ := ret[0].(*management.ActionList) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// List indicates an expected call of List -func (mr *MockActionAPIMockRecorder) List(opts ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockActionAPI)(nil).List), opts...) -} - -// MockActionVersionAPI is a mock of ActionVersionAPI interface -type MockActionVersionAPI struct { - ctrl *gomock.Controller - recorder *MockActionVersionAPIMockRecorder -} - -// MockActionVersionAPIMockRecorder is the mock recorder for MockActionVersionAPI -type MockActionVersionAPIMockRecorder struct { - mock *MockActionVersionAPI -} - -// NewMockActionVersionAPI creates a new mock instance -func NewMockActionVersionAPI(ctrl *gomock.Controller) *MockActionVersionAPI { - mock := &MockActionVersionAPI{ctrl: ctrl} - mock.recorder = &MockActionVersionAPIMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockActionVersionAPI) EXPECT() *MockActionVersionAPIMockRecorder { - return m.recorder -} - -// Create mocks base method -func (m *MockActionVersionAPI) Create(actionID string, v *management.ActionVersion) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", actionID, v) - ret0, _ := ret[0].(error) - return ret0 -} - -// Create indicates an expected call of Create -func (mr *MockActionVersionAPIMockRecorder) Create(actionID, v interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockActionVersionAPI)(nil).Create), actionID, v) -} - -// Read mocks base method -func (m *MockActionVersionAPI) Read(actionID, id string) (*management.ActionVersion, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Read", actionID, id) - ret0, _ := ret[0].(*management.ActionVersion) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Read indicates an expected call of Read -func (mr *MockActionVersionAPIMockRecorder) Read(actionID, id interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockActionVersionAPI)(nil).Read), actionID, id) -} - -// UpsertDraft mocks base method -func (m *MockActionVersionAPI) UpsertDraft(actionID string, v *management.ActionVersion) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpsertDraft", actionID, v) - ret0, _ := ret[0].(error) - return ret0 -} - -// UpsertDraft indicates an expected call of UpsertDraft -func (mr *MockActionVersionAPIMockRecorder) UpsertDraft(actionID, v interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpsertDraft", reflect.TypeOf((*MockActionVersionAPI)(nil).UpsertDraft), actionID, v) -} - -// ReadDraft mocks base method -func (m *MockActionVersionAPI) ReadDraft(actionID string) (*management.ActionVersion, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ReadDraft", actionID) - ret0, _ := ret[0].(*management.ActionVersion) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ReadDraft indicates an expected call of ReadDraft -func (mr *MockActionVersionAPIMockRecorder) ReadDraft(actionID interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadDraft", reflect.TypeOf((*MockActionVersionAPI)(nil).ReadDraft), actionID) -} - -// Delete mocks base method -func (m *MockActionVersionAPI) Delete(actionID, id string, opts ...management.RequestOption) error { - m.ctrl.T.Helper() - varargs := []interface{}{actionID, id} - for _, a := range opts { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "Delete", varargs...) - ret0, _ := ret[0].(error) - return ret0 -} - -// Delete indicates an expected call of Delete -func (mr *MockActionVersionAPIMockRecorder) Delete(actionID, id interface{}, opts ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{actionID, id}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockActionVersionAPI)(nil).Delete), varargs...) -} - -// List mocks base method -func (m *MockActionVersionAPI) List(actionID string, opts ...management.RequestOption) (*management.ActionVersionList, error) { - m.ctrl.T.Helper() - varargs := []interface{}{actionID} - for _, a := range opts { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "List", varargs...) - ret0, _ := ret[0].(*management.ActionVersionList) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// List indicates an expected call of List -func (mr *MockActionVersionAPIMockRecorder) List(actionID interface{}, opts ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{actionID}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockActionVersionAPI)(nil).List), varargs...) -} - -// Test mocks base method -func (m *MockActionVersionAPI) Test(actionID, id string, payload management.Object) (management.Object, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Test", actionID, id, payload) - ret0, _ := ret[0].(management.Object) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Test indicates an expected call of Test -func (mr *MockActionVersionAPIMockRecorder) Test(actionID, id, payload interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Test", reflect.TypeOf((*MockActionVersionAPI)(nil).Test), actionID, id, payload) -} - -// Deploy mocks base method -func (m *MockActionVersionAPI) Deploy(actionID, id string) (*management.ActionVersion, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Deploy", actionID, id) - ret0, _ := ret[0].(*management.ActionVersion) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Deploy indicates an expected call of Deploy -func (mr *MockActionVersionAPIMockRecorder) Deploy(actionID, id interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Deploy", reflect.TypeOf((*MockActionVersionAPI)(nil).Deploy), actionID, id) -} - -// MockActionBindingAPI is a mock of ActionBindingAPI interface -type MockActionBindingAPI struct { - ctrl *gomock.Controller - recorder *MockActionBindingAPIMockRecorder -} - -// MockActionBindingAPIMockRecorder is the mock recorder for MockActionBindingAPI -type MockActionBindingAPIMockRecorder struct { - mock *MockActionBindingAPI -} - -// NewMockActionBindingAPI creates a new mock instance -func NewMockActionBindingAPI(ctrl *gomock.Controller) *MockActionBindingAPI { - mock := &MockActionBindingAPI{ctrl: ctrl} - mock.recorder = &MockActionBindingAPIMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockActionBindingAPI) EXPECT() *MockActionBindingAPIMockRecorder { - return m.recorder -} - -// Create mocks base method -func (m *MockActionBindingAPI) Create(triggerID management.TriggerID, action *management.Action) (*management.ActionBinding, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", triggerID, action) - ret0, _ := ret[0].(*management.ActionBinding) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Create indicates an expected call of Create -func (mr *MockActionBindingAPIMockRecorder) Create(triggerID, action interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockActionBindingAPI)(nil).Create), triggerID, action) -} - -// List mocks base method -func (m *MockActionBindingAPI) List(triggerID management.TriggerID, opts ...management.RequestOption) (*management.ActionBindingList, error) { - m.ctrl.T.Helper() - varargs := []interface{}{triggerID} - for _, a := range opts { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "List", varargs...) - ret0, _ := ret[0].(*management.ActionBindingList) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// List indicates an expected call of List -func (mr *MockActionBindingAPIMockRecorder) List(triggerID interface{}, opts ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{triggerID}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockActionBindingAPI)(nil).List), varargs...) -} - -// Update mocks base method -func (m *MockActionBindingAPI) Update(triggerID management.TriggerID, v []*management.ActionBinding) (*management.ActionBindingList, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Update", triggerID, v) - ret0, _ := ret[0].(*management.ActionBindingList) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Update indicates an expected call of Update -func (mr *MockActionBindingAPIMockRecorder) Update(triggerID, v interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockActionBindingAPI)(nil).Update), triggerID, v) -} - -// MockActionExecutionAPI is a mock of ActionExecutionAPI interface -type MockActionExecutionAPI struct { - ctrl *gomock.Controller - recorder *MockActionExecutionAPIMockRecorder -} - -// MockActionExecutionAPIMockRecorder is the mock recorder for MockActionExecutionAPI -type MockActionExecutionAPIMockRecorder struct { - mock *MockActionExecutionAPI -} - -// NewMockActionExecutionAPI creates a new mock instance -func NewMockActionExecutionAPI(ctrl *gomock.Controller) *MockActionExecutionAPI { - mock := &MockActionExecutionAPI{ctrl: ctrl} - mock.recorder = &MockActionExecutionAPIMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockActionExecutionAPI) EXPECT() *MockActionExecutionAPIMockRecorder { - return m.recorder -} - -// Read mocks base method -func (m *MockActionExecutionAPI) Read(id string) (*management.ActionExecution, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Read", id) - ret0, _ := ret[0].(*management.ActionExecution) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Read indicates an expected call of Read -func (mr *MockActionExecutionAPIMockRecorder) Read(id interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockActionExecutionAPI)(nil).Read), id) -} diff --git a/internal/auth0/auth0.go b/internal/auth0/auth0.go index 25d3e1967..33f8d6dff 100644 --- a/internal/auth0/auth0.go +++ b/internal/auth0/auth0.go @@ -8,36 +8,28 @@ import ( // API mimics `management.Management`s general interface, except it refers to // the interfaces instead of the concrete structs. type API struct { - Action ActionAPI - ActionVersion ActionVersionAPI - ActionExecution ActionExecutionAPI - ActionBinding ActionBindingAPI - Branding BrandingAPI - Client ClientAPI - CustomDomain CustomDomainAPI - Log LogAPI - ResourceServer ResourceServerAPI - Rule RuleAPI - Tenant TenantAPI - User UserAPI - Connection ConnectionAPI + Branding BrandingAPI + Client ClientAPI + CustomDomain CustomDomainAPI + Log LogAPI + ResourceServer ResourceServerAPI + Rule RuleAPI + Tenant TenantAPI + User UserAPI + Connection ConnectionAPI } func NewAPI(m *management.Management) *API { return &API{ - Action: m.Action, - ActionVersion: m.ActionVersion, - ActionExecution: m.ActionExecution, - ActionBinding: m.ActionBinding, - Branding: m.Branding, - Client: m.Client, - CustomDomain: m.CustomDomain, - Log: m.Log, - ResourceServer: m.ResourceServer, - Rule: m.Rule, - Tenant: m.Tenant, - User: m.User, - Connection: m.Connection, + Branding: m.Branding, + Client: m.Client, + CustomDomain: m.CustomDomain, + Log: m.Log, + ResourceServer: m.ResourceServer, + Rule: m.Rule, + Tenant: m.Tenant, + User: m.User, + Connection: m.Connection, } } diff --git a/internal/cli/logs.go b/internal/cli/logs.go index 74573329d..0cbee9cf4 100644 --- a/internal/cli/logs.go +++ b/internal/cli/logs.go @@ -5,7 +5,6 @@ import ( "sort" "time" - "github.com/auth0/auth0-cli/internal/auth0/actions" "github.com/spf13/cobra" "gopkg.in/auth0.v5/management" ) @@ -61,24 +60,8 @@ auth0 logs ls -n 100`, return fmt.Errorf("An unexpected error occurred while getting logs: %v", err) } - // TODO(cyx): This is a hack for now to make the - // streaming work faster. - // - // Create a `set` to detect duplicates clientside. - // set := make(map[string]struct{}) - // list = dedupLogs(list, set) - var logsCh chan []*management.Log - - // We create an execution API decorator which provides - // a leaky bucket implementation for Read. This - // protects us from being rate limited since we - // potentially have an N+1 querying situation. - actionExecutionAPI := actions.NewSampledExecutionAPI( - cli.api.ActionExecution, time.Second, - ) - - cli.renderer.LogList(list, logsCh, actionExecutionAPI, !cli.debug) + cli.renderer.LogList(list, logsCh, !cli.debug) return nil }, } @@ -158,15 +141,7 @@ auth0 logs tail -n 100`, }() - // We create an execution API decorator which provides - // a leaky bucket implementation for Read. This - // protects us from being rate limited since we - // potentially have an N+1 querying situation. - actionExecutionAPI := actions.NewSampledExecutionAPI( - cli.api.ActionExecution, time.Second, - ) - - cli.renderer.LogList(list, logsCh, actionExecutionAPI, !cli.debug) + cli.renderer.LogList(list, logsCh, !cli.debug) return nil }, } diff --git a/internal/display/logs.go b/internal/display/logs.go index 26d861ef6..5a811b5f8 100644 --- a/internal/display/logs.go +++ b/internal/display/logs.go @@ -27,8 +27,6 @@ var _ View = &logView{} type logView struct { silent bool *management.Log - - ActionExecutionAPI auth0.ActionExecutionAPI } func (v *logView) AsTableHeader() []string { @@ -142,7 +140,7 @@ func (v *logView) typeDesc() (typ, desc string) { return typ, desc } -func (r *Renderer) LogList(logs []*management.Log, ch <-chan []*management.Log, api auth0.ActionExecutionAPI, silent bool) { +func (r *Renderer) LogList(logs []*management.Log, ch <-chan []*management.Log, silent bool) { resource := "logs" r.Heading(resource) @@ -155,7 +153,7 @@ func (r *Renderer) LogList(logs []*management.Log, ch <-chan []*management.Log, var res []View for _, l := range logs { - res = append(res, &logView{Log: l, ActionExecutionAPI: api, silent: silent}) + res = append(res, &logView{Log: l, silent: silent}) } var viewChan chan View @@ -168,7 +166,7 @@ func (r *Renderer) LogList(logs []*management.Log, ch <-chan []*management.Log, for list := range ch { for _, l := range list { - viewChan <- &logView{Log: l, ActionExecutionAPI: api, silent: silent} + viewChan <- &logView{Log: l, silent: silent} } } }() diff --git a/vendor/github.com/mitchellh/mapstructure/.travis.yml b/vendor/github.com/mitchellh/mapstructure/.travis.yml new file mode 100644 index 000000000..1689c7d73 --- /dev/null +++ b/vendor/github.com/mitchellh/mapstructure/.travis.yml @@ -0,0 +1,8 @@ +language: go + +go: + - "1.11.x" + - tip + +script: + - go test diff --git a/vendor/github.com/mitchellh/mapstructure/CHANGELOG.md b/vendor/github.com/mitchellh/mapstructure/CHANGELOG.md index 1955f2878..3b3cb723f 100644 --- a/vendor/github.com/mitchellh/mapstructure/CHANGELOG.md +++ b/vendor/github.com/mitchellh/mapstructure/CHANGELOG.md @@ -1,55 +1,3 @@ -## unreleased - -* Fix regression where `*time.Time` value would be set to empty and not be sent - to decode hooks properly [GH-232] - -## 1.4.0 - -* A new decode hook type `DecodeHookFuncValue` has been added that has - access to the full values. [GH-183] -* Squash is now supported with embedded fields that are struct pointers [GH-205] -* Empty strings will convert to 0 for all numeric types when weakly decoding [GH-206] - -## 1.3.3 - -* Decoding maps from maps creates a settable value for decode hooks [GH-203] - -## 1.3.2 - -* Decode into interface type with a struct value is supported [GH-187] - -## 1.3.1 - -* Squash should only squash embedded structs. [GH-194] - -## 1.3.0 - -* Added `",omitempty"` support. This will ignore zero values in the source - structure when encoding. [GH-145] - -## 1.2.3 - -* Fix duplicate entries in Keys list with pointer values. [GH-185] - -## 1.2.2 - -* Do not add unsettable (unexported) values to the unused metadata key - or "remain" value. [GH-150] - -## 1.2.1 - -* Go modules checksum mismatch fix - -## 1.2.0 - -* Added support to capture unused values in a field using the `",remain"` value - in the mapstructure tag. There is an example to showcase usage. -* Added `DecoderConfig` option to always squash embedded structs -* `json.Number` can decode into `uint` types -* Empty slices are preserved and not replaced with nil slices -* Fix panic that can occur in when decoding a map into a nil slice of structs -* Improved package documentation for godoc - ## 1.1.2 * Fix error when decode hook decodes interface implementation into interface diff --git a/vendor/github.com/mitchellh/mapstructure/decode_hooks.go b/vendor/github.com/mitchellh/mapstructure/decode_hooks.go index 92e6f76ff..1f0abc65a 100644 --- a/vendor/github.com/mitchellh/mapstructure/decode_hooks.go +++ b/vendor/github.com/mitchellh/mapstructure/decode_hooks.go @@ -1,7 +1,6 @@ package mapstructure import ( - "encoding" "errors" "fmt" "net" @@ -17,11 +16,10 @@ func typedDecodeHook(h DecodeHookFunc) DecodeHookFunc { // Create variables here so we can reference them with the reflect pkg var f1 DecodeHookFuncType var f2 DecodeHookFuncKind - var f3 DecodeHookFuncValue // Fill in the variables into this interface and the rest is done // automatically using the reflect package. - potential := []interface{}{f1, f2, f3} + potential := []interface{}{f1, f2} v := reflect.ValueOf(h) vt := v.Type() @@ -40,15 +38,13 @@ func typedDecodeHook(h DecodeHookFunc) DecodeHookFunc { // that took reflect.Kind instead of reflect.Type. func DecodeHookExec( raw DecodeHookFunc, - from reflect.Value, to reflect.Value) (interface{}, error) { - + from reflect.Type, to reflect.Type, + data interface{}) (interface{}, error) { switch f := typedDecodeHook(raw).(type) { case DecodeHookFuncType: - return f(from.Type(), to.Type(), from.Interface()) + return f(from, to, data) case DecodeHookFuncKind: - return f(from.Kind(), to.Kind(), from.Interface()) - case DecodeHookFuncValue: - return f(from, to) + return f(from.Kind(), to.Kind(), data) default: return nil, errors.New("invalid decode hook signature") } @@ -60,16 +56,22 @@ func DecodeHookExec( // The composed funcs are called in order, with the result of the // previous transformation. func ComposeDecodeHookFunc(fs ...DecodeHookFunc) DecodeHookFunc { - return func(f reflect.Value, t reflect.Value) (interface{}, error) { + return func( + f reflect.Type, + t reflect.Type, + data interface{}) (interface{}, error) { var err error - var data interface{} - newFrom := f for _, f1 := range fs { - data, err = DecodeHookExec(f1, newFrom, t) + data, err = DecodeHookExec(f1, f, t, data) if err != nil { return nil, err } - newFrom = reflect.ValueOf(data) + + // Modify the from kind to be correct with the new data + f = nil + if val := reflect.ValueOf(data); val.IsValid() { + f = val.Type() + } } return data, nil @@ -213,44 +215,3 @@ func WeaklyTypedHook( return data, nil } - -func RecursiveStructToMapHookFunc() DecodeHookFunc { - return func(f reflect.Value, t reflect.Value) (interface{}, error) { - if f.Kind() != reflect.Struct { - return f.Interface(), nil - } - - var i interface{} = struct{}{} - if t.Type() != reflect.TypeOf(&i).Elem() { - return f.Interface(), nil - } - - m := make(map[string]interface{}) - t.Set(reflect.ValueOf(m)) - - return f.Interface(), nil - } -} - -// TextUnmarshallerHookFunc returns a DecodeHookFunc that applies -// strings to the UnmarshalText function, when the target type -// implements the encoding.TextUnmarshaler interface -func TextUnmarshallerHookFunc() DecodeHookFuncType { - return func( - f reflect.Type, - t reflect.Type, - data interface{}) (interface{}, error) { - if f.Kind() != reflect.String { - return data, nil - } - result := reflect.New(t).Interface() - unmarshaller, ok := result.(encoding.TextUnmarshaler) - if !ok { - return data, nil - } - if err := unmarshaller.UnmarshalText([]byte(data.(string))); err != nil { - return nil, err - } - return result, nil - } -} diff --git a/vendor/github.com/mitchellh/mapstructure/go.mod b/vendor/github.com/mitchellh/mapstructure/go.mod index a03ae9730..d2a712562 100644 --- a/vendor/github.com/mitchellh/mapstructure/go.mod +++ b/vendor/github.com/mitchellh/mapstructure/go.mod @@ -1,3 +1 @@ module github.com/mitchellh/mapstructure - -go 1.14 diff --git a/vendor/github.com/mitchellh/mapstructure/mapstructure.go b/vendor/github.com/mitchellh/mapstructure/mapstructure.go index 3643901f5..256ee63fb 100644 --- a/vendor/github.com/mitchellh/mapstructure/mapstructure.go +++ b/vendor/github.com/mitchellh/mapstructure/mapstructure.go @@ -1,161 +1,10 @@ -// Package mapstructure exposes functionality to convert one arbitrary -// Go type into another, typically to convert a map[string]interface{} -// into a native Go structure. +// Package mapstructure exposes functionality to convert an arbitrary +// map[string]interface{} into a native Go structure. // // The Go structure can be arbitrarily complex, containing slices, // other structs, etc. and the decoder will properly decode nested // maps and so on into the proper structures in the native Go struct. // See the examples to see what the decoder is capable of. -// -// The simplest function to start with is Decode. -// -// Field Tags -// -// When decoding to a struct, mapstructure will use the field name by -// default to perform the mapping. For example, if a struct has a field -// "Username" then mapstructure will look for a key in the source value -// of "username" (case insensitive). -// -// type User struct { -// Username string -// } -// -// You can change the behavior of mapstructure by using struct tags. -// The default struct tag that mapstructure looks for is "mapstructure" -// but you can customize it using DecoderConfig. -// -// Renaming Fields -// -// To rename the key that mapstructure looks for, use the "mapstructure" -// tag and set a value directly. For example, to change the "username" example -// above to "user": -// -// type User struct { -// Username string `mapstructure:"user"` -// } -// -// Embedded Structs and Squashing -// -// Embedded structs are treated as if they're another field with that name. -// By default, the two structs below are equivalent when decoding with -// mapstructure: -// -// type Person struct { -// Name string -// } -// -// type Friend struct { -// Person -// } -// -// type Friend struct { -// Person Person -// } -// -// This would require an input that looks like below: -// -// map[string]interface{}{ -// "person": map[string]interface{}{"name": "alice"}, -// } -// -// If your "person" value is NOT nested, then you can append ",squash" to -// your tag value and mapstructure will treat it as if the embedded struct -// were part of the struct directly. Example: -// -// type Friend struct { -// Person `mapstructure:",squash"` -// } -// -// Now the following input would be accepted: -// -// map[string]interface{}{ -// "name": "alice", -// } -// -// When decoding from a struct to a map, the squash tag squashes the struct -// fields into a single map. Using the example structs from above: -// -// Friend{Person: Person{Name: "alice"}} -// -// Will be decoded into a map: -// -// map[string]interface{}{ -// "name": "alice", -// } -// -// DecoderConfig has a field that changes the behavior of mapstructure -// to always squash embedded structs. -// -// Remainder Values -// -// If there are any unmapped keys in the source value, mapstructure by -// default will silently ignore them. You can error by setting ErrorUnused -// in DecoderConfig. If you're using Metadata you can also maintain a slice -// of the unused keys. -// -// You can also use the ",remain" suffix on your tag to collect all unused -// values in a map. The field with this tag MUST be a map type and should -// probably be a "map[string]interface{}" or "map[interface{}]interface{}". -// See example below: -// -// type Friend struct { -// Name string -// Other map[string]interface{} `mapstructure:",remain"` -// } -// -// Given the input below, Other would be populated with the other -// values that weren't used (everything but "name"): -// -// map[string]interface{}{ -// "name": "bob", -// "address": "123 Maple St.", -// } -// -// Omit Empty Values -// -// When decoding from a struct to any other value, you may use the -// ",omitempty" suffix on your tag to omit that value if it equates to -// the zero value. The zero value of all types is specified in the Go -// specification. -// -// For example, the zero type of a numeric type is zero ("0"). If the struct -// field value is zero and a numeric type, the field is empty, and it won't -// be encoded into the destination type. -// -// type Source { -// Age int `mapstructure:",omitempty"` -// } -// -// Unexported fields -// -// Since unexported (private) struct fields cannot be set outside the package -// where they are defined, the decoder will simply skip them. -// -// For this output type definition: -// -// type Exported struct { -// private string // this unexported field will be skipped -// Public string -// } -// -// Using this map as input: -// -// map[string]interface{}{ -// "private": "I will be ignored", -// "Public": "I made it through!", -// } -// -// The following struct will be decoded: -// -// type Exported struct { -// private: "" // field is left with an empty string (zero value) -// Public: "I made it through!" -// } -// -// Other Configuration -// -// mapstructure is highly configurable. See the DecoderConfig struct -// for other features and options that are supported. package mapstructure import ( @@ -172,11 +21,10 @@ import ( // data transformations. See "DecodeHook" in the DecoderConfig // struct. // -// The type must be one of DecodeHookFuncType, DecodeHookFuncKind, or -// DecodeHookFuncValue. -// Values are a superset of Types (Values can return types), and Types are a -// superset of Kinds (Types can return Kinds) and are generally a richer thing -// to use, but Kinds are simpler if you only need those. +// The type should be DecodeHookFuncType or DecodeHookFuncKind. +// Either is accepted. Types are a superset of Kinds (Types can return +// Kinds) and are generally a richer thing to use, but Kinds are simpler +// if you only need those. // // The reason DecodeHookFunc is multi-typed is for backwards compatibility: // we started with Kinds and then realized Types were the better solution, @@ -192,22 +40,15 @@ type DecodeHookFuncType func(reflect.Type, reflect.Type, interface{}) (interface // source and target types. type DecodeHookFuncKind func(reflect.Kind, reflect.Kind, interface{}) (interface{}, error) -// DecodeHookFuncRaw is a DecodeHookFunc which has complete access to both the source and target -// values. -type DecodeHookFuncValue func(from reflect.Value, to reflect.Value) (interface{}, error) - // DecoderConfig is the configuration that is used to create a new decoder // and allows customization of various aspects of decoding. type DecoderConfig struct { // DecodeHook, if set, will be called before any decoding and any // type conversion (if WeaklyTypedInput is on). This lets you modify - // the values before they're set down onto the resulting struct. The - // DecodeHook is called for every map and value in the input. This means - // that if a struct has embedded fields with squash tags the decode hook - // is called only once with all of the input data, not once for each - // embedded struct. + // the values before they're set down onto the resulting struct. // - // If an error is returned, the entire decode will fail with that error. + // If an error is returned, the entire decode will fail with that + // error. DecodeHook DecodeHookFunc // If ErrorUnused is true, then it is an error for there to exist @@ -239,14 +80,6 @@ type DecoderConfig struct { // WeaklyTypedInput bool - // Squash will squash embedded structs. A squash tag may also be - // added to an individual struct field using a tag. For example: - // - // type Parent struct { - // Child `mapstructure:",squash"` - // } - Squash bool - // Metadata is the struct that will contain extra metadata about // the decoding. If this is nil, then no metadata will be tracked. Metadata *Metadata @@ -428,7 +261,9 @@ func (d *Decoder) decode(name string, input interface{}, outVal reflect.Value) e if d.config.DecodeHook != nil { // We have a DecodeHook, so let's pre-process the input. var err error - input, err = DecodeHookExec(d.config.DecodeHook, inputVal, outVal) + input, err = DecodeHookExec( + d.config.DecodeHook, + inputVal.Type(), outVal.Type(), input) if err != nil { return fmt.Errorf("error decoding '%s': %s", name, err) } @@ -436,7 +271,6 @@ func (d *Decoder) decode(name string, input interface{}, outVal reflect.Value) e var err error outputKind := getKind(outVal) - addMetaKey := true switch outputKind { case reflect.Bool: err = d.decodeBool(name, input, outVal) @@ -455,7 +289,7 @@ func (d *Decoder) decode(name string, input interface{}, outVal reflect.Value) e case reflect.Map: err = d.decodeMap(name, input, outVal) case reflect.Ptr: - addMetaKey, err = d.decodePtr(name, input, outVal) + err = d.decodePtr(name, input, outVal) case reflect.Slice: err = d.decodeSlice(name, input, outVal) case reflect.Array: @@ -469,7 +303,7 @@ func (d *Decoder) decode(name string, input interface{}, outVal reflect.Value) e // If we reached here, then we successfully decoded SOMETHING, so // mark the key as used if we're tracking metainput. - if addMetaKey && d.config.Metadata != nil && name != "" { + if d.config.Metadata != nil && name != "" { d.config.Metadata.Keys = append(d.config.Metadata.Keys, name) } @@ -480,34 +314,7 @@ func (d *Decoder) decode(name string, input interface{}, outVal reflect.Value) e // value to "data" of that type. func (d *Decoder) decodeBasic(name string, data interface{}, val reflect.Value) error { if val.IsValid() && val.Elem().IsValid() { - elem := val.Elem() - - // If we can't address this element, then its not writable. Instead, - // we make a copy of the value (which is a pointer and therefore - // writable), decode into that, and replace the whole value. - copied := false - if !elem.CanAddr() { - copied = true - - // Make *T - copy := reflect.New(elem.Type()) - - // *T = elem - copy.Elem().Set(elem) - - // Set elem so we decode into it - elem = copy - } - - // Decode. If we have an error then return. We also return right - // away if we're not a copy because that means we decoded directly. - if err := d.decode(name, data, elem); err != nil || !copied { - return err - } - - // If we're a copy, we need to set te final result - val.Set(elem.Elem()) - return nil + return d.decode(name, data, val.Elem()) } dataVal := reflect.ValueOf(data) @@ -579,8 +386,8 @@ func (d *Decoder) decodeString(name string, data interface{}, val reflect.Value) if !converted { return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", - name, val.Type(), dataVal.Type(), data) + "'%s' expected type '%s', got unconvertible type '%s'", + name, val.Type(), dataVal.Type()) } return nil @@ -605,12 +412,7 @@ func (d *Decoder) decodeInt(name string, data interface{}, val reflect.Value) er val.SetInt(0) } case dataKind == reflect.String && d.config.WeaklyTypedInput: - str := dataVal.String() - if str == "" { - str = "0" - } - - i, err := strconv.ParseInt(str, 0, val.Type().Bits()) + i, err := strconv.ParseInt(dataVal.String(), 0, val.Type().Bits()) if err == nil { val.SetInt(i) } else { @@ -626,8 +428,8 @@ func (d *Decoder) decodeInt(name string, data interface{}, val reflect.Value) er val.SetInt(i) default: return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", - name, val.Type(), dataVal.Type(), data) + "'%s' expected type '%s', got unconvertible type '%s'", + name, val.Type(), dataVal.Type()) } return nil @@ -636,7 +438,6 @@ func (d *Decoder) decodeInt(name string, data interface{}, val reflect.Value) er func (d *Decoder) decodeUint(name string, data interface{}, val reflect.Value) error { dataVal := reflect.Indirect(reflect.ValueOf(data)) dataKind := getKind(dataVal) - dataType := dataVal.Type() switch { case dataKind == reflect.Int: @@ -662,33 +463,16 @@ func (d *Decoder) decodeUint(name string, data interface{}, val reflect.Value) e val.SetUint(0) } case dataKind == reflect.String && d.config.WeaklyTypedInput: - str := dataVal.String() - if str == "" { - str = "0" - } - - i, err := strconv.ParseUint(str, 0, val.Type().Bits()) + i, err := strconv.ParseUint(dataVal.String(), 0, val.Type().Bits()) if err == nil { val.SetUint(i) } else { return fmt.Errorf("cannot parse '%s' as uint: %s", name, err) } - case dataType.PkgPath() == "encoding/json" && dataType.Name() == "Number": - jn := data.(json.Number) - i, err := jn.Int64() - if err != nil { - return fmt.Errorf( - "error decoding json.Number into %s: %s", name, err) - } - if i < 0 && !d.config.WeaklyTypedInput { - return fmt.Errorf("cannot parse '%s', %d overflows uint", - name, i) - } - val.SetUint(uint64(i)) default: return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", - name, val.Type(), dataVal.Type(), data) + "'%s' expected type '%s', got unconvertible type '%s'", + name, val.Type(), dataVal.Type()) } return nil @@ -718,8 +502,8 @@ func (d *Decoder) decodeBool(name string, data interface{}, val reflect.Value) e } default: return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", - name, val.Type(), dataVal.Type(), data) + "'%s' expected type '%s', got unconvertible type '%s'", + name, val.Type(), dataVal.Type()) } return nil @@ -744,12 +528,7 @@ func (d *Decoder) decodeFloat(name string, data interface{}, val reflect.Value) val.SetFloat(0) } case dataKind == reflect.String && d.config.WeaklyTypedInput: - str := dataVal.String() - if str == "" { - str = "0" - } - - f, err := strconv.ParseFloat(str, val.Type().Bits()) + f, err := strconv.ParseFloat(dataVal.String(), val.Type().Bits()) if err == nil { val.SetFloat(f) } else { @@ -765,8 +544,8 @@ func (d *Decoder) decodeFloat(name string, data interface{}, val reflect.Value) val.SetFloat(i) default: return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", - name, val.Type(), dataVal.Type(), data) + "'%s' expected type '%s', got unconvertible type '%s'", + name, val.Type(), dataVal.Type()) } return nil @@ -817,7 +596,7 @@ func (d *Decoder) decodeMapFromSlice(name string, dataVal reflect.Value, val ref for i := 0; i < dataVal.Len(); i++ { err := d.decode( - name+"["+strconv.Itoa(i)+"]", + fmt.Sprintf("%s[%d]", name, i), dataVal.Index(i).Interface(), val) if err != nil { return err @@ -850,7 +629,7 @@ func (d *Decoder) decodeMapFromMap(name string, dataVal reflect.Value, val refle } for _, k := range dataVal.MapKeys() { - fieldName := name + "[" + k.String() + "]" + fieldName := fmt.Sprintf("%s[%s]", name, k) // First decode the key into the proper type currentKey := reflect.Indirect(reflect.New(valKeyType)) @@ -899,40 +678,27 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re } tagValue := f.Tag.Get(d.config.TagName) - keyName := f.Name - - // If Squash is set in the config, we squash the field down. - squash := d.config.Squash && v.Kind() == reflect.Struct && f.Anonymous + tagParts := strings.Split(tagValue, ",") // Determine the name of the key in the map - if index := strings.Index(tagValue, ","); index != -1 { - if tagValue[:index] == "-" { - continue - } - // If "omitempty" is specified in the tag, it ignores empty values. - if strings.Index(tagValue[index+1:], "omitempty") != -1 && isEmptyValue(v) { + keyName := f.Name + if tagParts[0] != "" { + if tagParts[0] == "-" { continue } + keyName = tagParts[0] + } - // If "squash" is specified in the tag, we squash the field down. - squash = !squash && strings.Index(tagValue[index+1:], "squash") != -1 - if squash { - // When squashing, the embedded type can be a pointer to a struct. - if v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Struct { - v = v.Elem() - } - - // The final type must be a struct - if v.Kind() != reflect.Struct { - return fmt.Errorf("cannot squash non-struct type '%s'", v.Type()) - } - } - keyName = tagValue[:index] - } else if len(tagValue) > 0 { - if tagValue == "-" { - continue + // If "squash" is specified in the tag, we squash the field down. + squash := false + for _, tag := range tagParts[1:] { + if tag == "squash" { + squash = true + break } - keyName = tagValue + } + if squash && v.Kind() != reflect.Struct { + return fmt.Errorf("cannot squash non-struct type '%s'", v.Type()) } switch v.Kind() { @@ -947,22 +713,11 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re mType := reflect.MapOf(vKeyType, vElemType) vMap := reflect.MakeMap(mType) - // Creating a pointer to a map so that other methods can completely - // overwrite the map if need be (looking at you decodeMapFromMap). The - // indirection allows the underlying map to be settable (CanSet() == true) - // where as reflect.MakeMap returns an unsettable map. - addrVal := reflect.New(vMap.Type()) - reflect.Indirect(addrVal).Set(vMap) - - err := d.decode(keyName, x.Interface(), reflect.Indirect(addrVal)) + err := d.decode(keyName, x.Interface(), vMap) if err != nil { return err } - // the underlying map may have been completely overwritten so pull - // it indirectly out of the enclosing value. - vMap = reflect.Indirect(addrVal) - if squash { for _, k := range vMap.MapKeys() { valMap.SetMapIndex(k, vMap.MapIndex(k)) @@ -983,7 +738,7 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re return nil } -func (d *Decoder) decodePtr(name string, data interface{}, val reflect.Value) (bool, error) { +func (d *Decoder) decodePtr(name string, data interface{}, val reflect.Value) error { // If the input data is nil, then we want to just set the output // pointer to be nil as well. isNil := data == nil @@ -1004,7 +759,7 @@ func (d *Decoder) decodePtr(name string, data interface{}, val reflect.Value) (b val.Set(nilValue) } - return true, nil + return nil } // Create an element of the concrete (non pointer) type and decode @@ -1018,16 +773,16 @@ func (d *Decoder) decodePtr(name string, data interface{}, val reflect.Value) (b } if err := d.decode(name, data, reflect.Indirect(realVal)); err != nil { - return false, err + return err } val.Set(realVal) } else { if err := d.decode(name, data, reflect.Indirect(val)); err != nil { - return false, err + return err } } - return false, nil + return nil } func (d *Decoder) decodeFunc(name string, data interface{}, val reflect.Value) error { @@ -1036,8 +791,8 @@ func (d *Decoder) decodeFunc(name string, data interface{}, val reflect.Value) e dataVal := reflect.Indirect(reflect.ValueOf(data)) if val.Type() != dataVal.Type() { return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", - name, val.Type(), dataVal.Type(), data) + "'%s' expected type '%s', got unconvertible type '%s'", + name, val.Type(), dataVal.Type()) } val.Set(dataVal) return nil @@ -1050,8 +805,8 @@ func (d *Decoder) decodeSlice(name string, data interface{}, val reflect.Value) valElemType := valType.Elem() sliceType := reflect.SliceOf(valElemType) - // If we have a non array/slice type then we first attempt to convert. - if dataValKind != reflect.Array && dataValKind != reflect.Slice { + valSlice := val + if valSlice.IsNil() || d.config.ZeroFields { if d.config.WeaklyTypedInput { switch { // Slice and array we use the normal logic @@ -1078,17 +833,18 @@ func (d *Decoder) decodeSlice(name string, data interface{}, val reflect.Value) } } - return fmt.Errorf( - "'%s': source data must be an array or slice, got %s", name, dataValKind) - } + // Check input type + if dataValKind != reflect.Array && dataValKind != reflect.Slice { + return fmt.Errorf( + "'%s': source data must be an array or slice, got %s", name, dataValKind) - // If the input value is nil, then don't allocate since empty != nil - if dataVal.IsNil() { - return nil - } + } + + // If the input value is empty, then don't allocate since non-nil != nil + if dataVal.Len() == 0 { + return nil + } - valSlice := val - if valSlice.IsNil() || d.config.ZeroFields { // Make a new slice to hold our result, same size as the original data. valSlice = reflect.MakeSlice(sliceType, dataVal.Len(), dataVal.Len()) } @@ -1103,7 +859,7 @@ func (d *Decoder) decodeSlice(name string, data interface{}, val reflect.Value) } currentField := valSlice.Index(i) - fieldName := name + "[" + strconv.Itoa(i) + "]" + fieldName := fmt.Sprintf("%s[%d]", name, i) if err := d.decode(fieldName, currentData, currentField); err != nil { errors = appendErrors(errors, err) } @@ -1170,7 +926,7 @@ func (d *Decoder) decodeArray(name string, data interface{}, val reflect.Value) currentData := dataVal.Index(i).Interface() currentField := valArray.Index(i) - fieldName := name + "[" + strconv.Itoa(i) + "]" + fieldName := fmt.Sprintf("%s[%d]", name, i) if err := d.decode(fieldName, currentData, currentField); err != nil { errors = appendErrors(errors, err) } @@ -1206,23 +962,13 @@ func (d *Decoder) decodeStruct(name string, data interface{}, val reflect.Value) // Not the most efficient way to do this but we can optimize later if // we want to. To convert from struct to struct we go to map first // as an intermediary. - - // Make a new map to hold our result - mapType := reflect.TypeOf((map[string]interface{})(nil)) - mval := reflect.MakeMap(mapType) - - // Creating a pointer to a map so that other methods can completely - // overwrite the map if need be (looking at you decodeMapFromMap). The - // indirection allows the underlying map to be settable (CanSet() == true) - // where as reflect.MakeMap returns an unsettable map. - addrVal := reflect.New(mval.Type()) - - reflect.Indirect(addrVal).Set(mval) - if err := d.decodeMapFromStruct(name, dataVal, reflect.Indirect(addrVal), mval); err != nil { + m := make(map[string]interface{}) + mval := reflect.Indirect(reflect.ValueOf(&m)) + if err := d.decodeMapFromStruct(name, dataVal, mval, mval); err != nil { return err } - result := d.decodeStructFromMap(name, reflect.Indirect(addrVal), val) + result := d.decodeStructFromMap(name, mval, val) return result default: @@ -1259,11 +1005,6 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e field reflect.StructField val reflect.Value } - - // remainField is set to a valid field set with the "remain" tag if - // we are keeping track of remaining values. - var remainField *field - fields := []field{} for len(structs) > 0 { structVal := structs[0] @@ -1273,47 +1014,30 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e for i := 0; i < structType.NumField(); i++ { fieldType := structType.Field(i) - fieldVal := structVal.Field(i) - if fieldVal.Kind() == reflect.Ptr && fieldVal.Elem().Kind() == reflect.Struct { - // Handle embedded struct pointers as embedded structs. - fieldVal = fieldVal.Elem() - } + fieldKind := fieldType.Type.Kind() // If "squash" is specified in the tag, we squash the field down. - squash := d.config.Squash && fieldVal.Kind() == reflect.Struct && fieldType.Anonymous - remain := false - - // We always parse the tags cause we're looking for other tags too + squash := false tagParts := strings.Split(fieldType.Tag.Get(d.config.TagName), ",") for _, tag := range tagParts[1:] { if tag == "squash" { squash = true break } - - if tag == "remain" { - remain = true - break - } } if squash { - if fieldVal.Kind() != reflect.Struct { + if fieldKind != reflect.Struct { errors = appendErrors(errors, - fmt.Errorf("%s: unsupported type for squash: %s", fieldType.Name, fieldVal.Kind())) + fmt.Errorf("%s: unsupported type for squash: %s", fieldType.Name, fieldKind)) } else { - structs = append(structs, fieldVal) + structs = append(structs, structVal.FieldByName(fieldType.Name)) } continue } - // Build our field - if remain { - remainField = &field{fieldType, fieldVal} - } else { - // Normal struct field, store it away - fields = append(fields, field{fieldType, fieldVal}) - } + // Normal struct field, store it away + fields = append(fields, field{fieldType, structVal.Field(i)}) } } @@ -1354,6 +1078,9 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e } } + // Delete the key we're using from the unused map so we stop tracking + delete(dataValKeysUnused, rawMapKey.Interface()) + if !fieldValue.IsValid() { // This should never happen panic("field is not valid") @@ -1365,13 +1092,10 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e continue } - // Delete the key we're using from the unused map so we stop tracking - delete(dataValKeysUnused, rawMapKey.Interface()) - // If the name is empty string, then we're at the root, and we // don't dot-join the fields. if name != "" { - fieldName = name + "." + fieldName + fieldName = fmt.Sprintf("%s.%s", name, fieldName) } if err := d.decode(fieldName, rawMapVal.Interface(), fieldValue); err != nil { @@ -1379,25 +1103,6 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e } } - // If we have a "remain"-tagged field and we have unused keys then - // we put the unused keys directly into the remain field. - if remainField != nil && len(dataValKeysUnused) > 0 { - // Build a map of only the unused values - remain := map[interface{}]interface{}{} - for key := range dataValKeysUnused { - remain[key] = dataVal.MapIndex(reflect.ValueOf(key)).Interface() - } - - // Decode it as-if we were just decoding this map onto our map. - if err := d.decodeMap(name, remain, remainField.val); err != nil { - errors = appendErrors(errors, err) - } - - // Set the map to nil so we have none so that the next check will - // not error (ErrorUnused) - dataValKeysUnused = nil - } - if d.config.ErrorUnused && len(dataValKeysUnused) > 0 { keys := make([]string, 0, len(dataValKeysUnused)) for rawKey := range dataValKeysUnused { @@ -1418,7 +1123,7 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e for rawKey := range dataValKeysUnused { key := rawKey.(string) if name != "" { - key = name + "." + key + key = fmt.Sprintf("%s.%s", name, key) } d.config.Metadata.Unused = append(d.config.Metadata.Unused, key) @@ -1428,24 +1133,6 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e return nil } -func isEmptyValue(v reflect.Value) bool { - switch getKind(v) { - case reflect.Array, reflect.Map, reflect.Slice, reflect.String: - return v.Len() == 0 - case reflect.Bool: - return !v.Bool() - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return v.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return v.Uint() == 0 - case reflect.Float32, reflect.Float64: - return v.Float() == 0 - case reflect.Interface, reflect.Ptr: - return v.IsNil() - } - return false -} - func getKind(val reflect.Value) reflect.Kind { kind := val.Kind() diff --git a/vendor/gopkg.in/auth0.v5/.gitignore b/vendor/gopkg.in/auth0.v5/.gitignore index 691c71d35..f5a19a3ce 100644 --- a/vendor/gopkg.in/auth0.v5/.gitignore +++ b/vendor/gopkg.in/auth0.v5/.gitignore @@ -38,4 +38,7 @@ vendor/ ### VisualStudioCode Patch ### # Ignore all local history of files .history -.ionide \ No newline at end of file +.ionide + +### Local .env file +.env diff --git a/vendor/gopkg.in/auth0.v5/CHANGELOG.md b/vendor/gopkg.in/auth0.v5/CHANGELOG.md index 6e4e43abc..d591fd57c 100644 --- a/vendor/gopkg.in/auth0.v5/CHANGELOG.md +++ b/vendor/gopkg.in/auth0.v5/CHANGELOG.md @@ -1,3 +1,47 @@ +## v5.16.0 +* `management.Connection`: Add support for Google Apps enterprise connection ([#212](https://github.com/go-auth0/auth0/pull/212)) + +## v5.15.0 +* `management.Guardian`: Fixed minor bug when unmarshalling Policy string array ([#211](https://github.com/go-auth0/auth0/pull/211)) + +NOTES: + +* Added support for .env config file support ([#210](https://github.com/go-auth0/auth0/pull/210)) + +## v5.14.1 +* `management.Connection`: Add support for Auth0 SAML connection entityId option ([#209](https://github.com/go-auth0/auth0/pull/209)) + +## v5.14.0 +* `management.SigningKey`: Add support for listing, reading, rotating and revoking an Auth0 Tenant's signing key ([#191](https://github.com/go-auth0/auth0/pull/191)) +* `management.Grant`: Support pagination response when listing Grants ([#205](https://github.com/go-auth0/auth0/pull/205)) +* `management.Guardian`: Support to create a MFA enrollment ticket ([#207](https://github.com/go-auth0/auth0/pull/207)) +* `management.User`: Support to retrieve blocked IP addresses & unblock users using username, phone number or email ([#208](https://github.com/go-auth0/auth0/pull/208)) +* `management.Connection`: Support deny list (non persistent attributes) of attributes Auth0 stores per connection object ([#203](https://github.com/go-auth0/auth0/pull/203)) + +## v5.13.0 +* `management.ConnectionOptionsOIDC`: Add `SetUserAttributes` to OIDC Strategy + +## v5.12.0 +* `management.Connection`: Change Metadata property to be string map ([#160](https://github.com/go-auth0/auth0/pull/160)) +* `management.Connection`: Add Auth0 managed `ProvisioningTicketUrl to root connection object ([#201](https://github.com/go-auth0/auth0/pull/201)) +* `management.ConnectionOptions`: Adds missing AzureAD connection `TrustEmailVerified` option ([#198](https://github.com/go-auth0/auth0/pull/198)) +* `management.ConnectionOptions`: Add missing user fields provided by Twitter ([#197](https://github.com/go-auth0/auth0/pull/197)) +* `management.Guardian`: Add MFA Enrollment to Guardian ([#157](https://github.com/go-auth0/auth0/pull/157)) +* `management.Guardian`: Extend MFA SMS Providers ([#200](https://github.com/go-auth0/auth0/pull/200)) +* `management.Log`: Add description field to Logs ([#188](https://github.com/go-auth0/auth0/pull/188)) +* `management.Prompt`: Adds `identifier_first` to New Universal Login Prompt ([#187](https://github.com/go-auth0/auth0/pull/187)) +* `management.UserIdentity`: Add `AccessTokenSecret` to User Identity ([#196](https://github.com/go-auth0/auth0/pull/196)) +* `management.UserIdentity`: Add MFA Enrollments for a User ([#157](https://github.com/go-auth0/auth0/pull/157)) + +## v5.11.0 +* `management.ConnectionOptions`: Adds SetUserAttributes to ConnectionOptions to connections ([#194](https://github.com/go-auth0/auth0/pull/194)) + +## v5.10.0 +* `management.ConnectionOptions`: Adds set_user_root_attributes to more connections ([#192](https://github.com/go-auth0/auth0/pull/192)) + +## v5.9.0 +* `management.ConnectionManager`: Return nil when ConnectionManager.ReadByName() name field is empty ([#186](https://github.com/go-auth0/auth0/pull/186)) + ## v5.8.0 * `management.Ticket`: Add field `IncludeEmailInRedirect` ([#180](https://github.com/go-auth0/auth0/pull/180)) @@ -97,4 +141,4 @@ ## v4.0.0 -* **Breaking Change:** `Connection.Options` is now an `interface{}` accepting different types depending on the strategy. \ No newline at end of file +* **Breaking Change:** `Connection.Options` is now an `interface{}` accepting different types depending on the strategy. diff --git a/vendor/gopkg.in/auth0.v5/README.md b/vendor/gopkg.in/auth0.v5/README.md index 78e5cbc23..7e615f8ed 100644 --- a/vendor/gopkg.in/auth0.v5/README.md +++ b/vendor/gopkg.in/auth0.v5/README.md @@ -1,13 +1,13 @@ # Auth0 Go SDK -[![GoDoc](https://godoc.org/gopkg.in/auth0.v5?status.svg)](https://godoc.org/gopkg.in/auth0.v5) +[![Go Reference](https://pkg.go.dev/badge/gopkg.in/auth0.v5.svg)](https://pkg.go.dev/gopkg.in/auth0.v5) [![Build](https://github.com/go-auth0/auth0/workflows/Build/badge.svg)](https://github.com/go-auth0/auth0/actions?query=branch%3Amaster) [![Maintainability](https://api.codeclimate.com/v1/badges/bf038abb77ffb7c94cde/maintainability)](https://codeclimate.com/github/go-auth0/auth0/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/bf038abb77ffb7c94cde/test_coverage)](https://codeclimate.com/github/go-auth0/auth0/test_coverage) ## Documentation -Reference documentation can be found at [godoc.org](https://godoc.org/gopkg.in/auth0.v1). For more information about [Auth0](http://auth0.com/) please visit the [Auth0 Docs](http://docs.auth0.com/) page. +Reference documentation can be found at [pkg.go.dev](https://pkg.go.dev/gopkg.in/auth0.v5). For more information about [Auth0](http://auth0.com/) please visit the [Auth0 Docs](http://docs.auth0.com/) page. ## Management API @@ -49,6 +49,7 @@ fmt.Printf("Created client %s\n", c.ClientID) The following Auth0 resources are supported: +- [ ] [Actions](https://auth0.com/docs/api/management/v2/#!/Actions/get_actions) - [x] [Branding](https://auth0.com/docs/api/management/v2/#!/Branding/get_branding) - [x] [Clients (Applications)](https://auth0.com/docs/api/management/v2#!/Clients/get_clients) - [x] [Client Grants](https://auth0.com/docs/api/management/v2#!/Client_Grants/get_client_grants) @@ -60,6 +61,7 @@ The following Auth0 resources are supported: - [x] [Hook Secrets](https://auth0.com/docs/api/management/v2/#!/Hooks/get_secrets) - [x] [Log Streams](https://auth0.com/docs/api/management/v2#!/Log_Streams/get_log_streams) - [x] [Logs](https://auth0.com/docs/api/management/v2#!/Logs/get_logs) +- [ ] [Organizations](https://auth0.com/docs/api/management/v2#!/Organizations/get_organizations) - [x] [Prompts](https://auth0.com/docs/api/management/v2#!/Prompts/get_prompts) - [x] [Resource Servers (APIs)](https://auth0.com/docs/api/management/v2#!/Resource_Servers/get_resource_servers) - [x] [Roles](https://auth0.com/docs/api/management/v2#!/Roles) @@ -77,6 +79,18 @@ The following Auth0 resources are supported: - [x] [Tenants](https://auth0.com/docs/api/management/v2#!/Tenants/get_settings) - [ ] [Anomaly](https://auth0.com/docs/api/management/v2#!/Anomaly/get_ips_by_id) - [x] [Tickets](https://auth0.com/docs/api/management/v2#!/Tickets/post_email_verification) +- [x] [Signing Keys](https://auth0.com/docs/api/management/v2#!/Keys/get_signing_keys) + +### Tests + +The tests must run against an Auth0 tenant. They also need an [M2M app](https://auth0.com/docs/applications/set-up-an-application/register-machine-to-machine-applications) in that tenant that has been authorized to call the Management API. You can easily set one of these up by creating an [API Explorer Application](https://auth0.com/docs/tokens/management-api-access-tokens/create-and-authorize-a-machine-to-machine-application) in your tenant. + +Then simply create a local `.env` file with the following settings: + +* `AUTH0_DOMAIN`: The **Domain** of the M2M app +* `AUTH0_CLIENT_ID`: The **Client ID** of the M2M app +* `AUTH0_CLIENT_SECRET`: The **Client Secret** of the M2M app +* `AUTH0_DEBUG`: Set to `true` to call the Management API in debug mode, which dumps the HTTP requests and responses to the output ## What is Auth0? diff --git a/vendor/gopkg.in/auth0.v5/go.mod b/vendor/gopkg.in/auth0.v5/go.mod index 482831519..82fe05a88 100644 --- a/vendor/gopkg.in/auth0.v5/go.mod +++ b/vendor/gopkg.in/auth0.v5/go.mod @@ -7,8 +7,7 @@ require ( github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0 // indirect github.com/benbjohnson/clock v1.0.3 // indirect github.com/dustin/go-humanize v1.0.0 // indirect - github.com/mitchellh/mapstructure v1.4.1 + github.com/joho/godotenv v1.3.0 // indirect + github.com/stretchr/testify v1.4.0 golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 ) - -// replace gopkg.in/auth0.v5 => ./ diff --git a/vendor/gopkg.in/auth0.v5/go.sum b/vendor/gopkg.in/auth0.v5/go.sum index a44a864c1..620fec3c1 100644 --- a/vendor/gopkg.in/auth0.v5/go.sum +++ b/vendor/gopkg.in/auth0.v5/go.sum @@ -107,6 +107,8 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -115,8 +117,6 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= diff --git a/vendor/gopkg.in/auth0.v5/management/actions.go b/vendor/gopkg.in/auth0.v5/management/actions.go deleted file mode 100644 index dd9bddcd6..000000000 --- a/vendor/gopkg.in/auth0.v5/management/actions.go +++ /dev/null @@ -1,273 +0,0 @@ -package management - -import ( - "net/http" - "time" - - "github.com/mitchellh/mapstructure" -) - -type Action struct { - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - SupportedTriggers *[]Trigger `json:"supported_triggers,omitempty"` - - CreatedAt *time.Time `json:"created_at,omitempty"` - UpdatedAt *time.Time `json:"updated_at,omitempty"` - - // TODO: add required configuration / secrets -} - -type ActionExecutionResultResponse struct { - Error map[string]string `json:"error,omitempty"` - Logs *string `json:"logs,omitempty"` - Stats map[string]int64 `json:"stats,omitempty"` -} - -type ActionExecutionResult struct { - ActionName *string `json:"action_name,omitempty"` - BindingID *string `json:"binding_id,omitempty"` - VersionID *string `json:"version_id,omitempty"` - Error map[string]string `json:"error,omitempty"` - Response ActionExecutionResultResponse `json:"response,omitempty"` - - StartedAt *time.Time `json:"started_at,omitempty"` - EndedAt *time.Time `json:"ended_at,omitempty"` -} -type ActionExecution struct { - ID *string `json:"id"` - TriggerID TriggerID `json:"trigger_id"` - Status *string `json:"status"` - CreatedAt *time.Time `json:"created_at"` - UpdatedAt *time.Time `json:"updated_at"` - Results []*ActionExecutionResult `json:"results"` -} - -type VersionStatus string - -const ( - VersionStatusPending VersionStatus = "pending" - VersionStatusRetrying VersionStatus = "retrying" - VersionStatusBuilding VersionStatus = "building" - VersionStatusPackaged VersionStatus = "packaged" - VersionStatusBuilt VersionStatus = "built" -) - -type TriggerID string - -const ( - PostLogin TriggerID = "post-login" - ClientCredentials TriggerID = "client-credentials" - PreUserRegistration TriggerID = "pre-user-registration" - PostUserRegistration TriggerID = "post-user-registration" -) - -type ActionVersion struct { - ID string `json:"id,omitempty"` - Action *Action `json:"action,omitempty"` - Code string `json:"code,omitempty"` - Dependencies []Dependency `json:"dependencies"` - Deployed bool `json:"deployed,omitempty"` - Runtime string `json:"runtime,omitempty"` - Status VersionStatus `json:"status,omitempty"` - Number int `json:"number,omitempty"` - - CreatedAt *time.Time `json:"created_at,omitempty"` - UpdatedAt *time.Time `json:"updated_at,omitempty"` - - // TODO: maybe add errors? -} - -type Dependency struct { - Name string `json:"name"` - Version string `json:"version"` - RegistryURL string `json:"registry_url"` -} - -type Trigger struct { - ID *TriggerID `json:"id"` - Version *string `json:"version"` - URL *string `json:"url,omitempty"` -} - -type ActionList struct { - List - Actions []*Action `json:"actions"` -} - -type ActionVersionList struct { - List - Versions []*ActionVersion `json:"versions"` -} - -type ActionBinding struct { - ID *string `json:"id"` - TriggerID *TriggerID `json:"trigger_id,omitempty"` - Action *Action `json:"action,omitempty"` - CreatedAt *time.Time `json:"created_at,omitempty"` - UpdatedAt *time.Time `json:"updated_at,omitempty"` - DisplayName *string `json:"display_name,omitempty"` -} -type ActionBindingList struct { - List - Bindings []*ActionBinding `json:"bindings"` -} - -type Object map[string]interface{} - -type ActionManager struct { - *Management -} - -func newActionManager(m *Management) *ActionManager { - return &ActionManager{m} -} - -func applyActionsListDefaults(options []RequestOption) RequestOption { - return newRequestOption(func(r *http.Request) { - PerPage(50).apply(r) - for _, option := range options { - option.apply(r) - } - }) -} - -func (m *ActionManager) Create(a *Action) error { - return m.Request("POST", m.URI("actions", "actions"), a) -} - -func (m *ActionManager) Read(id string) (*Action, error) { - var a Action - err := m.Request("GET", m.URI("actions", "actions", id), &a) - return &a, err -} - -func (m *ActionManager) Update(id string, a *Action) error { - // We'll get a 400 if we try to send the following parameters as part - // of the payload. - a.ID = nil - a.CreatedAt = nil - a.UpdatedAt = nil - return m.Request("PATCH", m.URI("actions", "actions", id), a) -} - -func (m *ActionManager) Delete(id string, opts ...RequestOption) error { - return m.Request("DELETE", m.URI("actions", "actions", id), nil, opts...) -} - -// func WithTriggerID(id TriggerID) RequestOption { -// return func(v url.Values) { -// v.Set("triggerId", string(id)) -// } -// } - -func (m *ActionManager) List(opts ...RequestOption) (c *ActionList, err error) { - err = m.Request("GET", m.URI("actions", "actions"), &c, applyActionsListDefaults(opts)) - return -} - -type ActionExecutionManager struct { - *Management -} - -func newActionExecutionManager(m *Management) *ActionExecutionManager { - return &ActionExecutionManager{m} -} - -func (m *ActionExecutionManager) Read(id string) (*ActionExecution, error) { - var execution ActionExecution - err := m.Request("GET", m.URI("actions", "executions", id), &execution) - return &execution, err -} - -type ActionVersionManager struct { - *Management -} - -func newActionVersionManager(m *Management) *ActionVersionManager { - return &ActionVersionManager{m} -} - -func (m *ActionVersionManager) Create(actionID string, v *ActionVersion) error { - return m.Request("POST", m.URI("actions", "actions", actionID, "versions"), v) -} - -func (m *ActionVersionManager) UpsertDraft(actionID string, v *ActionVersion) error { - return m.Request("PATCH", m.URI("actions", "actions", actionID, "versions", "draft"), v) -} - -func (m *ActionVersionManager) ReadDraft(actionID string) (*ActionVersion, error) { - var v ActionVersion - err := m.Request("GET", m.URI("actions", "actions", actionID, "versions", "draft"), &v) - return &v, err -} - -func (m *ActionVersionManager) Read(actionID, id string) (*ActionVersion, error) { - var v ActionVersion - err := m.Request("GET", m.URI("actions", "actions", actionID, "versions", id), &v) - return &v, err -} - -func (m *ActionVersionManager) Delete(actionID, id string, opts ...RequestOption) error { - return m.Request("DELETE", m.URI("actions", "actions", actionID, "versions", id), nil, opts...) -} - -func (m *ActionVersionManager) List(actionID string, opts ...RequestOption) (c *ActionVersionList, err error) { - err = m.Request("GET", m.URI("actions", "actions", actionID, "versions"), &c, applyActionsListDefaults(opts)) - return -} - -// TODO(cyx): might call this `activate` instead later. Still fleshing out the -// name. -func (m *ActionVersionManager) Deploy(actionID, id string) (*ActionVersion, error) { - var v ActionVersion - err := m.Request("POST", m.URI("actions", "actions", actionID, "versions", id, "deploy"), &v) - return &v, err -} - -// TODO(cyx): consider how the `draft` test looks like. Will it just use -// `draft` in place of the ID? -func (m *ActionVersionManager) Test(actionID, id string, payload Object) (Object, error) { - v := Object{"payload": payload} - err := m.Request("POST", m.URI("actions", "actions", actionID, "versions", id, "test"), &v) - return v, err -} - -type ActionBindingManager struct { - *Management -} - -func newActionBindingManager(m *Management) *ActionBindingManager { - return &ActionBindingManager{m} -} - -func (m *ActionBindingManager) List(triggerID TriggerID, opts ...RequestOption) (c *ActionBindingList, err error) { - err = m.Request("GET", m.URI("actions", "triggers", string(triggerID), "bindings"), &c, applyActionsListDefaults(opts)) - return -} - -func (m *ActionBindingManager) Create(triggerID TriggerID, action *Action) (ab *ActionBinding, err error) { - v := Object{"action_id": action.ID, "display_name": action.Name} - if err = m.Request("POST", m.URI("actions", "triggers", string(triggerID), "bindings"), &v); err != nil { - return nil, err - } - - if err = mapstructure.Decode(v, &ab); err != nil { - return nil, err - } - - return ab, nil -} - -func (m *ActionBindingManager) Update(triggerID TriggerID, bindings []*ActionBinding) (list *ActionBindingList, err error) { - v := Object{"bindings": bindings} - if err = m.Request("PATCH", m.URI("actions", "triggers", string(triggerID), "bindings"), &v); err != nil { - return nil, err - } - - if err = mapstructure.Decode(v, &list); err != nil { - return nil, err - } - - return list, nil -} diff --git a/vendor/gopkg.in/auth0.v5/management/anomaly.go b/vendor/gopkg.in/auth0.v5/management/anomaly.go new file mode 100644 index 000000000..f81bdfb4e --- /dev/null +++ b/vendor/gopkg.in/auth0.v5/management/anomaly.go @@ -0,0 +1,49 @@ +package management + +import ( + "net/http" +) + +type AnomalyManager struct { + *Management +} + +func newAnomalyManager(m *Management) *AnomalyManager { + return &AnomalyManager{m} +} + +// 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 +func (m *AnomalyManager) CheckIP(ip string, opts ...RequestOption) (isBlocked bool, err error) { + req, err := m.NewRequest("GET", m.URI("anomaly", "blocks", "ips", ip), nil, opts...) + if err != nil { + return false, err + } + + res, err := m.Do(req) + if err != nil { + return false, err + } + + // 200: IP address specified is currently blocked. + if res.StatusCode == http.StatusOK { + return true, nil + } + + // 404: IP address specified is not currently blocked. + if res.StatusCode == http.StatusNotFound { + return false, nil + } + + return false, newError(res.Body) +} + +// 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 +func (m *AnomalyManager) UnblockIP(ip string, opts ...RequestOption) (err error) { + return m.Request("DELETE", m.URI("anomaly", "blocks", "ips", ip), nil, opts...) +} diff --git a/vendor/gopkg.in/auth0.v5/management/client.go b/vendor/gopkg.in/auth0.v5/management/client.go index b03e77db7..0ad363af5 100644 --- a/vendor/gopkg.in/auth0.v5/management/client.go +++ b/vendor/gopkg.in/auth0.v5/management/client.go @@ -1,5 +1,13 @@ package management +import ( + "encoding/json" + "fmt" + "strconv" + + "gopkg.in/auth0.v5" +) + type Client struct { // The name of the client Name *string `json:"name,omitempty"` @@ -88,7 +96,7 @@ type Client struct { type ClientJWTConfiguration struct { // The amount of seconds the JWT will be valid (affects exp claim) - LifetimeInSeconds *int `json:"lifetime_in_seconds,omitempty"` + LifetimeInSeconds *int `json:"-"` // True if the client secret is base64 encoded, false otherwise. Defaults to // true @@ -196,3 +204,56 @@ func (m *ClientManager) RotateSecret(id string, opts ...RequestOption) (c *Clien func (m *ClientManager) Delete(id string, opts ...RequestOption) error { return m.Request("DELETE", m.URI("clients", id), nil, opts...) } + +// UnmarshalJSON implements the json.Unmarshaler interface. +// +// It is required to handle the json field lifetime_in_seconds, which can either +// be an int, or a string in older tenants. +func (jc *ClientJWTConfiguration) UnmarshalJSON(b []byte) error { + type clientJWTConfiguration ClientJWTConfiguration + type clientJWTConfigurationWrapper struct { + *clientJWTConfiguration + RawLifetimeInSeconds interface{} `json:"lifetime_in_seconds,omitempty"` + } + + alias := &clientJWTConfigurationWrapper{(*clientJWTConfiguration)(jc), nil} + + err := json.Unmarshal(b, alias) + if err != nil { + return err + } + + unexpectedTypeError := fmt.Errorf("unexpected type for field lifetime_in_seconds") + + if alias.RawLifetimeInSeconds != nil { + switch rawLifetimeInSeconds := alias.RawLifetimeInSeconds.(type) { + case float64: + jc.LifetimeInSeconds = auth0.Int(int(rawLifetimeInSeconds)) + case string: + value, err := strconv.Atoi(rawLifetimeInSeconds) + if err != nil { + return unexpectedTypeError + } + jc.LifetimeInSeconds = &value + default: + return unexpectedTypeError + } + } + + return nil +} + +func (jc *ClientJWTConfiguration) MarshalJSON() ([]byte, error) { + type clientJWTConfiguration ClientJWTConfiguration + type clientJWTConfigurationWrapper struct { + *clientJWTConfiguration + RawLifetimeInSeconds interface{} `json:"lifetime_in_seconds,omitempty"` + } + + alias := &clientJWTConfigurationWrapper{(*clientJWTConfiguration)(jc), nil} + if jc.LifetimeInSeconds != nil { + alias.RawLifetimeInSeconds = jc.LifetimeInSeconds + } + + return json.Marshal(alias) +} diff --git a/vendor/gopkg.in/auth0.v5/management/connection.go b/vendor/gopkg.in/auth0.v5/management/connection.go index 8acd67f6a..c1bbe00c1 100644 --- a/vendor/gopkg.in/auth0.v5/management/connection.go +++ b/vendor/gopkg.in/auth0.v5/management/connection.go @@ -26,6 +26,7 @@ const ( ConnectionStrategyAD = "ad" ConnectionStrategyAzureAD = "waad" ConnectionStrategySAML = "samlp" + ConnectionStrategyGoogleApps = "google-apps" ) type Connection struct { @@ -70,7 +71,10 @@ type Connection struct { // connection name will be added as realm. Realms []interface{} `json:"realms,omitempty"` - Metadata *interface{} `json:"metadata,omitempty"` + Metadata map[string]string `json:"metadata,omitempty"` + + // Provisioning Ticket URL is Ticket URL for Active Directory/LDAP, etc. + ProvisioningTicketUrl *string `json:"provisioning_ticket_url,omitempty"` } func (c *Connection) MarshalJSON() ([]byte, error) { @@ -146,6 +150,8 @@ func (c *Connection) UnmarshalJSON(b []byte) error { v = &ConnectionOptionsAzureAD{} case ConnectionStrategySAML: v = &ConnectionOptionsSAML{} + case ConnectionStrategyGoogleApps: + v = &ConnectionOptionsGoogleApps{} default: v = make(map[string]interface{}) } @@ -205,6 +211,9 @@ type ConnectionOptions struct { Configuration map[string]interface{} `json:"configuration,omitempty"` StrategyVersion *int `json:"strategy_version,omitempty"` + + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` } type ConnectionOptionsGoogleOAuth2 struct { @@ -213,38 +222,39 @@ type ConnectionOptionsGoogleOAuth2 struct { AllowedAudiences []interface{} `json:"allowed_audiences,omitempty"` - Email *bool `json:"email,omitempty" scope:"email"` - Profile *bool `json:"profile,omitempty" scope:"profile"` - Contacts *bool `json:"contacts,omitempty" scope:"contacts"` - Blogger *bool `json:"blogger,omitempty" scope:"blogger"` - Calendar *bool `json:"calendar,omitempty" scope:"calendar"` - Gmail *bool `json:"gmail,omitempty" scope:"gmail"` - GooglePlus *bool `json:"google_plus,omitempty" scope:"google_plus"` - Orkut *bool `json:"orkut,omitempty" scope:"orkut"` - PicasaWeb *bool `json:"picasa_web,omitempty" scope:"picasa_web"` - Tasks *bool `json:"tasks,omitempty" scope:"tasks"` - Youtube *bool `json:"youtube,omitempty" scope:"youtube"` - AdsenseManagement *bool `json:"adsense_management,omitempty" scope:"adsense_management"` - GoogleAffiliateNetwork *bool `json:"google_affiliate_network,omitempty" scope:"google_affiliate_network"` - Analytics *bool `json:"analytics,omitempty" scope:"analytics"` - GoogleBooks *bool `json:"google_books,omitempty" scope:"google_books"` - GoogleCloudStorage *bool `json:"google_cloud_storage,omitempty" scope:"google_cloud_storage"` - ContentAPIForShopping *bool `json:"content_api_for_shopping,omitempty" scope:"content_api_for_shopping"` - ChromeWebStore *bool `json:"chrome_web_store,omitempty" scope:"chrome_web_store"` - DocumentList *bool `json:"document_list,omitempty" scope:"document_list"` - GoogleDrive *bool `json:"google_drive,omitempty" scope:"google_drive"` - GoogleDriveFiles *bool `json:"google_drive_files,omitempty" scope:"google_drive_files"` - LatitudeBest *bool `json:"latitude_best,omitempty" scope:"latitude_best"` - LatitudeCity *bool `json:"latitude_city,omitempty" scope:"latitude_city"` - Moderator *bool `json:"moderator,omitempty" scope:"moderator"` - Sites *bool `json:"sites,omitempty" scope:"sites"` - Spreadsheets *bool `json:"spreadsheets,omitempty" scope:"spreadsheets"` - URLShortener *bool `json:"url_shortener,omitempty" scope:"url_shortener"` - WebmasterTools *bool `json:"webmaster_tools,omitempty" scope:"webmaster_tools"` - Coordinate *bool `json:"coordinate,omitempty" scope:"coordinate"` - CoordinateReadonly *bool `json:"coordinate_readonly,omitempty" scope:"coordinate_readonly"` - - Scope []interface{} `json:"scope,omitempty"` + Email *bool `json:"email,omitempty" scope:"email"` + Profile *bool `json:"profile,omitempty" scope:"profile"` + Contacts *bool `json:"contacts,omitempty" scope:"contacts"` + Blogger *bool `json:"blogger,omitempty" scope:"blogger"` + Calendar *bool `json:"calendar,omitempty" scope:"calendar"` + Gmail *bool `json:"gmail,omitempty" scope:"gmail"` + GooglePlus *bool `json:"google_plus,omitempty" scope:"google_plus"` + Orkut *bool `json:"orkut,omitempty" scope:"orkut"` + PicasaWeb *bool `json:"picasa_web,omitempty" scope:"picasa_web"` + Tasks *bool `json:"tasks,omitempty" scope:"tasks"` + Youtube *bool `json:"youtube,omitempty" scope:"youtube"` + AdsenseManagement *bool `json:"adsense_management,omitempty" scope:"adsense_management"` + GoogleAffiliateNetwork *bool `json:"google_affiliate_network,omitempty" scope:"google_affiliate_network"` + Analytics *bool `json:"analytics,omitempty" scope:"analytics"` + GoogleBooks *bool `json:"google_books,omitempty" scope:"google_books"` + GoogleCloudStorage *bool `json:"google_cloud_storage,omitempty" scope:"google_cloud_storage"` + ContentAPIForShopping *bool `json:"content_api_for_shopping,omitempty" scope:"content_api_for_shopping"` + ChromeWebStore *bool `json:"chrome_web_store,omitempty" scope:"chrome_web_store"` + DocumentList *bool `json:"document_list,omitempty" scope:"document_list"` + GoogleDrive *bool `json:"google_drive,omitempty" scope:"google_drive"` + GoogleDriveFiles *bool `json:"google_drive_files,omitempty" scope:"google_drive_files"` + LatitudeBest *bool `json:"latitude_best,omitempty" scope:"latitude_best"` + LatitudeCity *bool `json:"latitude_city,omitempty" scope:"latitude_city"` + Moderator *bool `json:"moderator,omitempty" scope:"moderator"` + Sites *bool `json:"sites,omitempty" scope:"sites"` + Spreadsheets *bool `json:"spreadsheets,omitempty" scope:"spreadsheets"` + URLShortener *bool `json:"url_shortener,omitempty" scope:"url_shortener"` + WebmasterTools *bool `json:"webmaster_tools,omitempty" scope:"webmaster_tools"` + Coordinate *bool `json:"coordinate,omitempty" scope:"coordinate"` + CoordinateReadonly *bool `json:"coordinate_readonly,omitempty" scope:"coordinate_readonly"` + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` + Scope []interface{} `json:"scope,omitempty"` } func (c *ConnectionOptionsGoogleOAuth2) Scopes() []string { @@ -259,48 +269,49 @@ type ConnectionOptionsFacebook struct { ClientID *string `json:"client_id,omitempty"` ClientSecret *string `json:"client_secret,omitempty"` - AllowContextProfileField *bool `json:"allow_context_profile_field,omitempty"` - - Email *bool `json:"email,omitempty" scope:"email"` - GroupsAccessMemberInfo *bool `json:"groups_access_member_info,omitempty" scope:"groups_access_member_info"` - PublishToGroups *bool `json:"publish_to_groups,omitempty" scope:"publish_to_groups"` - UserAgeRange *bool `json:"user_age_range,omitempty" scope:"user_age_range"` - UserBirthday *bool `json:"user_birthday,omitempty" scope:"user_birthday"` - AdsManagement *bool `json:"ads_management,omitempty" scope:"ads_management"` - AdsRead *bool `json:"ads_read,omitempty" scope:"ads_read"` - ReadAudienceNetworkInsights *bool `json:"read_audience_network_insights,omitempty" scope:"read_audience_network_insights"` - ReadInsights *bool `json:"read_insights,omitempty" scope:"read_insights"` - ManageNotifications *bool `json:"manage_notifications,omitempty" scope:"manage_notifications"` - PublishActions *bool `json:"publish_actions,omitempty" scope:"publish_actions"` - ReadMailbox *bool `json:"read_mailbox,omitempty" scope:"read_mailbox"` - PublicProfile *bool `json:"public_profile,omitempty" scope:"public_profile"` - UserEvents *bool `json:"user_events,omitempty" scope:"user_events"` - UserFriends *bool `json:"user_friends,omitempty" scope:"user_friends"` - UserGender *bool `json:"user_gender,omitempty" scope:"user_gender"` - UserHometown *bool `json:"user_hometown,omitempty" scope:"user_hometown"` - UserLikes *bool `json:"user_likes,omitempty" scope:"user_likes"` - UserLink *bool `json:"user_link,omitempty" scope:"user_link"` - UserLocation *bool `json:"user_location,omitempty" scope:"user_location"` - UserPhotos *bool `json:"user_photos,omitempty" scope:"user_photos"` - UserPosts *bool `json:"user_posts,omitempty" scope:"user_posts"` - UserTaggedPlaces *bool `json:"user_tagged_places,omitempty" scope:"user_tagged_places"` - UserVideos *bool `json:"user_videos,omitempty" scope:"user_videos"` - BusinessManagement *bool `json:"business_management,omitempty" scope:"business_management"` - LeadsRetrieval *bool `json:"leads_retrieval,omitempty" scope:"leads_retrieval"` - ManagePages *bool `json:"manage_pages,omitempty" scope:"manage_pages"` - PagesManageCTA *bool `json:"pages_manage_cta,omitempty" scope:"pages_manage_cta"` - PagesManageInstantArticles *bool `json:"pages_manage_instant_articles,omitempty" scope:"pages_manage_instant_articles"` - PagesShowList *bool `json:"pages_show_list,omitempty" scope:"pages_show_list"` - PagesMessaging *bool `json:"pages_messaging,omitempty" scope:"pages_messaging"` - PagesMessagingPhoneNumber *bool `json:"pages_messaging_phone_number,omitempty" scope:"pages_messaging_phone_number"` - PagesMessagingSubscriptions *bool `json:"pages_messaging_subscriptions,omitempty" scope:"pages_messaging_subscriptions"` - PublishPages *bool `json:"publish_pages,omitempty" scope:"publish_pages"` - PublishVideo *bool `json:"publish_video,omitempty" scope:"publish_video"` - ReadPageMailboxes *bool `json:"read_page_mailboxes,omitempty" scope:"read_page_mailboxes"` - ReadStream *bool `json:"read_stream,omitempty" scope:"read_stream"` - UserGroups *bool `json:"user_groups,omitempty" scope:"user_groups"` - UserManagedGroups *bool `json:"user_managed_groups,omitempty" scope:"user_managed_groups"` - UserStatus *bool `json:"user_status,omitempty" scope:"user_status"` + AllowContextProfileField *bool `json:"allow_context_profile_field,omitempty"` + Email *bool `json:"email,omitempty" scope:"email"` + GroupsAccessMemberInfo *bool `json:"groups_access_member_info,omitempty" scope:"groups_access_member_info"` + PublishToGroups *bool `json:"publish_to_groups,omitempty" scope:"publish_to_groups"` + UserAgeRange *bool `json:"user_age_range,omitempty" scope:"user_age_range"` + UserBirthday *bool `json:"user_birthday,omitempty" scope:"user_birthday"` + AdsManagement *bool `json:"ads_management,omitempty" scope:"ads_management"` + AdsRead *bool `json:"ads_read,omitempty" scope:"ads_read"` + ReadAudienceNetworkInsights *bool `json:"read_audience_network_insights,omitempty" scope:"read_audience_network_insights"` + ReadInsights *bool `json:"read_insights,omitempty" scope:"read_insights"` + ManageNotifications *bool `json:"manage_notifications,omitempty" scope:"manage_notifications"` + PublishActions *bool `json:"publish_actions,omitempty" scope:"publish_actions"` + ReadMailbox *bool `json:"read_mailbox,omitempty" scope:"read_mailbox"` + PublicProfile *bool `json:"public_profile,omitempty" scope:"public_profile"` + UserEvents *bool `json:"user_events,omitempty" scope:"user_events"` + UserFriends *bool `json:"user_friends,omitempty" scope:"user_friends"` + UserGender *bool `json:"user_gender,omitempty" scope:"user_gender"` + UserHometown *bool `json:"user_hometown,omitempty" scope:"user_hometown"` + UserLikes *bool `json:"user_likes,omitempty" scope:"user_likes"` + UserLink *bool `json:"user_link,omitempty" scope:"user_link"` + UserLocation *bool `json:"user_location,omitempty" scope:"user_location"` + UserPhotos *bool `json:"user_photos,omitempty" scope:"user_photos"` + UserPosts *bool `json:"user_posts,omitempty" scope:"user_posts"` + UserTaggedPlaces *bool `json:"user_tagged_places,omitempty" scope:"user_tagged_places"` + UserVideos *bool `json:"user_videos,omitempty" scope:"user_videos"` + BusinessManagement *bool `json:"business_management,omitempty" scope:"business_management"` + LeadsRetrieval *bool `json:"leads_retrieval,omitempty" scope:"leads_retrieval"` + ManagePages *bool `json:"manage_pages,omitempty" scope:"manage_pages"` + PagesManageCTA *bool `json:"pages_manage_cta,omitempty" scope:"pages_manage_cta"` + PagesManageInstantArticles *bool `json:"pages_manage_instant_articles,omitempty" scope:"pages_manage_instant_articles"` + PagesShowList *bool `json:"pages_show_list,omitempty" scope:"pages_show_list"` + PagesMessaging *bool `json:"pages_messaging,omitempty" scope:"pages_messaging"` + PagesMessagingPhoneNumber *bool `json:"pages_messaging_phone_number,omitempty" scope:"pages_messaging_phone_number"` + PagesMessagingSubscriptions *bool `json:"pages_messaging_subscriptions,omitempty" scope:"pages_messaging_subscriptions"` + PublishPages *bool `json:"publish_pages,omitempty" scope:"publish_pages"` + PublishVideo *bool `json:"publish_video,omitempty" scope:"publish_video"` + ReadPageMailboxes *bool `json:"read_page_mailboxes,omitempty" scope:"read_page_mailboxes"` + ReadStream *bool `json:"read_stream,omitempty" scope:"read_stream"` + UserGroups *bool `json:"user_groups,omitempty" scope:"user_groups"` + UserManagedGroups *bool `json:"user_managed_groups,omitempty" scope:"user_managed_groups"` + UserStatus *bool `json:"user_status,omitempty" scope:"user_status"` + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` // Scope is a comma separated list of scopes. Scope *string `json:"scope,omitempty"` @@ -324,7 +335,9 @@ type ConnectionOptionsApple struct { Name *bool `json:"name,omitempty" scope:"name"` Email *bool `json:"email,omitempty" scope:"email"` - Scope *string `json:"scope,omitempty"` + Scope *string `json:"scope,omitempty"` + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` } func (c *ConnectionOptionsApple) Scopes() []string { @@ -347,7 +360,8 @@ type ConnectionOptionsLinkedin struct { Scope []interface{} `json:"scope,omitempty"` - SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` } func (c *ConnectionOptionsLinkedin) Scopes() []string { @@ -385,7 +399,8 @@ type ConnectionOptionsGitHub struct { Scope []interface{} `json:"scope,omitempty"` - SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` } func (c *ConnectionOptionsGitHub) Scopes() []string { @@ -404,8 +419,10 @@ type ConnectionOptionsEmail struct { AuthParams map[string]string `json:"authParams,omitempty"` - DisableSignup *bool `json:"disable_signup,omitempty"` - BruteForceProtection *bool `json:"brute_force_protection,omitempty"` + DisableSignup *bool `json:"disable_signup,omitempty"` + BruteForceProtection *bool `json:"brute_force_protection,omitempty"` + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` } type ConnectionOptionsEmailSettings struct { @@ -469,7 +486,8 @@ type ConnectionOptionsWindowsLive struct { Scope []interface{} `json:"scope,omitempty"` - SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` } func (c *ConnectionOptionsWindowsLive) Scopes() []string { @@ -488,8 +506,9 @@ type ConnectionOptionsSalesforce struct { Scope []interface{} `json:"scope,omitempty"` - CommunityBaseURL *string `json:"community_base_url,omitempty"` - SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + CommunityBaseURL *string `json:"community_base_url,omitempty"` + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` } func (c *ConnectionOptionsSalesforce) Scopes() []string { @@ -515,8 +534,10 @@ type ConnectionOptionsOIDC struct { Type *string `json:"type"` UserInfoEndpoint *string `json:"userinfo_endpoint"` TokenEndpoint *string `json:"token_endpoint"` + Scope *string `json:"scope,omitempty"` - Scope *string `json:"scope,omitempty"` + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` } func (c *ConnectionOptionsOIDC) Scopes() []string { @@ -543,12 +564,13 @@ func (c *ConnectionOptionsOIDC) SetScopes(enable bool, scopes ...string) { } type ConnectionOptionsOAuth2 struct { - ClientID *string `json:"client_id,omitempty"` - ClientSecret *string `json:"client_secret,omitempty"` - AuthorizationURL *string `json:"authorizationURL"` - TokenURL *string `json:"tokenURL"` - Scope *string `json:"scope,omitempty"` - + ClientID *string `json:"client_id,omitempty"` + ClientSecret *string `json:"client_secret,omitempty"` + AuthorizationURL *string `json:"authorizationURL"` + TokenURL *string `json:"tokenURL"` + Scope *string `json:"scope,omitempty"` + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` // Scripts for the connection // Allowed keys are: "fetchUserProfile" Scripts map[string]interface{} `json:"scripts,omitempty"` @@ -588,7 +610,8 @@ type ConnectionOptionsAD struct { DisableCache *bool `json:"disable_cache,omitempty"` BruteForceProtection *bool `json:"brute_force_protection,omitempty"` - SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` } type ConnectionOptionsAzureAD struct { @@ -619,6 +642,10 @@ type ConnectionOptionsAzureAD struct { IsSuspended *bool `json:"ext_is_suspended,omitempty" scope:"ext_is_suspended"` AgreedTerms *bool `json:"ext_agreed_terms,omitempty" scope:"ext_agreed_terms"` AssignedPlans *bool `json:"ext_assigned_plans,omitempty" scope:"ext_assigned_plans"` + + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + TrustEmailVerified *string `json:"should_trust_email_verified_connection,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` } func (c *ConnectionOptionsAzureAD) Scopes() []string { @@ -638,7 +665,8 @@ type ConnectionOptionsADFS struct { EnableUsersAPI *bool `json:"api_enable_users,omitempty"` // Set to on_first_login to avoid setting user attributes at each login. - SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` } type ConnectionOptionsSAML struct { @@ -663,8 +691,10 @@ type ConnectionOptionsSAML struct { RequestTemplate *string `json:"requestTemplate,omitempty"` UserIDAttribute *string `json:"user_id_attribute,omitempty"` LogoURL *string `json:"icon_url,omitempty"` + EntityID *string `json:"entityId,omitempty"` - SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` } type ConnectionOptionsSAMLIdpInitiated struct { @@ -672,6 +702,29 @@ type ConnectionOptionsSAMLIdpInitiated struct { ClientID *string `json:"client_id,omitempty"` ClientProtocol *string `json:"client_protocol,omitempty"` ClientAuthorizeQuery *string `json:"client_authorizequery,omitempty"` + + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` +} + +type ConnectionOptionsGoogleApps struct { + ClientID *string `json:"client_id,omitempty"` + ClientSecret *string `json:"client_secret,omitempty"` + Domain *string `json:"domain,omitempty"` + + EnableUsersAPI *bool `json:"api_enable_users,omitempty"` + BasicProfile *bool `json:"basic_profile,omitempty" scope:"basic_profile"` + ExtendedProfile *bool `json:"ext_profile,omitempty" scope:"ext_profile"` + Groups *bool `json:"ext_groups,omitempty" scope:"ext_groups"` + Admin *bool `json:"ext_admin,omitempty" scope:"ext_admin"` + IsSuspended *bool `json:"ext_is_suspended,omitempty" scope:"ext_is_suspended"` + AgreedTerms *bool `json:"ext_agreed_terms,omitempty" scope:"ext_agreed_terms"` + + SetUserAttributes *string `json:"set_user_root_attributes,omitempty"` + NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"` + + DomainAliases []interface{} `json:"domain_aliases,omitempty"` + LogoURL *string `json:"icon_url,omitempty"` } type ConnectionManager struct { diff --git a/vendor/gopkg.in/auth0.v5/management/grant.go b/vendor/gopkg.in/auth0.v5/management/grant.go index cb19a821c..fbf7aaca5 100644 --- a/vendor/gopkg.in/auth0.v5/management/grant.go +++ b/vendor/gopkg.in/auth0.v5/management/grant.go @@ -17,6 +17,11 @@ type Grant struct { Scope []interface{} `json:"scope,omitempty"` } +type GrantList struct { + List + Grants []*Grant `json:"grants"` +} + type GrantManager struct { *Management } @@ -28,8 +33,8 @@ func newGrantManager(m *Management) *GrantManager { // List the grants associated with your account. // // See: https://auth0.com/docs/api/management/v2#!/Grants/get_grants -func (m *GrantManager) List(opts ...RequestOption) (g []*Grant, err error) { - err = m.Request("GET", m.URI("grants"), &g, opts...) +func (m *GrantManager) List(opts ...RequestOption) (g *GrantList, err error) { + err = m.Request("GET", m.URI("grants"), &g, applyListDefaults(opts)) return } diff --git a/vendor/gopkg.in/auth0.v5/management/guardian.go b/vendor/gopkg.in/auth0.v5/management/guardian.go index 18e6cf715..d1ca466e8 100644 --- a/vendor/gopkg.in/auth0.v5/management/guardian.go +++ b/vendor/gopkg.in/auth0.v5/management/guardian.go @@ -1,5 +1,28 @@ package management +import ( + "encoding/json" + "net/http" + "time" +) + +type Enrollment struct { + // ID for this enrollment + ID *string `json:"id,omitempty"` + // Status of this enrollment. Can be 'pending' or 'confirmed' + Status *string `json:"status,omitempty"` + // Device name (only for push notification). + Name *string `json:"name,omitempty"` + // Device identifier. This is usually the phone identifier. + Identifier *string `json:"identifier,omitempty"` + // Phone number. + PhoneNumber *string `json:"phone_number,omitempty"` + // Enrollment date and time. + EnrolledAt *time.Time `json:"enrolled_at,omitempty"` + // Last authentication date and time. + LastAuth *time.Time `json:"last_auth,omitempty"` +} + type MultiFactor struct { // States if this factor is enabled Enabled *bool `json:"enabled,omitempty"` @@ -11,6 +34,16 @@ type MultiFactor struct { TrialExpired *bool `json:"trial_expired,omitempty"` } +type MultiFactorPolicies []string + +type MultiFactorProvider struct { + // One of auth0|twilio|phone-message-hook + Provider *string `json:"provider,omitempty"` +} + +type PhoneMessageTypes struct { + MessageTypes *[]string `json:"message_types,omitempty"` +} type MultiFactorSMSTemplate struct { // Message sent to the user when they are invited to enroll with a phone number EnrollmentMessage *string `json:"enrollment_message,omitempty"` @@ -51,12 +84,15 @@ type MultiFactorProviderTwilio struct { } type GuardianManager struct { + Enrollment *EnrollmentManager MultiFactor *MultiFactorManager } func newGuardianManager(m *Management) *GuardianManager { return &GuardianManager{ + &EnrollmentManager{m}, &MultiFactorManager{m, + &MultiFactorPhone{m}, &MultiFactorSMS{m}, &MultiFactorPush{m}, &MultiFactorEmail{m}, @@ -66,9 +102,71 @@ func newGuardianManager(m *Management) *GuardianManager { } } -type MultiFactorManager struct { +type EnrollmentManager struct { *Management +} + +type CreateEnrollmentTicket struct { + // UserID is the user_id for the enrollment ticket. + UserID string `json:"user_id,omitempty"` + // Email is an alternate email address to which the enrollment email will + // be sent. If empty, the email will be sent to the user's default email + // address. + Email string `json:"email,omitempty"` + // SendMail indicates whether to send an email to the user to start the + // multi-factor authentication enrollment process. + SendMail bool `json:"send_mail,omitempty"` +} + +type EnrollmentTicket struct { + TicketID string `json:"ticket_id"` + TicketURL string `json:"ticket_url"` +} + +// CreateTicket creates a multi-factor authentication enrollment ticket for +// a specified user. +// +// See: https://auth0.com/docs/api/management/v2#!/Guardian/post_ticket +func (m *EnrollmentManager) CreateTicket(t *CreateEnrollmentTicket, opts ...RequestOption) (EnrollmentTicket, error) { + req, err := m.NewRequest("POST", m.URI("guardian", "enrollments", "ticket"), t, opts...) + if err != nil { + return EnrollmentTicket{}, err + } + + res, err := m.Do(req) + if err != nil { + return EnrollmentTicket{}, err + } + defer res.Body.Close() + + if res.StatusCode != http.StatusOK { + return EnrollmentTicket{}, newError(res.Body) + } + + var out EnrollmentTicket + err = json.NewDecoder(res.Body).Decode(&out) + return out, err +} +// Get retrieves an enrollment (including its status and type). +// +// See: https://auth0.com/docs/api/management/v2#!/Guardian/get_enrollments_by_id +func (m *EnrollmentManager) Get(id string, opts ...RequestOption) (en *Enrollment, err error) { + err = m.Request("GET", m.URI("guardian", "enrollments", id), &en, opts...) + return +} + +// Delete an enrollment to allow the user to enroll with multi-factor authentication again. +// +// See: https://auth0.com/docs/api/management/v2#!/Guardian/delete_enrollments_by_id +func (m *EnrollmentManager) Delete(id string, opts ...RequestOption) (err error) { + err = m.Request("DELETE", m.URI("guardian", "enrollments", id), nil, opts...) + return +} + +type MultiFactorManager struct { + *Management + Phone *MultiFactorPhone SMS *MultiFactorSMS Push *MultiFactorPush Email *MultiFactorEmail @@ -84,6 +182,60 @@ func (m *MultiFactorManager) List(opts ...RequestOption) (mf []*MultiFactor, err return } +// Get MFA policies +// +// See: https://auth0.com/docs/api/management/v2/#!/Guardian/get_policies +func (m *MultiFactorManager) Policy(opts ...RequestOption) (p *MultiFactorPolicies, err error) { + err = m.Request("GET", m.URI("guardian", "policies"), &p, opts...) + return +} + +// Update MFA policies +// +// See: https://auth0.com/docs/api/management/v2/#!/Guardian/put_policies +//Expects an array of either ["all-applications"] or ["confidence-score"] +func (m *MultiFactorManager) UpdatePolicy(p *MultiFactorPolicies, opts ...RequestOption) error { + return m.Request("PUT", m.URI("guardian", "policies"), p, opts...) +} + +type MultiFactorPhone struct{ *Management } + +// Update MFA Phone to be enabled. +// See: https://auth0.com/docs/api/management/v2/#!/Guardian/put_factors_by_name +func (m *MultiFactorPhone) Enable(enabled bool, opts ...RequestOption) error { + // An endpoint for enabling Phone doesn't exist yet so we go towards + // sms endpoint to be consistent with the other methods available for this struct. + return m.Request("PUT", m.URI("guardian", "factors", "sms"), &MultiFactor{ + Enabled: &enabled, + }, opts...) +} + +// Retrieves the MFA Phone provider, one of ["auth0" or "twilio" or "phone-message-hook"] +// See: https://auth0.com/docs/api/management/v2/#!/Guardian/get_selected_provider +func (m *MultiFactorPhone) Provider(opts ...RequestOption) (p *MultiFactorProvider, err error) { + err = m.Request("GET", m.URI("guardian", "factors", "phone", "selected-provider"), &p, opts...) + return +} + +// Update MFA Phone provider, one of ["auth0" or "twilio" or "phone-message-hook"] +// See: https://auth0.com/docs/api/management/v2/#!/Guardian/put_selected_provider +func (m *MultiFactorPhone) UpdateProvider(p *MultiFactorProvider, opts ...RequestOption) error { + return m.Request("PUT", m.URI("guardian", "factors", "phone", "selected-provider"), &p, opts...) +} + +// Retrieves the MFA Phone Message Type +// See: https://auth0.com/docs/api/management/v2/#!/Guardian/get_message_types +func (m *MultiFactorPhone) MessageTypes(opts ...RequestOption) (mt *PhoneMessageTypes, err error) { + err = m.Request("GET", m.URI("guardian", "factors", "phone", "message-types"), &mt, opts...) + return +} + +// Update MFA Phone Message Type +// See: https://auth0.com/docs/api/management/v2/#!/Guardian/put_message_types +func (m *MultiFactorPhone) UpdateMessageTypes(mt *PhoneMessageTypes, opts ...RequestOption) error { + return m.Request("PUT", m.URI("guardian", "factors", "phone", "message-types"), &mt, opts...) +} + type MultiFactorSMS struct{ *Management } // Enable enables or disables the SMS Multi-factor Authentication. diff --git a/vendor/gopkg.in/auth0.v5/management/log.go b/vendor/gopkg.in/auth0.v5/management/log.go index ff0a487d4..1078d6666 100644 --- a/vendor/gopkg.in/auth0.v5/management/log.go +++ b/vendor/gopkg.in/auth0.v5/management/log.go @@ -69,6 +69,9 @@ type Log struct { // The log event type Type *string `json:"type"` + // The log event description + Description *string `json:"description"` + // The id of the client ClientID *string `json:"client_id"` @@ -78,7 +81,6 @@ type Log struct { // The IP of the log event source IP *string `json:"ip"` - Description *string `json:"description"` LocationInfo map[string]interface{} `json:"location_info"` Details map[string]interface{} `json:"details"` diff --git a/vendor/gopkg.in/auth0.v5/management/management.gen.go b/vendor/gopkg.in/auth0.v5/management/management.gen.go index e005cedd4..60b39e95e 100644 --- a/vendor/gopkg.in/auth0.v5/management/management.gen.go +++ b/vendor/gopkg.in/auth0.v5/management/management.gen.go @@ -402,6 +402,30 @@ func (c *ClientRefreshToken) GetExpirationType() string { return *c.ExpirationType } +// GetIdleTokenLifetime returns the IdleTokenLifetime field if it's non-nil, zero value otherwise. +func (c *ClientRefreshToken) GetIdleTokenLifetime() int { + if c == nil || c.IdleTokenLifetime == nil { + return 0 + } + return *c.IdleTokenLifetime +} + +// GetInfiniteIdleTokenLifetime returns the InfiniteIdleTokenLifetime field if it's non-nil, zero value otherwise. +func (c *ClientRefreshToken) GetInfiniteIdleTokenLifetime() bool { + if c == nil || c.InfiniteIdleTokenLifetime == nil { + return false + } + return *c.InfiniteIdleTokenLifetime +} + +// GetInfiniteTokenLifetime returns the InfiniteTokenLifetime field if it's non-nil, zero value otherwise. +func (c *ClientRefreshToken) GetInfiniteTokenLifetime() bool { + if c == nil || c.InfiniteTokenLifetime == nil { + return false + } + return *c.InfiniteTokenLifetime +} + // GetLeeway returns the Leeway field if it's non-nil, zero value otherwise. func (c *ClientRefreshToken) GetLeeway() int { if c == nil || c.Leeway == nil { @@ -471,6 +495,14 @@ func (c *Connection) GetName() string { return *c.Name } +// GetProvisioningTicketUrl returns the ProvisioningTicketUrl field if it's non-nil, zero value otherwise. +func (c *Connection) GetProvisioningTicketUrl() string { + if c == nil || c.ProvisioningTicketUrl == nil { + return "" + } + return *c.ProvisioningTicketUrl +} + // GetStrategy returns the Strategy field if it's non-nil, zero value otherwise. func (c *Connection) GetStrategy() string { if c == nil || c.Strategy == nil { @@ -521,6 +553,14 @@ func (c *ConnectionOptions) GetImportMode() bool { return *c.ImportMode } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptions) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetPasswordPolicy returns the PasswordPolicy field if it's non-nil, zero value otherwise. func (c *ConnectionOptions) GetPasswordPolicy() string { if c == nil || c.PasswordPolicy == nil { @@ -537,6 +577,14 @@ func (c *ConnectionOptions) GetRequiresUsername() bool { return *c.RequiresUsername } +// GetSetUserAttributes returns the SetUserAttributes field if it's non-nil, zero value otherwise. +func (c *ConnectionOptions) GetSetUserAttributes() string { + if c == nil || c.SetUserAttributes == nil { + return "" + } + return *c.SetUserAttributes +} + // GetStrategyVersion returns the StrategyVersion field if it's non-nil, zero value otherwise. func (c *ConnectionOptions) GetStrategyVersion() int { if c == nil || c.StrategyVersion == nil { @@ -590,6 +638,14 @@ func (c *ConnectionOptionsAD) GetLogoURL() string { return *c.LogoURL } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsAD) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetSetUserAttributes returns the SetUserAttributes field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsAD) GetSetUserAttributes() string { if c == nil || c.SetUserAttributes == nil { @@ -635,6 +691,14 @@ func (c *ConnectionOptionsADFS) GetLogoURL() string { return *c.LogoURL } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsADFS) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetSetUserAttributes returns the SetUserAttributes field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsADFS) GetSetUserAttributes() string { if c == nil || c.SetUserAttributes == nil { @@ -696,6 +760,14 @@ func (c *ConnectionOptionsApple) GetName() bool { return *c.Name } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsApple) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetScope returns the Scope field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsApple) GetScope() string { if c == nil || c.Scope == nil { @@ -704,6 +776,14 @@ func (c *ConnectionOptionsApple) GetScope() string { return *c.Scope } +// GetSetUserAttributes returns the SetUserAttributes field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsApple) GetSetUserAttributes() string { + if c == nil || c.SetUserAttributes == nil { + return "" + } + return *c.SetUserAttributes +} + // GetTeamID returns the TeamID field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsApple) GetTeamID() string { if c == nil || c.TeamID == nil { @@ -845,6 +925,22 @@ func (c *ConnectionOptionsAzureAD) GetNestedGroups() bool { return *c.NestedGroups } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsAzureAD) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + +// GetSetUserAttributes returns the SetUserAttributes field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsAzureAD) GetSetUserAttributes() string { + if c == nil || c.SetUserAttributes == nil { + return "" + } + return *c.SetUserAttributes +} + // GetTenantDomain returns the TenantDomain field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsAzureAD) GetTenantDomain() string { if c == nil || c.TenantDomain == nil { @@ -853,6 +949,14 @@ func (c *ConnectionOptionsAzureAD) GetTenantDomain() string { return *c.TenantDomain } +// GetTrustEmailVerified returns the TrustEmailVerified field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsAzureAD) GetTrustEmailVerified() string { + if c == nil || c.TrustEmailVerified == nil { + return "" + } + return *c.TrustEmailVerified +} + // GetUseCommonEndpoint returns the UseCommonEndpoint field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsAzureAD) GetUseCommonEndpoint() bool { if c == nil || c.UseCommonEndpoint == nil { @@ -922,6 +1026,14 @@ func (c *ConnectionOptionsEmail) GetName() string { return *c.Name } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsEmail) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetOTP returns the OTP field. func (c *ConnectionOptionsEmail) GetOTP() *ConnectionOptionsOTP { if c == nil { @@ -930,6 +1042,14 @@ func (c *ConnectionOptionsEmail) GetOTP() *ConnectionOptionsOTP { return c.OTP } +// GetSetUserAttributes returns the SetUserAttributes field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsEmail) GetSetUserAttributes() string { + if c == nil || c.SetUserAttributes == nil { + return "" + } + return *c.SetUserAttributes +} + // String returns a string representation of ConnectionOptionsEmail. func (c *ConnectionOptionsEmail) String() string { return Stringify(c) @@ -1060,6 +1180,14 @@ func (c *ConnectionOptionsFacebook) GetManagePages() bool { return *c.ManagePages } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsFacebook) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetPagesManageCTA returns the PagesManageCTA field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsFacebook) GetPagesManageCTA() bool { if c == nil || c.PagesManageCTA == nil { @@ -1196,6 +1324,14 @@ func (c *ConnectionOptionsFacebook) GetScope() string { return *c.Scope } +// GetSetUserAttributes returns the SetUserAttributes field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsFacebook) GetSetUserAttributes() string { + if c == nil || c.SetUserAttributes == nil { + return "" + } + return *c.SetUserAttributes +} + // GetUserAgeRange returns the UserAgeRange field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsFacebook) GetUserAgeRange() bool { if c == nil || c.UserAgeRange == nil { @@ -1401,6 +1537,14 @@ func (c *ConnectionOptionsGitHub) GetGist() bool { return *c.Gist } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGitHub) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetNotifications returns the Notifications field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsGitHub) GetNotifications() bool { if c == nil || c.Notifications == nil { @@ -1518,6 +1662,115 @@ func (c *ConnectionOptionsGitHub) String() string { return Stringify(c) } +// GetAdmin returns the Admin field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleApps) GetAdmin() bool { + if c == nil || c.Admin == nil { + return false + } + return *c.Admin +} + +// GetAgreedTerms returns the AgreedTerms field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleApps) GetAgreedTerms() bool { + if c == nil || c.AgreedTerms == nil { + return false + } + return *c.AgreedTerms +} + +// GetBasicProfile returns the BasicProfile field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleApps) GetBasicProfile() bool { + if c == nil || c.BasicProfile == nil { + return false + } + return *c.BasicProfile +} + +// GetClientID returns the ClientID field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleApps) GetClientID() string { + if c == nil || c.ClientID == nil { + return "" + } + return *c.ClientID +} + +// GetClientSecret returns the ClientSecret field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleApps) GetClientSecret() string { + if c == nil || c.ClientSecret == nil { + return "" + } + return *c.ClientSecret +} + +// GetDomain returns the Domain field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleApps) GetDomain() string { + if c == nil || c.Domain == nil { + return "" + } + return *c.Domain +} + +// GetEnableUsersAPI returns the EnableUsersAPI field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleApps) GetEnableUsersAPI() bool { + if c == nil || c.EnableUsersAPI == nil { + return false + } + return *c.EnableUsersAPI +} + +// GetExtendedProfile returns the ExtendedProfile field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleApps) GetExtendedProfile() bool { + if c == nil || c.ExtendedProfile == nil { + return false + } + return *c.ExtendedProfile +} + +// GetGroups returns the Groups field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleApps) GetGroups() bool { + if c == nil || c.Groups == nil { + return false + } + return *c.Groups +} + +// GetIsSuspended returns the IsSuspended field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleApps) GetIsSuspended() bool { + if c == nil || c.IsSuspended == nil { + return false + } + return *c.IsSuspended +} + +// GetLogoURL returns the LogoURL field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleApps) GetLogoURL() string { + if c == nil || c.LogoURL == nil { + return "" + } + return *c.LogoURL +} + +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleApps) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + +// GetSetUserAttributes returns the SetUserAttributes field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleApps) GetSetUserAttributes() string { + if c == nil || c.SetUserAttributes == nil { + return "" + } + return *c.SetUserAttributes +} + +// String returns a string representation of ConnectionOptionsGoogleApps. +func (c *ConnectionOptionsGoogleApps) String() string { + return Stringify(c) +} + // GetAdsenseManagement returns the AdsenseManagement field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsGoogleOAuth2) GetAdsenseManagement() bool { if c == nil || c.AdsenseManagement == nil { @@ -1702,6 +1955,14 @@ func (c *ConnectionOptionsGoogleOAuth2) GetModerator() bool { return *c.Moderator } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleOAuth2) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetOrkut returns the Orkut field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsGoogleOAuth2) GetOrkut() bool { if c == nil || c.Orkut == nil { @@ -1726,6 +1987,14 @@ func (c *ConnectionOptionsGoogleOAuth2) GetProfile() bool { return *c.Profile } +// GetSetUserAttributes returns the SetUserAttributes field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsGoogleOAuth2) GetSetUserAttributes() string { + if c == nil || c.SetUserAttributes == nil { + return "" + } + return *c.SetUserAttributes +} + // GetSites returns the Sites field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsGoogleOAuth2) GetSites() bool { if c == nil || c.Sites == nil { @@ -1811,6 +2080,14 @@ func (c *ConnectionOptionsLinkedin) GetEmail() bool { return *c.Email } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsLinkedin) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetProfile returns the Profile field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsLinkedin) GetProfile() bool { if c == nil || c.Profile == nil { @@ -1864,6 +2141,14 @@ func (c *ConnectionOptionsOAuth2) GetClientSecret() string { return *c.ClientSecret } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsOAuth2) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetScope returns the Scope field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsOAuth2) GetScope() string { if c == nil || c.Scope == nil { @@ -1872,6 +2157,14 @@ func (c *ConnectionOptionsOAuth2) GetScope() string { return *c.Scope } +// GetSetUserAttributes returns the SetUserAttributes field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsOAuth2) GetSetUserAttributes() string { + if c == nil || c.SetUserAttributes == nil { + return "" + } + return *c.SetUserAttributes +} + // GetTokenURL returns the TokenURL field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsOAuth2) GetTokenURL() string { if c == nil || c.TokenURL == nil { @@ -1941,6 +2234,14 @@ func (c *ConnectionOptionsOIDC) GetLogoURL() string { return *c.LogoURL } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsOIDC) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetScope returns the Scope field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsOIDC) GetScope() string { if c == nil || c.Scope == nil { @@ -1949,6 +2250,14 @@ func (c *ConnectionOptionsOIDC) GetScope() string { return *c.Scope } +// GetSetUserAttributes returns the SetUserAttributes field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsOIDC) GetSetUserAttributes() string { + if c == nil || c.SetUserAttributes == nil { + return "" + } + return *c.SetUserAttributes +} + // GetTenantDomain returns the TenantDomain field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsOIDC) GetTenantDomain() string { if c == nil || c.TenantDomain == nil { @@ -2031,6 +2340,14 @@ func (c *ConnectionOptionsSalesforce) GetCommunityBaseURL() string { return *c.CommunityBaseURL } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsSalesforce) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetProfile returns the Profile field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsSalesforce) GetProfile() bool { if c == nil || c.Profile == nil { @@ -2076,6 +2393,14 @@ func (c *ConnectionOptionsSAML) GetDigestAglorithm() string { return *c.DigestAglorithm } +// GetEntityID returns the EntityID field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsSAML) GetEntityID() string { + if c == nil || c.EntityID == nil { + return "" + } + return *c.EntityID +} + // GetExpires returns the Expires field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsSAML) GetExpires() string { if c == nil || c.Expires == nil { @@ -2116,6 +2441,14 @@ func (c *ConnectionOptionsSAML) GetMetadataXML() string { return *c.MetadataXML } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsSAML) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetProtocolBinding returns the ProtocolBinding field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsSAML) GetProtocolBinding() string { if c == nil || c.ProtocolBinding == nil { @@ -2233,6 +2566,22 @@ func (c *ConnectionOptionsSAMLIdpInitiated) GetEnabled() bool { return *c.Enabled } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsSAMLIdpInitiated) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + +// GetSetUserAttributes returns the SetUserAttributes field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsSAMLIdpInitiated) GetSetUserAttributes() string { + if c == nil || c.SetUserAttributes == nil { + return "" + } + return *c.SetUserAttributes +} + // String returns a string representation of ConnectionOptionsSAMLIdpInitiated. func (c *ConnectionOptionsSAMLIdpInitiated) String() string { return Stringify(c) @@ -2435,6 +2784,14 @@ func (c *ConnectionOptionsWindowsLive) GetFilesUpdate() bool { return *c.FilesUpdate } +// GetNonPersistentAttrs returns the NonPersistentAttrs field if it's non-nil, zero value otherwise. +func (c *ConnectionOptionsWindowsLive) GetNonPersistentAttrs() []string { + if c == nil || c.NonPersistentAttrs == nil { + return nil + } + return *c.NonPersistentAttrs +} + // GetNotes returns the Notes field if it's non-nil, zero value otherwise. func (c *ConnectionOptionsWindowsLive) GetNotes() bool { if c == nil || c.Notes == nil { @@ -2536,6 +2893,11 @@ func (c *ConnectionOptionsWindowsLive) String() string { return Stringify(c) } +// String returns a string representation of CreateEnrollmentTicket. +func (c *CreateEnrollmentTicket) String() string { + return Stringify(c) +} + // GetDomain returns the Domain field if it's non-nil, zero value otherwise. func (c *CustomDomain) GetDomain() string { if c == nil || c.Domain == nil { @@ -2846,6 +3208,72 @@ func (e *EmailTemplate) String() string { return Stringify(e) } +// GetEnrolledAt returns the EnrolledAt field if it's non-nil, zero value otherwise. +func (e *Enrollment) GetEnrolledAt() time.Time { + if e == nil || e.EnrolledAt == nil { + return time.Time{} + } + return *e.EnrolledAt +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (e *Enrollment) GetID() string { + if e == nil || e.ID == nil { + return "" + } + return *e.ID +} + +// GetIdentifier returns the Identifier field if it's non-nil, zero value otherwise. +func (e *Enrollment) GetIdentifier() string { + if e == nil || e.Identifier == nil { + return "" + } + return *e.Identifier +} + +// GetLastAuth returns the LastAuth field if it's non-nil, zero value otherwise. +func (e *Enrollment) GetLastAuth() time.Time { + if e == nil || e.LastAuth == nil { + return time.Time{} + } + return *e.LastAuth +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (e *Enrollment) GetName() string { + if e == nil || e.Name == nil { + return "" + } + return *e.Name +} + +// GetPhoneNumber returns the PhoneNumber field if it's non-nil, zero value otherwise. +func (e *Enrollment) GetPhoneNumber() string { + if e == nil || e.PhoneNumber == nil { + return "" + } + return *e.PhoneNumber +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (e *Enrollment) GetStatus() string { + if e == nil || e.Status == nil { + return "" + } + return *e.Status +} + +// String returns a string representation of Enrollment. +func (e *Enrollment) String() string { + return Stringify(e) +} + +// String returns a string representation of EnrollmentTicket. +func (e *EnrollmentTicket) String() string { + return Stringify(e) +} + // GetAudience returns the Audience field if it's non-nil, zero value otherwise. func (g *Grant) GetAudience() string { if g == nil || g.Audience == nil { @@ -2883,6 +3311,11 @@ func (g *Grant) String() string { return Stringify(g) } +// String returns a string representation of GrantList. +func (g *GrantList) String() string { + return Stringify(g) +} + // GetEnabled returns the Enabled field if it's non-nil, zero value otherwise. func (h *Hook) GetEnabled() bool { if h == nil || h.Enabled == nil { @@ -3087,6 +3520,14 @@ func (l *Log) GetDate() time.Time { return *l.Date } +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (l *Log) GetDescription() string { + if l == nil || l.Description == nil { + return "" + } + return *l.Description +} + // GetID returns the ID field if it's non-nil, zero value otherwise. func (l *Log) GetID() string { if l == nil || l.ID == nil { @@ -3387,6 +3828,24 @@ func (m *MultiFactorOTP) String() string { return Stringify(m) } +// String returns a string representation of MultiFactorPhone. +func (m *MultiFactorPhone) String() string { + return Stringify(m) +} + +// GetProvider returns the Provider field if it's non-nil, zero value otherwise. +func (m *MultiFactorProvider) GetProvider() string { + if m == nil || m.Provider == nil { + return "" + } + return *m.Provider +} + +// String returns a string representation of MultiFactorProvider. +func (m *MultiFactorProvider) String() string { + return Stringify(m) +} + // GetAccessKeyID returns the AccessKeyID field if it's non-nil, zero value otherwise. func (m *MultiFactorProviderAmazonSNS) GetAccessKeyID() string { if m == nil || m.AccessKeyID == nil { @@ -3542,6 +4001,27 @@ func (p *PermissionList) String() string { return Stringify(p) } +// GetMessageTypes returns the MessageTypes field if it's non-nil, zero value otherwise. +func (p *PhoneMessageTypes) GetMessageTypes() []string { + if p == nil || p.MessageTypes == nil { + return nil + } + return *p.MessageTypes +} + +// String returns a string representation of PhoneMessageTypes. +func (p *PhoneMessageTypes) String() string { + return Stringify(p) +} + +// GetIdentifierFirst returns the IdentifierFirst field if it's non-nil, zero value otherwise. +func (p *Prompt) GetIdentifierFirst() bool { + if p == nil || p.IdentifierFirst == nil { + return false + } + return *p.IdentifierFirst +} + // String returns a string representation of Prompt. func (p *Prompt) String() string { return Stringify(p) @@ -3779,6 +4259,107 @@ func (r *RuleList) String() string { return Stringify(r) } +// GetCert returns the Cert field if it's non-nil, zero value otherwise. +func (s *SigningKey) GetCert() string { + if s == nil || s.Cert == nil { + return "" + } + return *s.Cert +} + +// GetCurrent returns the Current field if it's non-nil, zero value otherwise. +func (s *SigningKey) GetCurrent() bool { + if s == nil || s.Current == nil { + return false + } + return *s.Current +} + +// GetCurrentSince returns the CurrentSince field if it's non-nil, zero value otherwise. +func (s *SigningKey) GetCurrentSince() time.Time { + if s == nil || s.CurrentSince == nil { + return time.Time{} + } + return *s.CurrentSince +} + +// GetCurrentUntil returns the CurrentUntil field if it's non-nil, zero value otherwise. +func (s *SigningKey) GetCurrentUntil() time.Time { + if s == nil || s.CurrentUntil == nil { + return time.Time{} + } + return *s.CurrentUntil +} + +// GetFingerprint returns the Fingerprint field if it's non-nil, zero value otherwise. +func (s *SigningKey) GetFingerprint() string { + if s == nil || s.Fingerprint == nil { + return "" + } + return *s.Fingerprint +} + +// GetKID returns the KID field if it's non-nil, zero value otherwise. +func (s *SigningKey) GetKID() string { + if s == nil || s.KID == nil { + return "" + } + return *s.KID +} + +// GetNext returns the Next field if it's non-nil, zero value otherwise. +func (s *SigningKey) GetNext() bool { + if s == nil || s.Next == nil { + return false + } + return *s.Next +} + +// GetPKCS7 returns the PKCS7 field if it's non-nil, zero value otherwise. +func (s *SigningKey) GetPKCS7() string { + if s == nil || s.PKCS7 == nil { + return "" + } + return *s.PKCS7 +} + +// GetPrevious returns the Previous field if it's non-nil, zero value otherwise. +func (s *SigningKey) GetPrevious() bool { + if s == nil || s.Previous == nil { + return false + } + return *s.Previous +} + +// GetRevoked returns the Revoked field if it's non-nil, zero value otherwise. +func (s *SigningKey) GetRevoked() bool { + if s == nil || s.Revoked == nil { + return false + } + return *s.Revoked +} + +// GetRevokedAt returns the RevokedAt field if it's non-nil, zero value otherwise. +func (s *SigningKey) GetRevokedAt() time.Time { + if s == nil || s.RevokedAt == nil { + return time.Time{} + } + return *s.RevokedAt +} + +// GetThumbprint returns the Thumbprint field if it's non-nil, zero value otherwise. +func (s *SigningKey) GetThumbprint() string { + if s == nil || s.Thumbprint == nil { + return "" + } + return *s.Thumbprint +} + +// String returns a string representation of SigningKey. +func (s *SigningKey) String() string { + return Stringify(s) +} + // GetChangePassword returns the ChangePassword field. func (t *Tenant) GetChangePassword() *TenantChangePassword { if t == nil { @@ -4142,6 +4723,14 @@ func (t *TenantUniversalLoginColors) GetPageBackground() string { return *t.PageBackground } +// GetPageBackgroundGradient returns the PageBackgroundGradient field. +func (t *TenantUniversalLoginColors) GetPageBackgroundGradient() *BrandingPageBackgroundGradient { + if t == nil { + return nil + } + return t.PageBackgroundGradient +} + // GetPrimary returns the Primary field if it's non-nil, zero value otherwise. func (t *TenantUniversalLoginColors) GetPrimary() string { if t == nil || t.Primary == nil { @@ -4171,14 +4760,6 @@ func (t *Ticket) GetEmail() string { return *t.Email } -// GetMarkEmailAsVerified returns the MarkEmailAsVerified field if it's non-nil, zero value otherwise. -func (t *Ticket) GetMarkEmailAsVerified() bool { - if t == nil || t.MarkEmailAsVerified == nil { - return false - } - return *t.MarkEmailAsVerified -} - // GetIncludeEmailInRedirect returns the IncludeEmailInRedirect field if it's non-nil, zero value otherwise. func (t *Ticket) GetIncludeEmailInRedirect() bool { if t == nil || t.IncludeEmailInRedirect == nil { @@ -4187,6 +4768,14 @@ func (t *Ticket) GetIncludeEmailInRedirect() bool { return *t.IncludeEmailInRedirect } +// GetMarkEmailAsVerified returns the MarkEmailAsVerified field if it's non-nil, zero value otherwise. +func (t *Ticket) GetMarkEmailAsVerified() bool { + if t == nil || t.MarkEmailAsVerified == nil { + return false + } + return *t.MarkEmailAsVerified +} + // GetResultURL returns the ResultURL field if it's non-nil, zero value otherwise. func (t *Ticket) GetResultURL() string { if t == nil || t.ResultURL == nil { @@ -4248,6 +4837,14 @@ func (u *User) GetCreatedAt() time.Time { return *u.CreatedAt } +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (u *User) GetDescription() string { + if u == nil || u.Description == nil { + return "" + } + return *u.Description +} + // GetEmail returns the Email field if it's non-nil, zero value otherwise. func (u *User) GetEmail() string { if u == nil || u.Email == nil { @@ -4304,6 +4901,14 @@ func (u *User) GetLastLogin() time.Time { return *u.LastLogin } +// GetLocation returns the Location field if it's non-nil, zero value otherwise. +func (u *User) GetLocation() string { + if u == nil || u.Location == nil { + return "" + } + return *u.Location +} + // GetLoginsCount returns the LoginsCount field if it's non-nil, zero value otherwise. func (u *User) GetLoginsCount() int64 { if u == nil || u.LoginsCount == nil { @@ -4360,6 +4965,14 @@ func (u *User) GetPicture() string { return *u.Picture } +// GetScreenName returns the ScreenName field if it's non-nil, zero value otherwise. +func (u *User) GetScreenName() string { + if u == nil || u.ScreenName == nil { + return "" + } + return *u.ScreenName +} + // GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. func (u *User) GetUpdatedAt() time.Time { if u == nil || u.UpdatedAt == nil { @@ -4368,6 +4981,14 @@ func (u *User) GetUpdatedAt() time.Time { return *u.UpdatedAt } +// GetURL returns the URL field if it's non-nil, zero value otherwise. +func (u *User) GetURL() string { + if u == nil || u.URL == nil { + return "" + } + return *u.URL +} + // GetUsername returns the Username field if it's non-nil, zero value otherwise. func (u *User) GetUsername() string { if u == nil || u.Username == nil { @@ -4410,6 +5031,83 @@ func (u *UserBlock) String() string { return Stringify(u) } +// GetAuthMethod returns the AuthMethod field if it's non-nil, zero value otherwise. +func (u *UserEnrollment) GetAuthMethod() string { + if u == nil || u.AuthMethod == nil { + return "" + } + return *u.AuthMethod +} + +// GetEnrolledAt returns the EnrolledAt field if it's non-nil, zero value otherwise. +func (u *UserEnrollment) GetEnrolledAt() time.Time { + if u == nil || u.EnrolledAt == nil { + return time.Time{} + } + return *u.EnrolledAt +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (u *UserEnrollment) GetID() string { + if u == nil || u.ID == nil { + return "" + } + return *u.ID +} + +// GetIdentifier returns the Identifier field if it's non-nil, zero value otherwise. +func (u *UserEnrollment) GetIdentifier() string { + if u == nil || u.Identifier == nil { + return "" + } + return *u.Identifier +} + +// GetLastAuth returns the LastAuth field if it's non-nil, zero value otherwise. +func (u *UserEnrollment) GetLastAuth() time.Time { + if u == nil || u.LastAuth == nil { + return time.Time{} + } + return *u.LastAuth +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (u *UserEnrollment) GetName() string { + if u == nil || u.Name == nil { + return "" + } + return *u.Name +} + +// GetPhoneNumber returns the PhoneNumber field if it's non-nil, zero value otherwise. +func (u *UserEnrollment) GetPhoneNumber() string { + if u == nil || u.PhoneNumber == nil { + return "" + } + return *u.PhoneNumber +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (u *UserEnrollment) GetStatus() string { + if u == nil || u.Status == nil { + return "" + } + return *u.Status +} + +// GetType returns the Type field if it's non-nil, zero value otherwise. +func (u *UserEnrollment) GetType() string { + if u == nil || u.Type == nil { + return "" + } + return *u.Type +} + +// String returns a string representation of UserEnrollment. +func (u *UserEnrollment) String() string { + return Stringify(u) +} + // GetAccessToken returns the AccessToken field if it's non-nil, zero value otherwise. func (u *UserIdentity) GetAccessToken() string { if u == nil || u.AccessToken == nil { @@ -4418,6 +5116,14 @@ func (u *UserIdentity) GetAccessToken() string { return *u.AccessToken } +// GetAccessTokenSecret returns the AccessTokenSecret field if it's non-nil, zero value otherwise. +func (u *UserIdentity) GetAccessTokenSecret() string { + if u == nil || u.AccessTokenSecret == nil { + return "" + } + return *u.AccessTokenSecret +} + // GetConnection returns the Connection field if it's non-nil, zero value otherwise. func (u *UserIdentity) GetConnection() string { if u == nil || u.Connection == nil { @@ -4442,6 +5148,14 @@ func (u *UserIdentity) GetProvider() string { return *u.Provider } +// GetRefreshToken returns the RefreshToken field if it's non-nil, zero value otherwise. +func (u *UserIdentity) GetRefreshToken() string { + if u == nil || u.RefreshToken == nil { + return "" + } + return *u.RefreshToken +} + // GetUserID returns the UserID field if it's non-nil, zero value otherwise. func (u *UserIdentity) GetUserID() string { if u == nil || u.UserID == nil { @@ -4455,7 +5169,57 @@ func (u *UserIdentity) String() string { return Stringify(u) } +// GetConnectionID returns the ConnectionID field if it's non-nil, zero value otherwise. +func (u *UserIdentityLink) GetConnectionID() string { + if u == nil || u.ConnectionID == nil { + return "" + } + return *u.ConnectionID +} + +// GetLinkWith returns the LinkWith field if it's non-nil, zero value otherwise. +func (u *UserIdentityLink) GetLinkWith() string { + if u == nil || u.LinkWith == nil { + return "" + } + return *u.LinkWith +} + +// GetProvider returns the Provider field if it's non-nil, zero value otherwise. +func (u *UserIdentityLink) GetProvider() string { + if u == nil || u.Provider == nil { + return "" + } + return *u.Provider +} + +// GetUserID returns the UserID field if it's non-nil, zero value otherwise. +func (u *UserIdentityLink) GetUserID() string { + if u == nil || u.UserID == nil { + return "" + } + return *u.UserID +} + +// String returns a string representation of UserIdentityLink. +func (u *UserIdentityLink) String() string { + return Stringify(u) +} + // String returns a string representation of UserList. func (u *UserList) String() string { return Stringify(u) } + +// GetRecoveryCode returns the RecoveryCode field if it's non-nil, zero value otherwise. +func (u *UserRecoveryCode) GetRecoveryCode() string { + if u == nil || u.RecoveryCode == nil { + return "" + } + return *u.RecoveryCode +} + +// String returns a string representation of UserRecoveryCode. +func (u *UserRecoveryCode) String() string { + return Stringify(u) +} diff --git a/vendor/gopkg.in/auth0.v5/management/management.go b/vendor/gopkg.in/auth0.v5/management/management.go index 804cdbdf8..b9ab96a35 100644 --- a/vendor/gopkg.in/auth0.v5/management/management.go +++ b/vendor/gopkg.in/auth0.v5/management/management.go @@ -83,18 +83,6 @@ func WithClient(client *http.Client) ManagementOption { // Management API v2. // type Management struct { - // Action manages Auth0 actions - Action *ActionManager - - // Action manages Auth0 actions bindings - ActionBinding *ActionBindingManager - - // Action manages Auth0 actions executions - ActionExecution *ActionExecutionManager - - // Action manages Auth0 actions versions - ActionVersion *ActionVersionManager - // Client manages Auth0 Client (also known as Application) resources. Client *ClientManager @@ -165,6 +153,12 @@ type Management struct { // Blacklist manages the auth0 blacklists Blacklist *BlacklistManager + // SigningKey manages Auth0 Application Signing Keys. + SigningKey *SigningKeyManager + + // Anomaly manages the IP blocks + Anomaly *AnomalyManager + url *url.URL basePath string userAgent string @@ -208,10 +202,6 @@ func New(domain string, options ...ManagementOption) (*Management, error) { client.WithUserAgent(m.userAgent), client.WithRateLimit()) - m.Action = newActionManager(m) - m.ActionBinding = newActionBindingManager(m) - m.ActionExecution = newActionExecutionManager(m) - m.ActionVersion = newActionVersionManager(m) m.Client = newClientManager(m) m.ClientGrant = newClientGrantManager(m) m.Connection = newConnectionManager(m) @@ -235,6 +225,8 @@ func New(domain string, options ...ManagementOption) (*Management, error) { m.Guardian = newGuardianManager(m) m.Prompt = newPromptManager(m) m.Blacklist = newBlacklistManager(m) + m.SigningKey = newSigningKeyManager(m) + m.Anomaly = newAnomalyManager(m) return m, nil } @@ -362,10 +354,10 @@ func (m *managementError) Status() int { // Specific implementations embed this struct, therefore its direct use is not // useful. Rather it has been made public in order to aid documentation. type List struct { - Start int `json:"start,omitempty"` - Limit int `json:"limit,omitempty"` - Length int `json:"length,omitempty"` - Total int `json:"total,omitempty"` + Start int `json:"start"` + Limit int `json:"limit"` + Length int `json:"length"` + Total int `json:"total"` } func (l List) HasNext() bool { diff --git a/vendor/gopkg.in/auth0.v5/management/prompt.go b/vendor/gopkg.in/auth0.v5/management/prompt.go index ffb3900ba..db5a1e2de 100644 --- a/vendor/gopkg.in/auth0.v5/management/prompt.go +++ b/vendor/gopkg.in/auth0.v5/management/prompt.go @@ -3,6 +3,9 @@ package management type Prompt struct { // Which login experience to use. Can be `new` or `classic`. UniversalLoginExperience string `json:"universal_login_experience,omitempty"` + + // IdentifierFirst determines if the login screen prompts for just the identifier, identifier and password first. + IdentifierFirst *bool `json:"identifier_first,omitempty"` } type PromptManager struct { diff --git a/vendor/gopkg.in/auth0.v5/management/signing_key.go b/vendor/gopkg.in/auth0.v5/management/signing_key.go new file mode 100644 index 000000000..bcf7f8113 --- /dev/null +++ b/vendor/gopkg.in/auth0.v5/management/signing_key.go @@ -0,0 +1,82 @@ +package management + +import "time" + +type SigningKey struct { + + // The key id of the signing key. + KID *string `json:"kid,omitempty"` + + // The public certificate of the signing key. + Cert *string `json:"cert,omitempty"` + + // The public certificate of the signing key in pkcs7 format. + PKCS7 *string `json:"pkcs7,omitempty"` + + // True if the key is the the current key. + Current *bool `json:"current,omitempty"` + + // True if the key is the the next key. + Next *bool `json:"next,omitempty"` + + // True if the key is the the previous key. + Previous *bool `json:"previous,omitempty"` + + // The date and time when the key became the current key. + CurrentSince *time.Time `json:"current_since,omitempty"` + + // The date and time when the current key was rotated. + CurrentUntil *time.Time `json:"current_until,omitempty"` + + // The cert fingerprint. + Fingerprint *string `json:"fingerprint,omitempty"` + + // The cert thumbprint. + Thumbprint *string `json:"thumbprint,omitempty"` + + // True if the key is revoked. + Revoked *bool `json:"revoked,omitempty"` + + // The date and time when the key was revoked. + RevokedAt *time.Time `json:"revoked_at,omitempty"` +} + +type SigningKeyManager struct { + *Management +} + +func newSigningKeyManager(m *Management) *SigningKeyManager { + return &SigningKeyManager{m} +} + +// List all Application Signing Keys. +// +// See: https://auth0.com/docs/api/management/v2#!/Keys/get_signing_keys +func (m *SigningKeyManager) List(opts ...RequestOption) (ks []*SigningKey, err error) { + err = m.Request("GET", m.URI("keys", "signing"), &ks, opts...) + return +} + +// Read an Application Signing Key by its key id. +// +// See: https://auth0.com/docs/api/management/v2#!/Keys/get_signing_key +func (m *SigningKeyManager) Read(kid string, opts ...RequestOption) (k *SigningKey, err error) { + err = m.Request("GET", m.URI("keys", "signing", kid), &k, opts...) + return +} + +// Rotate the Application Signing Key. +// +// See: https://auth0.com/docs/api/management/v2#!/Keys/post_signing_keys +func (m *SigningKeyManager) Rotate(opts ...RequestOption) (k *SigningKey, err error) { + err = m.Request("POST", m.URI("keys", "signing", "rotate"), &k, opts...) + return +} + +// Revoke an Application Signing Key by its key id. +// +// See: https://auth0.com/docs/api/management/v2#!/Keys/put_signing_keys +func (m *SigningKeyManager) Revoke(kid string, opts ...RequestOption) (k *SigningKey, err error) { + err = m.Request("PUT", m.URI("keys", "signing", kid, "revoke"), &k, opts...) + return +} diff --git a/vendor/gopkg.in/auth0.v5/management/user.go b/vendor/gopkg.in/auth0.v5/management/user.go index 9212f391e..a1a3d56f5 100644 --- a/vendor/gopkg.in/auth0.v5/management/user.go +++ b/vendor/gopkg.in/auth0.v5/management/user.go @@ -37,6 +37,15 @@ type User struct { // The user's nickname Nickname *string `json:"nickname,omitempty"` + // The screen name, handle, or alias that this user identifies themselves with + ScreenName *string `json:"screen_name,omitempty"` + + // The user-defined UTF-8 string describing their account + Description *string `json:"description,omitempty"` + + // The user-defined location for this account’s profile + Location *string `json:"location,omitempty"` + // The user's password (mandatory for non SMS connections) Password *string `json:"password,omitempty"` @@ -84,6 +93,9 @@ type User struct { // The user's picture url Picture *string `json:"picture,omitempty"` + // A URL provided by the user in association with their profile + URL *string `json:"url,omitempty"` + // True if the user is blocked from the application, false if the user is enabled Blocked *bool `json:"blocked,omitempty"` @@ -98,7 +110,6 @@ type User struct { // // We have to use a custom one due to possible inconsistencies in value types. func (u *User) UnmarshalJSON(b []byte) error { - type user User type userAlias struct { *user @@ -130,8 +141,8 @@ func (u *User) UnmarshalJSON(b []byte) error { return nil } -func (u *User) MarshalJSON() ([]byte, error) { +func (u *User) MarshalJSON() ([]byte, error) { type user User type userAlias struct { *user @@ -161,12 +172,13 @@ type UserIdentityLink struct { } type UserIdentity struct { - Connection *string `json:"connection,omitempty"` - UserID *string `json:"-"` - Provider *string `json:"provider,omitempty"` - IsSocial *bool `json:"isSocial,omitempty"` - AccessToken *string `json:"access_token,omitempty"` - RefreshToken *string `json:"refresh_token,omitempty"` + Connection *string `json:"connection,omitempty"` + UserID *string `json:"-"` + Provider *string `json:"provider,omitempty"` + IsSocial *bool `json:"isSocial,omitempty"` + AccessToken *string `json:"access_token,omitempty"` + AccessTokenSecret *string `json:"access_token_secret,omitempty"` + RefreshToken *string `json:"refresh_token,omitempty"` } // UnmarshalJSON is a custom deserializer for the UserIdentity type. @@ -176,7 +188,6 @@ type UserIdentity struct { // // See https://community.auth0.com/t/users-user-id-returns-inconsistent-type-for-identities-user-id/39236 func (i *UserIdentity) UnmarshalJSON(b []byte) error { - type userIdentity UserIdentity type userIdentityAlias struct { *userIdentity @@ -207,7 +218,6 @@ func (i *UserIdentity) UnmarshalJSON(b []byte) error { } func (i *UserIdentity) MarshalJSON() ([]byte, error) { - type userIdentity UserIdentity type userIdentityAlias struct { *userIdentity @@ -231,6 +241,32 @@ type UserBlock struct { IP *string `json:"ip,omitempty"` } +type UserRecoveryCode struct { + RecoveryCode *string `json:"recovery_code,omitempty"` +} + +// UserEnrollment contains information about the Guardian enrollments for the user +type UserEnrollment struct { + // Authentication method for this enrollment. Can be `authentication`, `guardian`, or `sms`. + AuthMethod *string `json:"auth_method,omitempty"` + // Start date and time of this enrollment. + EnrolledAt *time.Time `json:"enrolled_at,omitempty"` + // ID of this enrollment. + ID *string `json:"id,omitempty"` + // Device identifier (usually phone identifier) of this enrollment. + Identifier *string `json:"identifier,omitempty"` + // Last authentication date and time of this enrollment. + LastAuth *time.Time `json:"last_auth,omitempty"` + // Name of enrollment (usually phone number). + Name *string `json:"name,omitempty"` + // Phone number for this enrollment. + PhoneNumber *string `json:"phone_number,omitempty"` + // Status of this enrollment. Can be `pending` or `confirmed`. + Status *string `json:"status,omitempty"` + // Type of enrollment. + Type *string `json:"type,omitempty"` +} + // UserList is an envelope struct which is used when calling List() or Search() // methods. // @@ -393,7 +429,8 @@ func (m *UserManager) RemovePermissions(id string, permissions []*Permission, op return m.Request("DELETE", m.URI("users", id, "permissions"), &p, opts...) } -// Blocks retrieves a list of blocked IP addresses of a particular user. +// Blocks retrieves a list of blocked IP addresses of a particular user using the +// user ID. // // See: https://auth0.com/docs/api/management/v2#!/User_Blocks/get_user_blocks_by_id func (m *UserManager) Blocks(id string, opts ...RequestOption) ([]*UserBlock, error) { @@ -402,8 +439,19 @@ func (m *UserManager) Blocks(id string, opts ...RequestOption) ([]*UserBlock, er return b.BlockedFor, err } +// Blocks retrieves a list of blocked IP addresses of a particular user using +// any of the user identifiers: username, phone number or email. +// +// See: https://auth0.com/docs/api/management/v2#!/User_Blocks/get_user_blocks +func (m *UserManager) BlocksByIdentifier(identifier string, opts ...RequestOption) ([]*UserBlock, error) { + b := new(userBlock) + opts = append(opts, Parameter("identifier", identifier)) + err := m.Request("GET", m.URI("user-blocks"), &b, opts...) + return b.BlockedFor, err +} + // Unblock a user that was blocked due to an excessive amount of incorrectly -// provided credentials. +// provided credentials using the user ID. // // Note: This endpoint does not unblock users that were blocked by admins. // @@ -412,6 +460,49 @@ func (m *UserManager) Unblock(id string, opts ...RequestOption) error { return m.Request("DELETE", m.URI("user-blocks", id), nil, opts...) } +// Unblock 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. +// +// Note: This endpoint does not unblock users that were blocked by admins. +// +// See: https://auth0.com/docs/api/management/v2#!/User_Blocks/delete_user_blocks +func (m *UserManager) UnblockByIdentifier(identifier string, opts ...RequestOption) error { + opts = append(opts, Parameter("identifier", identifier)) + return m.Request("DELETE", m.URI("user-blocks"), nil, opts...) +} + +// Enrollments retrieves all Guardian enrollments for a user. +// +// See: https://auth0.com/docs/api/management/v2#!/Users/get_enrollments +func (m *UserManager) Enrollments(id string, opts ...RequestOption) (enrolls []*UserEnrollment, err error) { + err = m.Request("GET", m.URI("users", id, "enrollments"), &enrolls, opts...) + return +} + +// RegenerateRecoveryCode removes the current multi-factor authentication recovery code and generate a new one. +// +// See: https://auth0.com/docs/api/management/v2#!/Users/post_recovery_code_regeneration +func (m *UserManager) RegenerateRecoveryCode(id string, opts ...RequestOption) (*UserRecoveryCode, error) { + r := new(UserRecoveryCode) + err := m.Request("POST", m.URI("users", id, "recovery-code-regeneration"), &r, opts...) + return r, err +} + +// InvalidateRememberBrowser invalidates all remembered browsers across all authentication factors for a user. +// +// See: https://auth0.com/docs/api/management/v2#!/Users/post_invalidate_remember_browser +func (m *UserManager) InvalidateRememberBrowser(id string, opts ...RequestOption) error { + uri := m.URI( + "users", + id, + "multifactor", + "actions", + "invalidate-remember-browser", + ) + err := m.Request("POST", uri, nil, opts...) + return err +} + // Link links two user accounts together forming a primary and secondary relationship. // // See: https://auth0.com/docs/api/management/v2#!/Users/post_identities diff --git a/vendor/modules.txt b/vendor/modules.txt index 19694df2f..c6b4496bd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -181,7 +181,7 @@ github.com/mgutz/ansi github.com/mholt/archiver/v3 # github.com/microcosm-cc/bluemonday v1.0.2 github.com/microcosm-cc/bluemonday -# github.com/mitchellh/mapstructure v1.4.1 +# github.com/mitchellh/mapstructure v1.1.2 github.com/mitchellh/mapstructure # github.com/muesli/reflow v0.1.0 github.com/muesli/reflow/ansi @@ -346,7 +346,7 @@ google.golang.org/protobuf/reflect/protoreflect google.golang.org/protobuf/reflect/protoregistry google.golang.org/protobuf/runtime/protoiface google.golang.org/protobuf/runtime/protoimpl -# gopkg.in/auth0.v5 v5.17.0 => github.com/go-auth0/auth0 v1.3.1-0.20210128024326-898cafab69ba +# gopkg.in/auth0.v5 v5.17.0 ## explicit gopkg.in/auth0.v5 gopkg.in/auth0.v5/internal/client @@ -362,4 +362,3 @@ gopkg.in/yaml.v2 # gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b ## explicit gopkg.in/yaml.v3 -# gopkg.in/auth0.v5 => github.com/go-auth0/auth0 v1.3.1-0.20210128024326-898cafab69ba