diff --git a/docs/api/openapi.yml b/docs/api/openapi.yml index 9a1bf240d0..a9c287ab28 100644 --- a/docs/api/openapi.yml +++ b/docs/api/openapi.yml @@ -1007,43 +1007,6 @@ paths: summary: Create bulk invite tags: - users - /api/v1/login: - post: - deprecated: true - description: This endpoint is deprecated and will be removed in the future - operationId: DeprecatedCreateSessionByEmailPassword - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AuthtypesDeprecatedPostableLogin' - responses: - "200": - content: - application/json: - schema: - properties: - data: - $ref: '#/components/schemas/AuthtypesDeprecatedGettableLogin' - status: - type: string - type: object - description: OK - "400": - content: - application/json: - schema: - $ref: '#/components/schemas/RenderErrorResponse' - description: Bad Request - "500": - content: - application/json: - schema: - $ref: '#/components/schemas/RenderErrorResponse' - description: Internal Server Error - summary: Deprecated create session by email password - tags: - - sessions /api/v1/logs/promote_paths: get: deprecated: false @@ -3143,20 +3106,6 @@ components: url: type: string type: object - AuthtypesDeprecatedGettableLogin: - properties: - accessJwt: - type: string - userId: - type: string - type: object - AuthtypesDeprecatedPostableLogin: - properties: - email: - type: string - password: - type: string - type: object AuthtypesGettableAuthDomain: properties: authNProviderInfo: diff --git a/pkg/apiserver/signozapiserver/session.go b/pkg/apiserver/signozapiserver/session.go index 8dd8c19c27..edbad3fbb2 100644 --- a/pkg/apiserver/signozapiserver/session.go +++ b/pkg/apiserver/signozapiserver/session.go @@ -10,23 +10,6 @@ import ( ) func (provider *provider) addSessionRoutes(router *mux.Router) error { - if err := router.Handle("/api/v1/login", handler.New(provider.authZ.OpenAccess(provider.sessionHandler.DeprecatedCreateSessionByEmailPassword), handler.OpenAPIDef{ - ID: "DeprecatedCreateSessionByEmailPassword", - Tags: []string{"sessions"}, - Summary: "Deprecated create session by email password", - Description: "This endpoint is deprecated and will be removed in the future", - Request: new(authtypes.DeprecatedPostableLogin), - RequestContentType: "application/json", - Response: new(authtypes.DeprecatedGettableLogin), - ResponseContentType: "application/json", - SuccessStatusCode: http.StatusOK, - ErrorStatusCodes: []int{http.StatusBadRequest}, - Deprecated: true, - SecuritySchemes: []handler.OpenAPISecurityScheme{}, - })).Methods(http.MethodPost).GetError(); err != nil { - return err - } - if err := router.Handle("/api/v2/sessions/email_password", handler.New(provider.authZ.OpenAccess(provider.sessionHandler.CreateSessionByEmailPassword), handler.OpenAPIDef{ ID: "CreateSessionByEmailPassword", Tags: []string{"sessions"}, diff --git a/pkg/modules/session/implsession/handler.go b/pkg/modules/session/implsession/handler.go index efb6ff6b97..86ad71e0e3 100644 --- a/pkg/modules/session/implsession/handler.go +++ b/pkg/modules/session/implsession/handler.go @@ -47,28 +47,6 @@ func (handler *handler) GetSessionContext(rw http.ResponseWriter, req *http.Requ render.Success(rw, http.StatusOK, sessionContext) } -func (handler *handler) DeprecatedCreateSessionByEmailPassword(rw http.ResponseWriter, req *http.Request) { - ctx, cancel := context.WithTimeout(req.Context(), 15*time.Second) - defer cancel() - - body := new(authtypes.DeprecatedPostableLogin) - if err := binding.JSON.BindBody(req.Body, body); err != nil { - render.Error(rw, err) - return - } - - token, err := handler.module.DeprecatedCreateSessionByEmailPassword(ctx, body.Email, body.Password) - if err != nil { - render.Error(rw, err) - return - } - - render.Success(rw, http.StatusOK, &authtypes.DeprecatedGettableLogin{ - AccessJWT: token.AccessToken, - UserID: token.UserID.String(), - }) -} - func (handler *handler) CreateSessionByEmailPassword(rw http.ResponseWriter, req *http.Request) { ctx, cancel := context.WithTimeout(req.Context(), 15*time.Second) defer cancel() diff --git a/pkg/modules/session/implsession/module.go b/pkg/modules/session/implsession/module.go index fe573847b3..97d9d2439d 100644 --- a/pkg/modules/session/implsession/module.go +++ b/pkg/modules/session/implsession/module.go @@ -107,30 +107,6 @@ func (module *module) GetSessionContext(ctx context.Context, email valuer.Email, return context, nil } -func (module *module) DeprecatedCreateSessionByEmailPassword(ctx context.Context, email valuer.Email, password string) (*authtypes.Token, error) { - users, err := module.userGetter.GetUsersByEmail(ctx, email) - if err != nil { - return nil, err - } - - if len(users) == 0 { - return nil, errors.New(errors.TypeUnauthenticated, types.ErrCodeIncorrectPassword, "invalid email or password") - } - - factorPassword, err := module.userGetter.GetFactorPasswordByUserID(ctx, users[0].ID) - if err != nil { - return nil, err - } - - if !factorPassword.Equals(password) { - return nil, errors.New(errors.TypeUnauthenticated, types.ErrCodeIncorrectPassword, "invalid email or password") - } - - identity := authtypes.NewIdentity(users[0].ID, users[0].OrgID, users[0].Email, users[0].Role) - - return module.tokenizer.CreateToken(ctx, identity, map[string]string{}) -} - func (module *module) CreatePasswordAuthNSession(ctx context.Context, authNProvider authtypes.AuthNProvider, email valuer.Email, password string, orgID valuer.UUID) (*authtypes.Token, error) { passwordAuthN, err := getProvider[authn.PasswordAuthN](authNProvider, module.authNs) if err != nil { diff --git a/pkg/modules/session/session.go b/pkg/modules/session/session.go index 3b3dc40872..b0367be642 100644 --- a/pkg/modules/session/session.go +++ b/pkg/modules/session/session.go @@ -11,9 +11,6 @@ import ( ) type Module interface { - // This is soon be removed. - DeprecatedCreateSessionByEmailPassword(ctx context.Context, email valuer.Email, password string) (*authtypes.Token, error) - // Gets the session context for the user. The context contains information on what the user has to do in order to create a session. GetSessionContext(ctx context.Context, email valuer.Email, siteURL *url.URL) (*authtypes.SessionContext, error) @@ -37,9 +34,6 @@ type Handler interface { // Get the session context for the user. GetSessionContext(http.ResponseWriter, *http.Request) - // Create a session for a user using email and password. - DeprecatedCreateSessionByEmailPassword(http.ResponseWriter, *http.Request) - // Create a session for a user using email and password. CreateSessionByEmailPassword(http.ResponseWriter, *http.Request) diff --git a/pkg/types/authtypes/session.go b/pkg/types/authtypes/session.go index 209381e08e..29ce7ad5f4 100644 --- a/pkg/types/authtypes/session.go +++ b/pkg/types/authtypes/session.go @@ -5,16 +5,6 @@ import ( "github.com/SigNoz/signoz/pkg/valuer" ) -type DeprecatedPostableLogin struct { - Email valuer.Email `json:"email"` - Password string `json:"password"` -} - -type DeprecatedGettableLogin struct { - AccessJWT string `json:"accessJwt"` - UserID string `json:"userId"` -} - type SessionContext struct { Exists bool `json:"exists"` Orgs []*OrgSessionContext `json:"orgs"`