Skip to content

Commit 2a74a5d

Browse files
authored
feat(auth): Remove auto creation of organizations (#967)
Signed-off-by: Javier Rodriguez <[email protected]>
1 parent c95b180 commit 2a74a5d

File tree

15 files changed

+429
-162
lines changed

15 files changed

+429
-162
lines changed

app/cli/cmd/organization_list.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import (
2424
"github.com/spf13/cobra"
2525
)
2626

27+
const UserWithNoOrganizationMsg = "you are not part of any organization, please run \"chainloop organization create --name ORG_NAME\" to create one"
28+
2729
func newOrganizationList() *cobra.Command {
2830
cmd := &cobra.Command{
2931
Use: "list",
@@ -44,7 +46,7 @@ func newOrganizationList() *cobra.Command {
4446

4547
func orgMembershipTableOutput(items []*action.MembershipItem) error {
4648
if len(items) == 0 {
47-
fmt.Println("you have no access to any organization yet")
49+
fmt.Println(UserWithNoOrganizationMsg)
4850
return nil
4951
}
5052

app/cli/cmd/organization_member_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func newOrganizationMemberList() *cobra.Command {
4444

4545
func orgMembershipsTableOutput(items []*action.MembershipItem) error {
4646
if len(items) == 0 {
47-
fmt.Println("you have no access to any organization yet")
47+
fmt.Println(UserWithNoOrganizationMsg)
4848
return nil
4949
}
5050

app/cli/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ func errorInfo(err error, logger zerolog.Logger) (string, int) {
6767
msg = "your authentication token has expired, please run chainloop auth login again"
6868
case isWrappedErr(st, jwtMiddleware.ErrMissingJwtToken):
6969
msg = "authentication required, please run \"chainloop auth login\""
70+
case v1.IsUserWithNoMembershipErrorNotInOrg(err):
71+
msg = cmd.UserWithNoOrganizationMsg
7072
case errors.As(err, &cmd.GracefulError{}):
7173
// Graceful recovery if the flag is set and the received error is marked as recoverable
7274
if cmd.GracefulExit {

app/controlplane/api/controlplane/v1/response_messages.pb.go

Lines changed: 108 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/controlplane/v1/response_messages.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,9 @@ enum AllowListError {
191191
ALLOW_LIST_ERROR_UNSPECIFIED = 0;
192192
ALLOW_LIST_ERROR_NOT_IN_LIST = 1 [(errors.code) = 403];
193193
}
194+
195+
enum UserWithNoMembershipError {
196+
option (errors.default_code) = 500;
197+
USER_WITH_NO_MEMBERSHIP_ERROR_UNSPECIFIED = 0;
198+
USER_WITH_NO_MEMBERSHIP_ERROR_NOT_IN_ORG = 1 [(errors.code) = 403];
199+
}

app/controlplane/api/controlplane/v1/response_messages_errors.pb.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)