Skip to content

Commit 7e118de

Browse files
Merge branch 'main' into dex-config-namespace
2 parents 965a986 + ad5d637 commit 7e118de

File tree

189 files changed

+1916
-1903
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+1916
-1903
lines changed

App.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,22 @@ import (
2121
"context"
2222
"crypto/tls"
2323
"fmt"
24-
"github.com/devtron-labs/devtron/api/util"
25-
"github.com/devtron-labs/devtron/client/telemetry"
26-
"github.com/devtron-labs/devtron/otel"
2724
"log"
2825
"net/http"
2926
"os"
3027
"time"
3128

29+
"github.com/devtron-labs/devtron/api/util"
30+
"github.com/devtron-labs/devtron/client/telemetry"
31+
"github.com/devtron-labs/devtron/otel"
32+
"github.com/devtron-labs/devtron/pkg/auth/user"
33+
3234
"github.com/casbin/casbin"
3335
authMiddleware "github.com/devtron-labs/authenticator/middleware"
3436
pubsub "github.com/devtron-labs/common-lib/pubsub-lib"
3537
"github.com/devtron-labs/devtron/api/router"
3638
"github.com/devtron-labs/devtron/api/sse"
3739
"github.com/devtron-labs/devtron/internal/middleware"
38-
"github.com/devtron-labs/devtron/pkg/user"
3940
"github.com/go-pg/pg"
4041
_ "github.com/lib/pq"
4142
"go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux"

Wire.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import (
3030
appStoreDeployment "github.com/devtron-labs/devtron/api/appStore/deployment"
3131
appStoreDiscover "github.com/devtron-labs/devtron/api/appStore/discover"
3232
appStoreValues "github.com/devtron-labs/devtron/api/appStore/values"
33+
"github.com/devtron-labs/devtron/api/auth/sso"
34+
"github.com/devtron-labs/devtron/api/auth/user"
3335
chartRepo "github.com/devtron-labs/devtron/api/chartRepo"
3436
"github.com/devtron-labs/devtron/api/cluster"
3537
"github.com/devtron-labs/devtron/api/connector"
@@ -46,10 +48,8 @@ import (
4648
"github.com/devtron-labs/devtron/api/router/pubsub"
4749
"github.com/devtron-labs/devtron/api/server"
4850
"github.com/devtron-labs/devtron/api/sse"
49-
"github.com/devtron-labs/devtron/api/sso"
5051
"github.com/devtron-labs/devtron/api/team"
5152
"github.com/devtron-labs/devtron/api/terminal"
52-
"github.com/devtron-labs/devtron/api/user"
5353
util5 "github.com/devtron-labs/devtron/api/util"
5454
webhookHelm "github.com/devtron-labs/devtron/api/webhook/helm"
5555
"github.com/devtron-labs/devtron/client/argocdServer"

api/apiToken/ApiTokenRestHandler.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ package apiToken
1919

2020
import (
2121
"encoding/json"
22+
"net/http"
23+
"strconv"
24+
2225
openapi "github.com/devtron-labs/devtron/api/openapi/openapiClient"
2326
"github.com/devtron-labs/devtron/api/restHandler/common"
2427
"github.com/devtron-labs/devtron/pkg/apiToken"
25-
"github.com/devtron-labs/devtron/pkg/user"
26-
"github.com/devtron-labs/devtron/pkg/user/casbin"
28+
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
29+
"github.com/devtron-labs/devtron/pkg/auth/user"
2730
"github.com/gorilla/mux"
2831
"github.com/juju/errors"
2932
"go.uber.org/zap"
3033
"gopkg.in/go-playground/validator.v9"
31-
"net/http"
32-
"strconv"
3334
)
3435

3536
type ApiTokenRestHandler interface {

api/appStore/AppStoreStatusTimelineRestHandler.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package appStore
22

33
import (
4+
"net/http"
5+
"strconv"
6+
47
"github.com/devtron-labs/devtron/api/restHandler/common"
58
"github.com/devtron-labs/devtron/pkg/app/status"
6-
"github.com/devtron-labs/devtron/pkg/user/casbin"
9+
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
710
"github.com/devtron-labs/devtron/util/rbac"
811
"github.com/gorilla/mux"
912
"go.uber.org/zap"
10-
"net/http"
11-
"strconv"
1213
)
1314

1415
type AppStoreStatusTimelineRestHandler interface {

api/appStore/InstalledAppRestHandler.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ import (
2222
"encoding/json"
2323
"errors"
2424
"fmt"
25+
"net/http"
26+
"strconv"
27+
"strings"
28+
"time"
29+
2530
bean2 "github.com/devtron-labs/devtron/api/bean"
2631
client "github.com/devtron-labs/devtron/api/helm-app"
2732
openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient"
@@ -35,10 +40,10 @@ import (
3540
appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean"
3641
"github.com/devtron-labs/devtron/pkg/appStore/deployment/repository"
3742
"github.com/devtron-labs/devtron/pkg/appStore/deployment/service"
43+
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
44+
"github.com/devtron-labs/devtron/pkg/auth/user"
3845
"github.com/devtron-labs/devtron/pkg/cluster"
3946
application2 "github.com/devtron-labs/devtron/pkg/k8s/application"
40-
"github.com/devtron-labs/devtron/pkg/user"
41-
"github.com/devtron-labs/devtron/pkg/user/casbin"
4247
"github.com/devtron-labs/devtron/util"
4348
"github.com/devtron-labs/devtron/util/argo"
4449
"github.com/devtron-labs/devtron/util/rbac"
@@ -47,10 +52,6 @@ import (
4752
"github.com/gorilla/mux"
4853
"go.uber.org/zap"
4954
"gopkg.in/go-playground/validator.v9"
50-
"net/http"
51-
"strconv"
52-
"strings"
53-
"time"
5455
)
5556

5657
type InstalledAppRestHandler interface {
@@ -159,12 +160,6 @@ func (handler InstalledAppRestHandlerImpl) GetAllInstalledApp(w http.ResponseWri
159160
}
160161
v := r.URL.Query()
161162
token := r.Header.Get("token")
162-
userEmailId, err := handler.userAuthService.GetEmailFromToken(token)
163-
if err != nil {
164-
handler.Logger.Errorw("error in getting user emailId from token", "userId", userId, "err", err)
165-
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
166-
return
167-
}
168163
var envIds []int
169164
envsQueryParam := v.Get("envIds")
170165
if envsQueryParam != "" {
@@ -290,8 +285,8 @@ func (handler InstalledAppRestHandlerImpl) GetAllInstalledApp(w http.ResponseWri
290285

291286
}
292287
start := time.Now()
293-
resultObjectMap1 := handler.enforcer.EnforceByEmailInBatch(userEmailId, casbin.ResourceHelmApp, casbin.ActionGet, objectArray1)
294-
resultObjectMap2 := handler.enforcer.EnforceByEmailInBatch(userEmailId, casbin.ResourceHelmApp, casbin.ActionGet, objectArray2)
288+
resultObjectMap1 := handler.enforcer.EnforceInBatch(token, casbin.ResourceHelmApp, casbin.ActionGet, objectArray1)
289+
resultObjectMap2 := handler.enforcer.EnforceInBatch(token, casbin.ResourceHelmApp, casbin.ActionGet, objectArray2)
295290
middleware.AppListingDuration.WithLabelValues("enforceByEmailInBatch", "helm").Observe(time.Since(start).Seconds())
296291
authorizedAppIdSet := make(map[string]bool)
297292
//O(n) time loop , at max we will only iterate through all the apps

api/appStore/chartProvider/ChartProviderRestHandler.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ package chartProvider
1919

2020
import (
2121
"encoding/json"
22+
"net/http"
23+
"strconv"
24+
2225
"github.com/devtron-labs/devtron/api/restHandler/common"
2326
"github.com/devtron-labs/devtron/pkg/appStore/chartProvider"
24-
"github.com/devtron-labs/devtron/pkg/user"
25-
"github.com/devtron-labs/devtron/pkg/user/casbin"
27+
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
28+
"github.com/devtron-labs/devtron/pkg/auth/user"
2629
"go.uber.org/zap"
2730
"gopkg.in/go-playground/validator.v9"
28-
"net/http"
29-
"strconv"
3031
)
3132

3233
type ChartProviderRestHandler interface {
@@ -38,9 +39,9 @@ type ChartProviderRestHandler interface {
3839
type ChartProviderRestHandlerImpl struct {
3940
Logger *zap.SugaredLogger
4041
chartProviderService chartProvider.ChartProviderService
41-
validator *validator.Validate
42-
userAuthService user.UserService
43-
enforcer casbin.Enforcer
42+
validator *validator.Validate
43+
userAuthService user.UserService
44+
enforcer casbin.Enforcer
4445
}
4546

4647
func NewChartProviderRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService user.UserService, validator *validator.Validate, chartProviderService chartProvider.ChartProviderService,

api/appStore/deployment/AppStoreDeploymentRestHandler.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ import (
2222
"encoding/json"
2323
"errors"
2424
"fmt"
25+
"net/http"
26+
"strconv"
27+
"strings"
28+
"time"
29+
2530
client "github.com/devtron-labs/devtron/api/helm-app"
2631
openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient"
2732
"github.com/devtron-labs/devtron/api/restHandler/common"
@@ -30,19 +35,15 @@ import (
3035
appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common"
3136
"github.com/devtron-labs/devtron/pkg/appStore/deployment/service"
3237
"github.com/devtron-labs/devtron/pkg/attributes"
33-
"github.com/devtron-labs/devtron/pkg/user"
34-
"github.com/devtron-labs/devtron/pkg/user/casbin"
38+
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
39+
"github.com/devtron-labs/devtron/pkg/auth/user"
3540
util2 "github.com/devtron-labs/devtron/util"
3641
"github.com/devtron-labs/devtron/util/argo"
3742
"github.com/devtron-labs/devtron/util/rbac"
3843
"github.com/go-pg/pg"
3944
"github.com/gorilla/mux"
4045
"go.uber.org/zap"
4146
"gopkg.in/go-playground/validator.v9"
42-
"net/http"
43-
"strconv"
44-
"strings"
45-
"time"
4647
)
4748

4849
const HELM_APP_UPDATE_COUNTER = "HelmAppUpdateCounter"
@@ -58,9 +59,9 @@ type AppStoreDeploymentRestHandler interface {
5859
}
5960

6061
type AppStoreDeploymentRestHandlerImpl struct {
61-
Logger *zap.SugaredLogger
62-
userAuthService user.UserService
63-
enforcer casbin.Enforcer
62+
Logger *zap.SugaredLogger
63+
userAuthService user.UserService
64+
enforcer casbin.Enforcer
6465
enforcerUtil rbac.EnforcerUtil
6566
enforcerUtilHelm rbac.EnforcerUtilHelm
6667
appStoreDeploymentService service.AppStoreDeploymentService

api/appStore/deployment/CommonDeploymentRestHandler.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import (
2121
"context"
2222
"encoding/json"
2323
"fmt"
24+
"net/http"
25+
"strconv"
26+
"time"
27+
2428
"github.com/devtron-labs/common-lib/utils/k8sObjectsUtil"
2529
client "github.com/devtron-labs/devtron/api/helm-app"
2630
openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient"
@@ -29,18 +33,15 @@ import (
2933
appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean"
3034
appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common"
3135
"github.com/devtron-labs/devtron/pkg/appStore/deployment/service"
32-
"github.com/devtron-labs/devtron/pkg/user"
33-
"github.com/devtron-labs/devtron/pkg/user/casbin"
36+
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
37+
"github.com/devtron-labs/devtron/pkg/auth/user"
3438
util2 "github.com/devtron-labs/devtron/util"
3539
"github.com/devtron-labs/devtron/util/argo"
3640
"github.com/devtron-labs/devtron/util/rbac"
3741
"github.com/gorilla/mux"
3842
"go.opentelemetry.io/otel"
3943
"go.uber.org/zap"
4044
"gopkg.in/go-playground/validator.v9"
41-
"net/http"
42-
"strconv"
43-
"time"
4445
)
4546

4647
type CommonDeploymentRestHandler interface {
@@ -50,9 +51,9 @@ type CommonDeploymentRestHandler interface {
5051
}
5152

5253
type CommonDeploymentRestHandlerImpl struct {
53-
Logger *zap.SugaredLogger
54-
userAuthService user.UserService
55-
enforcer casbin.Enforcer
54+
Logger *zap.SugaredLogger
55+
userAuthService user.UserService
56+
enforcer casbin.Enforcer
5657
enforcerUtil rbac.EnforcerUtil
5758
enforcerUtilHelm rbac.EnforcerUtilHelm
5859
appStoreDeploymentService service.AppStoreDeploymentService

api/appStore/discover/AppStoreRestHandler.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@
1818
package appStoreDiscover
1919

2020
import (
21+
"net/http"
22+
"strconv"
23+
"strings"
24+
2125
"github.com/devtron-labs/devtron/api/restHandler/common"
2226
appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean"
2327
"github.com/devtron-labs/devtron/pkg/appStore/discover/service"
24-
"github.com/devtron-labs/devtron/pkg/user"
25-
"github.com/devtron-labs/devtron/pkg/user/casbin"
28+
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
29+
"github.com/devtron-labs/devtron/pkg/auth/user"
2630
"github.com/gorilla/mux"
2731
"go.uber.org/zap"
28-
"net/http"
29-
"strconv"
30-
"strings"
3132
)
3233

3334
type AppStoreRestHandler interface {

api/appStore/values/AppStoreValuesRestHandler.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ package appStoreValues
1919

2020
import (
2121
"encoding/json"
22+
"net/http"
23+
"strconv"
24+
2225
"github.com/devtron-labs/devtron/api/restHandler/common"
2326
appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean"
2427
"github.com/devtron-labs/devtron/pkg/appStore/values/service"
25-
"github.com/devtron-labs/devtron/pkg/user"
28+
"github.com/devtron-labs/devtron/pkg/auth/user"
2629
"github.com/gorilla/mux"
2730
"go.uber.org/zap"
28-
"net/http"
29-
"strconv"
3031
)
3132

3233
type AppStoreValuesRestHandler interface {

0 commit comments

Comments
 (0)