Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
-Cambio en la versión de Spring Boot
-Creación de perfiles para producción y desarrollo
  • Loading branch information
Marc0Franc0 committed Feb 16, 2024
1 parent 0f1e5a5 commit 6d4dc5d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 27 deletions.
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Proyecto de muestra sobre cómo implementar la seguridad con autenticación JWT
- Autorización basada en roles con Spring Security

## Tecnologías
- Spring Boot 3.0
- Spring Boot 3.1.4
- Spring Security
- JSON Web Tokens (JWT)
- BCrypt
Expand All @@ -26,16 +26,11 @@ Para construir y ejecutar la aplicación necesita:
- [JDK 17+](https://www.oracle.com/java/technologies/downloads/#java17)
- [Maven 3+](https://maven.apache.org)

Configurar datos de la base de datos MySQL: [application.properties](https://github.com/Marc0Franc0/School-Management/blob/main/src/main/resources/application.properties)
Configurar perfil (producción o desarrollo):[application.properties](https://github.com/Marc0Franc0/User-Api-Jwt/blob/main/src/main/resources/application.properties)

Configurar JWT: [application.properties](https://github.com/Marc0Franc0/School-Management/blob/main/src/main/resources/application.properties)
- jwt.secret.key = esYG4cI3/jsQ1f3b+25mesq9nXsN7kIU45hPr27FyRxMd7WteShs/5VnXv1YfgMR
(Se utiliza para firmar los tokens)
- jwt.time.expiration = 86400000 (equivalente a un día)
Configurar variables de entorno para producción: [application-prod.properties](https://github.com/Marc0Franc0/User-Api-Jwt/blob/main/src/main/resources/application-prod.properties)

Configurar usuario admin:
- user.admin.username = nombre_de_usuario_admin
- user.admin.password = contraseña_de_usuario_admin
Configurar variables de entorno para desarrollo: [application-dev.properties](https://github.com/Marc0Franc0/User-Api-Jwt/blob/main/src/main/resources/application-dev.properties)

Ejecutar localmente

Expand All @@ -46,6 +41,5 @@ mvn clean install
mvn spring-boot:run
```

Dirigirse a:
- [http://localhost:8080/](http://localhost:8080/)
- [http://localhost:8080/swagger-ui/index.html](http://localhost:8080/swagger-ui/index.html)
Dirigirse a:
- [Documentación Swagger](http://localhost:8080/swagger-ui/index.html)
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.2</version>
<version>3.1.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.app</groupId>
Expand Down Expand Up @@ -55,7 +55,8 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
<version>1.18.30</version>
<optional>provided</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
13 changes: 13 additions & 0 deletions src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Configuración base de datos
spring.datasource.url= jdbc:mysql://localhost:3306/users
spring.datasource.username= root
spring.datasource.password=
spring.datasource.jpa.hibernate.ddl-auto= update

#Configuración usuario administrador
user.admin.username= marco
user.admin.password= 1234

#Configuración JWT
jwt.secret.key= esYG4cI3/jsQ1f3b+25mesq9nXsN7kIU45hPr27FyRxMd7WteShs/5VnXv1YfgMR
jwt.secret.time.expiration= 86400000
14 changes: 14 additions & 0 deletions src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

#Configuración base de datos
spring.datasource.url= ${SPRING_DATASOURCE_URL}
spring.datasource.username= ${SPRING_DATASOURCE_USERNAME}
spring.datasource.password= ${SPRING_DATASOURCE_PASSWORD}
spring.datasource.jpa.hibernate.ddl-auto= ${SPRING_JPA_HIBERNATE_DDL_AUTO}

#Configuración usuario administrador
user.admin.username= ${USER_ADMIN_USERNAME}
user.admin.password= ${USER_ADMIN_PASSWORD}

#Configuración JWT
jwt.secret.key= ${JWT_SECRET_KEY}
jwt.secret.time.expiration= ${JWT_TIME_EXPIRATION}
17 changes: 4 additions & 13 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
#Configuración base de datos
spring.datasource.url: ${SPRING_DATASOURCE_URL}
spring.datasource.username: ${SPRING_DATASOURCE_USERNAME}
spring.datasource.password: ${SPRING_DATASOURCE_PASSWORD}
spring.datasource.jpa.hibernate.ddl-auto: ${SPRING_JPA_HIBERNATE_DDL_AUTO}

#Configuración usuario administrador
user.admin.username: ${USER_ADMIN_USERNAME}
user.admin.password: ${USER_ADMIN_PASSWORD}

#Configuración JWT
jwt.secret.key: ${JWT_SECRET_KEY}
jwt.secret.time.expiration: ${JWT_TIME_EXPIRATION}
spring.profiles.active = ${SPRING_PROFILES_ACTIVE}
#Permite establecer utf8 en la documentación
server.servlet.encoding.force-response=true
server.servlet.encoding.charset=UTF-8

0 comments on commit 6d4dc5d

Please sign in to comment.