MSP-8520 rename sudir to oauth
This commit is contained in:
1 parent
c32459f73d
commit
5bd389757c
23 files changed
+254
-252
No files matched your search
+12
-12
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
type authService interface {
|
||||
Login(ctx context.Context, request domain.LoginRequest) (*domain.LoginResponse, error)
|
||||
LoginWithSudir(ctx context.Context, request domain.LoginSudirRequest) (*domain.LoginResponse, error)
|
||||
LoginWithOauth(ctx context.Context, request domain.LoginOauthRequest) (*domain.LoginResponse, error)
|
||||
Logout(ctx context.Context, adminId int64, request *domain.LogoutRequest) error
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ func (a Auth) Login(ctx context.Context, authRequest domain.LoginRequest) (*doma
|
||||
auth, err := a.authService.Login(ctx, authRequest)
|
||||
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrSudirAuthorization):
|
||||
case errors.Is(err, domain.ErrOauthAuthorization):
|
||||
return nil, status.Error(codes.InvalidArgument, "plain auth is not available")
|
||||
case errors.Is(err, domain.ErrUnauthenticated):
|
||||
a.logger.Error(ctx, err.Error())
|
||||
@@ -113,28 +113,28 @@ func (a Auth) Login(ctx context.Context, authRequest domain.LoginRequest) (*doma
|
||||
}
|
||||
}
|
||||
|
||||
// LoginWithSudir
|
||||
// LoginWithOauth
|
||||
// @Tags auth
|
||||
// @Summary Авторизация по авторизационному коду от СУДИР
|
||||
// @Summary Авторизация по авторизационному коду от OAuth
|
||||
// @Description Авторизация с получением токена администратора
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.LoginSudirRequest true "Тело запроса"
|
||||
// @Param body body domain.LoginOauthRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.LoginResponse
|
||||
// @Failure 401 {object} domain.GrpcError "Некорректный код для авторизации или неизвестное название клиента"
|
||||
// @Failure 412 {object} domain.GrpcError "Авторизация СУДИР не настроена на сервере"
|
||||
// @Failure 412 {object} domain.GrpcError "Авторизация OAuth не настроена на сервере"
|
||||
// @Failure 500 {object} domain.GrpcError
|
||||
// @Router /auth/login_with_sudir [POST]
|
||||
func (a Auth) LoginWithSudir(ctx context.Context, request domain.LoginSudirRequest) (*domain.LoginResponse, error) {
|
||||
auth, err := a.authService.LoginWithSudir(ctx, request)
|
||||
// @Router /auth/login_with_oauth [POST]
|
||||
func (a Auth) LoginWithOauth(ctx context.Context, request domain.LoginOauthRequest) (*domain.LoginResponse, error) {
|
||||
auth, err := a.authService.LoginWithOauth(ctx, request)
|
||||
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrSudirAuthIsMissed):
|
||||
return nil, status.Error(codes.FailedPrecondition, "sudir auth is not configured")
|
||||
case errors.Is(err, domain.ErrOauthIsMissed):
|
||||
return nil, status.Error(codes.FailedPrecondition, "oauth is not configured")
|
||||
case errors.Is(err, domain.ErrUnauthenticated):
|
||||
return nil, status.Error(codes.Unauthenticated, "invalid code")
|
||||
case err != nil:
|
||||
return nil, errors.WithMessage(err, "login with sudir")
|
||||
return nil, errors.WithMessage(err, "login with oauth")
|
||||
default:
|
||||
return auth, nil
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type UiSettingsService interface {
|
||||
SudirSettings(ctx context.Context, req domain.ClientNameRequest) (*domain.UiSudirSetting, error)
|
||||
OauthSettings(ctx context.Context, req domain.ClientNameRequest) (*domain.UiOauthSetting, error)
|
||||
}
|
||||
|
||||
type UiSettings struct {
|
||||
@@ -23,20 +23,20 @@ func NewUiSettings(service UiSettingsService) UiSettings {
|
||||
}
|
||||
}
|
||||
|
||||
// UiSudirSettings
|
||||
// UiOauthSettings
|
||||
// @Tags ui_settings
|
||||
// @Summary Получение настроек для ui для авторизации через СУДИР
|
||||
// @Description Получение настроек для ui для авторизации через СУДИР
|
||||
// @Summary Получение настроек для ui для авторизации через OAuth
|
||||
// @Description Получение настроек для ui для авторизации через OAuth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.ClientNameRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.UiSudirSetting
|
||||
// @Success 200 {object} domain.UiOauthSetting
|
||||
// @Failure 400 {object} domain.GrpcError
|
||||
// @Failure 401 {object} domain.GrpcError "Неизвестное название клиента"
|
||||
// @Failure 500 {object} domain.GrpcError
|
||||
// @Router /ui_settings/sudir [POST]
|
||||
func (c UiSettings) SudirSettings(ctx context.Context, req domain.ClientNameRequest) (*domain.UiSudirSetting, error) {
|
||||
resp, err := c.service.SudirSettings(ctx, req)
|
||||
// @Router /ui_settings/oauth [POST]
|
||||
func (c UiSettings) OauthSettings(ctx context.Context, req domain.ClientNameRequest) (*domain.UiOauthSetting, error) {
|
||||
resp, err := c.service.OauthSettings(ctx, req)
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrUnknownClient):
|
||||
return nil, status.Error(codes.Unauthenticated, "invalid client name")
|
||||
|
||||
Reference in new issue
Block a user