Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Cli 148 #280

Merged
merged 41 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4a33c7e
[CLI-148] initial commit: user show, create, list
Apr 30, 2021
1ea48f6
[CLI-148] refactor: users command
May 3, 2021
b5138ff
[CLI-148] refactor users command: add error return value
May 3, 2021
b14abdf
Merge branch 'main' into CLI-148
bright-poku May 3, 2021
0520af1
Update internal/cli/users.go
bright-poku May 3, 2021
06d8b0a
[CLI-148] refactor: add suggestions from review
May 4, 2021
36f4a49
Merge branch 'main' into CLI-148
bright-poku May 4, 2021
528b075
[CLI-148] refactor
May 4, 2021
efdf7d9
Merge branch 'CLI-148' of github.com:auth0/auth0-cli into CLI-148
May 4, 2021
1fb585e
[CLI-148] refactor: run gofmt on users files
May 4, 2021
ae549e1
[CLI-148] refactor: cleanup whitespaces
May 4, 2021
07c73aa
[CLI-148] refactored getconnrequusername function
May 4, 2021
c807b80
[CLI-148] refactor: run gofmt on project user files
May 5, 2021
89e8a4a
[CLI-148] refactor: added code review suggestions
May 7, 2021
b112ddd
Merge branch 'main' into CLI-148
bright-poku May 7, 2021
d583efa
[CLI-148] refactor: add users open command
May 7, 2021
d87decf
Merge branch 'CLI-148' of github.com:auth0/auth0-cli into CLI-148
May 7, 2021
8679b8d
[CLI-148] refactor: gofmt to cleanup
May 7, 2021
97d67f5
Apply suggestions from code review
Widcket May 7, 2021
ef74b98
[CLI-148] refactor: password input
May 10, 2021
9f51ca0
Merge branch 'CLI-148' of github.com:auth0/auth0-cli into CLI-148
May 10, 2021
7c21f4d
[CLI-148] refactor: cleanup spaces
May 10, 2021
f7c25a8
[CLI-148] refactor: sort imports
May 10, 2021
08a3df0
Merge branch 'main' into CLI-148
bright-poku May 10, 2021
c8ffee6
Merge branch 'main' into CLI-148
bright-poku May 10, 2021
d74e2d8
[CLI-148] refactor: sync with master
May 10, 2021
e849df5
Merge branch 'main' into CLI-148
bright-poku May 10, 2021
4e8007c
[CLI-148] refactor: updated set of scopes
May 10, 2021
4aac3b5
[CLI-148] refactor: updated order of scopes
May 10, 2021
f44f444
[CLI-148] refactor: updated scopes in auth file
May 10, 2021
aa381aa
[CLi-148] refactor: clean up comments
May 11, 2021
73c2c8b
Merge branch 'main' into CLI-148
bright-poku May 12, 2021
e2e649e
[CLi-148] refactor: updated scopes to match main branch
May 12, 2021
b83b5c8
Merge branch 'main' into CLI-148
bright-poku May 12, 2021
cd1e2b2
[CLi-148] refactor: cleanup
May 12, 2021
0555fcb
workflow test
May 12, 2021
a2c707c
workflow add back integration
May 12, 2021
3a8db6e
workflow comment out integration
May 13, 2021
811f879
[CLI-148] updated scopes in config generator
May 13, 2021
f59c51a
Update internal/cli/users.go
Widcket May 14, 2021
377386c
Fix 400 error
Widcket May 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ tags
# misc
.vscode
.DS_Store
.idea
3 changes: 2 additions & 1 deletion internal/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ var requiredScopes = []string{
"create:clients", "delete:clients", "read:clients", "update:clients",
"create:resource_servers", "delete:resource_servers", "read:resource_servers", "update:resource_servers",
"create:rules", "delete:rules", "read:rules", "update:rules",
"read:users", "update:users",
"read:client_keys", "read:logs", "read:connections", "update:connections",
"create:users", "delete:users", "read:users", "update:users",
"read:branding", "update:branding",
"read:client_keys", "read:logs", "read:tenant_settings", "read:custom_domains",
}
Expand Down
2 changes: 2 additions & 0 deletions internal/auth0/auth0.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type API struct {
Rule RuleAPI
Tenant TenantAPI
User UserAPI
Connection ConnectionAPI
}

func NewAPI(m *management.Management) *API {
Expand All @@ -36,6 +37,7 @@ func NewAPI(m *management.Management) *API {
Rule: m.Rule,
Tenant: m.Tenant,
User: m.User,
Connection: m.Connection,
}
}

Expand Down
26 changes: 26 additions & 0 deletions internal/auth0/connection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//go:generate mockgen -source=connection.go -destination=connection.go -package=auth0

package auth0

import "gopkg.in/auth0.v5/management"

type ConnectionAPI interface {

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

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

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

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

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

// List all connections.
List(opts ...management.RequestOption) (ul *management.ConnectionList, err error)
}
18 changes: 18 additions & 0 deletions internal/auth0/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,22 @@ type UserAPI interface {
// Unblock a user that was blocked due to an excessive amount of incorrectly
// provided credentials.
Unblock(id string, opts ...management.RequestOption) error

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

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

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

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

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

// Search for users
Search(opts ...management.RequestOption) (us *management.UserList, err error)
}
18 changes: 18 additions & 0 deletions internal/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ func (f *Flag) EditorPromptU(cmd *cobra.Command, value *string, initialValue, fi
return nil
}

func (f *Flag) AskPassword(cmd *cobra.Command, value *string, defaultValue *string) error {
return askPasswordFlag(cmd, f, value, defaultValue, false)
}

func (f *Flag) AskPasswordU(cmd *cobra.Command, value *string, defaultValue *string) error {
return askPasswordFlag(cmd, f, value, defaultValue, true)
}

func (f *Flag) RegisterString(cmd *cobra.Command, value *string, defaultValue string) {
registerString(cmd, f, value, defaultValue, false)
}
Expand Down Expand Up @@ -206,6 +214,16 @@ func selectFlag(cmd *cobra.Command, f *Flag, value interface{}, options []string
return nil
}

func askPasswordFlag(cmd *cobra.Command, f *Flag, value *string, defaultValue *string, isUpdate bool) error {
if shouldAsk(cmd, f, isUpdate) {
if err := askPassword(cmd, f, value, defaultValue, isUpdate); err != nil {
return err
}
}

return nil
}

func registerString(cmd *cobra.Command, f *Flag, value *string, defaultValue string, isUpdate bool) {
cmd.Flags().StringVarP(value, f.LongForm, f.ShortForm, defaultValue, f.Help)

Expand Down
11 changes: 11 additions & 0 deletions internal/cli/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ func askBool(cmd *cobra.Command, i commandInput, value *bool, defaultValue *bool
return nil
}

func askPassword(cmd *cobra.Command, i commandInput, value interface{}, defaultValue *string, isUpdate bool) error {
isRequired := !isUpdate && i.GetIsRequired()
input := prompt.Password("", i.GetLabel(), auth0.StringValue(defaultValue), isRequired)

if err := prompt.AskOne(input, value); err != nil {
return handleInputError(err)
}

return nil
}

func _select(cmd *cobra.Command, i commandInput, value interface{}, options []string, defaultValue *string, isUpdate bool) error {
isRequired := !isUpdate && i.GetIsRequired()

Expand Down
Loading