From 4e3dfdab497b616a780073d5505452716496b465 Mon Sep 17 00:00:00 2001 From: dasha Date: Sat, 13 May 2023 13:29:35 +0400 Subject: [PATCH] =?UTF-8?q?=D1=8F=20=D0=BD=D0=B0=D0=B4=D0=B5=D1=8E=D1=81?= =?UTF-8?q?=D1=8C=20=D1=8D=D1=82=D0=BE=20=D0=B2=D1=81=D0=B5=20=D0=B8=20?= =?UTF-8?q?=D0=BD=D0=B8=D1=87=D0=B5=D0=B3=D0=BE=20=D0=BD=D0=B5=20=D1=81?= =?UTF-8?q?=D0=BB=D0=BE=D0=BC=D0=B0=D0=B5=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 7 +- front/src/App.js | 63 ++--- front/src/pages/Films.jsx | 181 +++++++----- front/src/pages/Orders.jsx | 155 ++++++----- front/src/pages/Registration.jsx | 181 +++++------- front/src/pages/Sessions.jsx | 171 +++++++----- front/src/pages/Users.jsx | 181 ++++++++++++ front/src/pages/components/Header.jsx | 123 +++++++-- front/src/pages/components/PrivateRoutes.jsx | 16 ++ front/src/styles/index.css | 11 + .../configuration/OpenAPI30Configuration.java | 28 ++ .../PasswordEncoderConfiguration.java | 14 + .../configuration/SecurityConfiguration.java | 87 ++++++ .../{ => configuration}/WebConfiguration.java | 30 +- .../app/configuration/jwt/JwtException.java | 11 + .../app/configuration/jwt/JwtFilter.java | 71 +++++ .../app/configuration/jwt/JwtProperties.java | 27 ++ .../app/configuration/jwt/JwtProvider.java | 107 ++++++++ .../student/controller/CinemaController.java | 5 + .../controller/CustomerController.java | 81 ++++-- .../student/controller/OrderController.java | 4 +- .../student/controller/SessionController.java | 8 +- .../app/student/controller/UserSignupDto.java | 31 +++ .../labwork1/app/student/model/Customer.java | 18 ++ .../labwork1/app/student/model/UserRole.java | 20 ++ .../repository/CustomerRepository.java | 1 + .../service/CustomerNotFoundException.java | 3 + .../app/student/service/CustomerService.java | 79 +++++- .../app/student/service/OrderService.java | 9 + .../app/student/service/SessionService.java | 11 +- .../student/service/UserExistsException.java | 7 + .../util/validation/ValidationException.java | 4 + src/main/resources/application.properties | 4 +- .../com/labwork1/app/JpaCustomerTests.java | 258 +++++++++--------- 34 files changed, 1457 insertions(+), 550 deletions(-) create mode 100644 front/src/pages/Users.jsx create mode 100644 front/src/pages/components/PrivateRoutes.jsx create mode 100644 src/main/java/com/labwork1/app/configuration/OpenAPI30Configuration.java create mode 100644 src/main/java/com/labwork1/app/configuration/PasswordEncoderConfiguration.java create mode 100644 src/main/java/com/labwork1/app/configuration/SecurityConfiguration.java rename src/main/java/com/labwork1/app/{ => configuration}/WebConfiguration.java (59%) create mode 100644 src/main/java/com/labwork1/app/configuration/jwt/JwtException.java create mode 100644 src/main/java/com/labwork1/app/configuration/jwt/JwtFilter.java create mode 100644 src/main/java/com/labwork1/app/configuration/jwt/JwtProperties.java create mode 100644 src/main/java/com/labwork1/app/configuration/jwt/JwtProvider.java create mode 100644 src/main/java/com/labwork1/app/student/controller/UserSignupDto.java create mode 100644 src/main/java/com/labwork1/app/student/model/UserRole.java create mode 100644 src/main/java/com/labwork1/app/student/service/UserExistsException.java diff --git a/build.gradle b/build.gradle index 7e8766c..b374d68 100644 --- a/build.gradle +++ b/build.gradle @@ -19,11 +19,16 @@ jar { dependencies { implementation(project(':front')) + annotationProcessor "org.springframework.boot:spring-boot-configuration-processor" + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'com.h2database:h2:2.1.210' implementation 'org.springframework.boot:spring-boot-starter-validation' implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5' - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'com.auth0:java-jwt:4.4.0' testImplementation 'org.springframework.boot:spring-boot-starter-test' implementation 'org.hibernate.validator:hibernate-validator' diff --git a/front/src/App.js b/front/src/App.js index 173405f..5c161f9 100644 --- a/front/src/App.js +++ b/front/src/App.js @@ -1,4 +1,4 @@ -import { useRoutes, Outlet, BrowserRouter } from 'react-router-dom' +import {BrowserRouter, Route, Routes} from 'react-router-dom' import Films from './pages/Films' import FilmPage from './pages/FilmPage' import Header from './pages/components/Header' @@ -7,39 +7,40 @@ import SearchSame from './pages/SearchSame' import Registration from './pages/Registration' import Sessions from './pages/Sessions' import Orders from './pages/Orders' - -function Router(props) { - return useRoutes(props.rootRoute); -} +import Users from "./pages/Users"; +import PrivateRoutes from "./pages/components/PrivateRoutes"; export default function App() { - const routes = [ - { index: true, element: }, - { path: '/films', element: , label: 'Главная' }, - { path: '/registration', element: , label: 'Регистрация' }, - { path: '/sessions', element: , label: 'Сеансы' }, - { path: '/orders', element: , label: 'Заказы' }, - { path: '/films/:id', element: }, - { path: '/search-same/:request', element: } - ]; - const links = routes.filter(route => route.hasOwnProperty('label')); - const rootRoute = [ - { path: '/', element: render(links), children: routes } - ]; + const links = [ + {path: 'films', label: 'Главная', userAccess: 'NONE'}, + {path: 'registration', label: 'Регистрация', userAccess: 'NONE'}, + {path: 'entry', label: 'Вход', userAccess: 'NONE'}, + {path: 'users', label: 'Пользователи', userAccess: 'ADMIN'}, + {path: 'sessions', label: 'Сеансы', userAccess: 'NONE'}, + {path: 'orders', label: 'Заказы', userAccess: 'USER'} + ]; - function render(links) { return ( - <> -
- -