mirror of
https://github.com/SigNoz/signoz.git
synced 2026-03-13 08:13:22 +08:00
@@ -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:
|
||||
|
||||
@@ -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"},
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user