-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add auth api to gateway, authenticated user to DL (#2104)
- Loading branch information
Showing
17 changed files
with
257 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {authSimpleSchema} from './simple-schema'; | ||
|
||
export const authSchema = { | ||
...authSimpleSchema, | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import {createAction} from '../gateway-utils'; | ||
import {defaultParamsSerializer} from '../utils'; | ||
|
||
import type {SuccessResponse} from './types/common'; | ||
import type { | ||
AddUsersRolesArgs, | ||
CreateUserArgs, | ||
CreateUserResponse, | ||
DeleteUserArgs, | ||
GetUserProfileArgs, | ||
GetUserProfileResponse, | ||
GetUsersListArgs, | ||
GetUsersListResponse, | ||
RemoveUsersRolesArgs, | ||
UpdateMyUserPasswordArgs, | ||
UpdateMyUserProfileArgs, | ||
UpdateUserPasswordArgs, | ||
UpdateUserProfileArgs, | ||
UpdateUsersRolesArgs, | ||
} from './types/users'; | ||
|
||
const PATH_PREFIX = '/v1'; | ||
|
||
export const actions = { | ||
addUsersRoles: createAction<SuccessResponse, AddUsersRolesArgs>({ | ||
method: 'POST', | ||
path: () => `${PATH_PREFIX}/management/users/roles/add`, | ||
params: ({deltas}, headers) => ({body: {deltas}, headers}), | ||
}), | ||
updateUsersRoles: createAction<SuccessResponse, UpdateUsersRolesArgs>({ | ||
method: 'POST', | ||
path: () => `${PATH_PREFIX}/management/users/roles/update`, | ||
params: ({deltas}, headers) => ({body: {deltas}, headers}), | ||
}), | ||
removeUsersRoles: createAction<SuccessResponse, RemoveUsersRolesArgs>({ | ||
method: 'POST', | ||
path: () => `${PATH_PREFIX}/management/users/roles/remove`, | ||
params: ({deltas}, headers) => ({body: {deltas}, headers}), | ||
}), | ||
createUser: createAction<CreateUserResponse, CreateUserArgs>({ | ||
method: 'POST', | ||
path: () => `${PATH_PREFIX}/management/users/create`, | ||
params: ({login, password, email, firstName, lastName, roles}, headers) => ({ | ||
body: {login, password, email, firstName, lastName, roles}, | ||
headers, | ||
}), | ||
}), | ||
deleteUser: createAction<SuccessResponse, DeleteUserArgs>({ | ||
method: 'DELETE', | ||
path: ({userId}) => `${PATH_PREFIX}/management/users/${userId}`, | ||
params: (_args, headers) => ({headers}), | ||
}), | ||
getUserProfile: createAction<GetUserProfileResponse, GetUserProfileArgs>({ | ||
method: 'GET', | ||
path: ({userId}) => `${PATH_PREFIX}/management/users/${userId}/profile`, | ||
params: (_args, headers) => ({headers}), | ||
}), | ||
updateUserProfile: createAction<SuccessResponse, UpdateUserProfileArgs>({ | ||
method: 'POST', | ||
path: ({userId}) => `${PATH_PREFIX}/management/users/${userId}/profile`, | ||
params: ({email, firstName, lastName}, headers) => ({ | ||
body: {email, firstName, lastName}, | ||
headers, | ||
}), | ||
}), | ||
updateUserPassword: createAction<SuccessResponse, UpdateUserPasswordArgs>({ | ||
method: 'POST', | ||
path: ({userId}) => `${PATH_PREFIX}/management/users/${userId}/password`, | ||
params: ({newPassword}, headers) => ({body: {newPassword}, headers}), | ||
}), | ||
|
||
getMyUserProfile: createAction<GetUserProfileResponse, undefined>({ | ||
method: 'GET', | ||
path: () => `${PATH_PREFIX}/users/me/profile`, | ||
params: (_args, headers) => ({headers}), | ||
}), | ||
updateMyUserProfile: createAction<SuccessResponse, UpdateMyUserProfileArgs>({ | ||
method: 'POST', | ||
path: () => `${PATH_PREFIX}/users/me/profile`, | ||
params: ({email, firstName, lastName}, headers) => ({ | ||
body: {email, firstName, lastName}, | ||
headers, | ||
}), | ||
}), | ||
updateMyUserPassword: createAction<SuccessResponse, UpdateMyUserPasswordArgs>({ | ||
method: 'POST', | ||
path: () => `${PATH_PREFIX}/users/me/password`, | ||
params: ({oldPassword, newPassword}, headers) => ({ | ||
body: {oldPassword, newPassword}, | ||
headers, | ||
}), | ||
}), | ||
getUsersList: createAction<GetUsersListResponse, GetUsersListArgs>({ | ||
method: 'GET', | ||
path: () => `${PATH_PREFIX}/users/list`, | ||
params: ({page, pageSize, filterString, roles}, headers) => ({ | ||
query: {page, pageSize, filterString, roles}, | ||
headers, | ||
}), | ||
paramsSerializer: defaultParamsSerializer, | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import {authSimpleSchema} from './simple-schema'; | ||
import {getServiceEndpoints} from '../../endpoints/schema'; | ||
|
||
export const authSchema = { | ||
...authSimpleSchema, | ||
import {actions} from './actions'; | ||
|
||
export default { | ||
actions, | ||
endpoints: getServiceEndpoints('auth'), | ||
serviceName: 'auth', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface SuccessResponse { | ||
done: true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import type {UserRole} from '../../../components/auth/constants/role'; | ||
|
||
export interface AddUsersRolesArgs { | ||
deltas: { | ||
role: `${UserRole}`; | ||
subjectId: string; | ||
}[]; | ||
} | ||
|
||
export interface RemoveUsersRolesArgs extends AddUsersRolesArgs {} | ||
|
||
export interface UpdateUsersRolesArgs { | ||
deltas: { | ||
oldRole: `${UserRole}`; | ||
newRole: `${UserRole}`; | ||
subjectId: string; | ||
}[]; | ||
} | ||
|
||
export interface CreateUserArgs { | ||
login: string; | ||
password: string; | ||
email?: string; | ||
firstName?: string; | ||
lastName?: string; | ||
roles?: `${UserRole}`[]; | ||
} | ||
|
||
export interface CreateUserResponse { | ||
userId: string; | ||
} | ||
|
||
export interface DeleteUserArgs { | ||
userId: string; | ||
} | ||
|
||
export interface GetUserProfileArgs { | ||
userId: string; | ||
} | ||
|
||
interface UserProfile { | ||
userId: string; | ||
login: string | null; | ||
email: string | null; | ||
firstName: string | null; | ||
lastName: string | null; | ||
roles: `${UserRole}`[]; | ||
} | ||
|
||
export interface GetUserProfileResponse { | ||
profile: UserProfile; | ||
} | ||
|
||
interface UpdateUserProfile { | ||
email?: string | null; | ||
firstName?: string | null; | ||
lastName?: string | null; | ||
} | ||
|
||
export interface UpdateUserProfileArgs extends UpdateUserProfile { | ||
userId: string; | ||
} | ||
|
||
export interface UpdateMyUserProfileArgs extends UpdateUserProfile {} | ||
|
||
export interface UpdateUserPasswordArgs { | ||
userId: string; | ||
newPassword: string; | ||
} | ||
|
||
export interface UpdateMyUserPasswordArgs { | ||
oldPassword: string; | ||
newPassword: string; | ||
} | ||
|
||
export interface GetUsersListArgs { | ||
page?: number; | ||
pageSize?: number; | ||
filterString?: string; | ||
roles?: `${UserRole}`[]; | ||
} | ||
|
||
interface GetUserList extends UserProfile { | ||
providerId: string | null; | ||
} | ||
|
||
export interface GetUsersListResponse { | ||
nextPageToken?: string; | ||
users: GetUserList[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters