Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Refactoring & Dockerizing #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ramazansakin wants to merge 13 commits into bezkoder:master
base: master
Choose a base branch
Loading
from ramazansakin:master
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
c17d3b8
feat: lombok adaptation & refactoring
ramazansakin Jul 27, 2022
474467f
chore: username is already unique and not-blank, so its enough to check
ramazansakin Jul 27, 2022
cc2ecd5
chore: clean up
ramazansakin Jul 27, 2022
0950cdd
refact: clean up
ramazansakin Jul 27, 2022
3582edc
feat: app dockerized & composed with mysql
ramazansakin Jul 27, 2022
523f6ec
feat: docker profile props added
ramazansakin Jul 27, 2022
8d5e03c
feat: docker profile removed
ramazansakin Jul 27, 2022
519f3fa
feat: docker-compose & props up
ramazansakin Jul 27, 2022
d710e94
get current changes & resolve conflicts
tienbku Sep 9, 2022
969039d
userSSL is removed not to get connection problem but it needs to be c...
ramazansakin Apr 8, 2023
5f6d3c4
SignupRequest required fields defined
ramazansakin Apr 8, 2023
5f2ae8c
pre-defined roles initialized not to get "Role not found" error
ramazansakin Apr 8, 2023
a0c2e70
docker-compose up & lombok dep added
ramazansakin Apr 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Dockerfile
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM openjdk:8-alpine
MAINTAINER "Ramazan Sakin"
ADD target/spring-boot-security-jwt-0.0.1-SNAPSHOT.jar spring-boot-security-jwt-0.0.1-SNAPSHOT.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "spring-boot-security-jwt-0.0.1-SNAPSHOT.jar"]
49 changes: 34 additions & 15 deletions README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
## User Registration, User Login and Authorization process.
The diagram shows flow of how we implement User Registration, User Login and Authorization process.

![spring-boot-jwt-authentication-spring-security-flow](spring-boot-jwt-authentication-spring-security-flow.png)
![spring-boot-jwt-authentication-spring-security-flow](misc/spring-boot-jwt-authentication-spring-security-flow.png)

## Spring Boot Server Architecture with Spring Security
You can have an overview of our Spring Boot Server with the diagram below:

![spring-boot-jwt-authentication-spring-security-architecture](spring-boot-jwt-authentication-spring-security-architecture.png)
![spring-boot-jwt-authentication-spring-security-architecture](misc/spring-boot-jwt-authentication-spring-security-architecture.png)

For more detail, please visit:
> [Secure Spring Boot App with Spring Security & JWT Authentication](https://bezkoder.com/spring-boot-jwt-authentication/)
Expand All @@ -17,10 +17,31 @@ For more detail, please visit:

## Refresh Token

![spring-boot-refresh-token-jwt-example-flow](spring-boot-refresh-token-jwt-example-flow.png)
![spring-boot-refresh-token-jwt-example-flow](misc/spring-boot-refresh-token-jwt-example-flow.png)

For instruction: [Spring Boot Refresh Token with JWT example](https://bezkoder.com/spring-boot-refresh-token-jwt/)

## More Practice:
> [Spring Boot File upload example with Multipart File](https://bezkoder.com/spring-boot-file-upload/)

> [Exception handling: @RestControllerAdvice example in Spring Boot](https://bezkoder.com/spring-boot-restcontrolleradvice/)

> [Spring Boot Repository Unit Test with @DataJpaTest](https://bezkoder.com/spring-boot-unit-test-jpa-repo-datajpatest/)

> [Spring Boot Pagination & Sorting example](https://www.bezkoder.com/spring-boot-pagination-sorting-example/)

Associations:
> [Spring Boot One To Many example with Spring JPA, Hibernate](https://www.bezkoder.com/jpa-one-to-many/)

> [Spring Boot Many To Many example with Spring JPA, Hibernate](https://www.bezkoder.com/jpa-many-to-many/)

> [JPA One To One example with Spring Boot](https://www.bezkoder.com/jpa-one-to-one/)

Deployment:
> [Deploy Spring Boot App on AWS – Elastic Beanstalk](https://www.bezkoder.com/deploy-spring-boot-aws-eb/)

> [Docker Compose Spring Boot and MySQL example](https://www.bezkoder.com/docker-compose-spring-boot-mysql/)

## Fullstack Authentication

> [Spring Boot + Vue.js JWT Authentication](https://bezkoder.com/spring-boot-vue-js-authentication-jwt-spring-security/)
Expand All @@ -33,6 +54,10 @@ For instruction: [Spring Boot Refresh Token with JWT example](https://bezkoder.c

> [Spring Boot + Angular 12 JWT Authentication](https://www.bezkoder.com/angular-12-spring-boot-jwt-auth/)

> [Spring Boot + Angular 13 JWT Authentication](https://www.bezkoder.com/angular-13-spring-boot-jwt-auth/)

> [Spring Boot + Angular 14 JWT Authentication](https://www.bezkoder.com/angular-14-spring-boot-jwt-auth/)

> [Spring Boot + React JWT Authentication](https://bezkoder.com/spring-boot-react-jwt-auth/)

## Fullstack CRUD App
Expand Down Expand Up @@ -69,6 +94,12 @@ For instruction: [Spring Boot Refresh Token with JWT example](https://bezkoder.c

> [Angular 13 + Spring Boot + PostgreSQL example](https://www.bezkoder.com/spring-boot-angular-13-postgresql/)

> [Angular 14 + Spring Boot + H2 Embedded Database example](https://www.bezkoder.com/spring-boot-angular-14-crud/)

> [Angular 14 + Spring Boot + MySQL example](https://www.bezkoder.com/spring-boot-angular-14-mysql/)

> [Angular 14 + Spring Boot + PostgreSQL example](https://www.bezkoder.com/spring-boot-angular-14-postgresql/)

> [React + Spring Boot + MySQL example](https://bezkoder.com/react-spring-boot-crud/)

> [React + Spring Boot + PostgreSQL example](https://bezkoder.com/spring-boot-react-postgresql/)
Expand All @@ -82,18 +113,6 @@ Run both Back-end & Front-end in one place:

> [Integrate Vue.js with Spring Boot Rest API](https://bezkoder.com/integrate-vue-spring-boot/)

More Practice:
> [Spring Boot File upload example with Multipart File](https://bezkoder.com/spring-boot-file-upload/)

> [Exception handling: @RestControllerAdvice example in Spring Boot](https://bezkoder.com/spring-boot-restcontrolleradvice/)

> [Spring Boot Repository Unit Test with @DataJpaTest](https://bezkoder.com/spring-boot-unit-test-jpa-repo-datajpatest/)

Deployment:
> [Deploy Spring Boot App on AWS – Elastic Beanstalk](https://www.bezkoder.com/deploy-spring-boot-aws-eb/)

> [Docker Compose Spring Boot and MySQL example](https://www.bezkoder.com/docker-compose-spring-boot-mysql/)

## Dependency
– If you want to use PostgreSQL:
```xml
Expand Down
27 changes: 27 additions & 0 deletions docker-compose.yml
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "2.1"
services:
spring-boot-jwt-auth:
build: .
image: spring-boot-jwt-auth
ports:
- "8080:8080"
environment:
- spring.datasource.url=jdbc:mysql://mysqldb:3306/testdb
depends_on:
mysqldb:
condition: service_healthy
restart: on-failure

mysqldb:
image: mysql:8.0.32
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=123456
- MYSQL_DATABASE=testdb
- MYSQL_PASSWORD=123456
restart: unless-stopped
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 10s
retries: 5
8 changes: 7 additions & 1 deletion pom.xml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.1</version>
<version>2.7.3</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.bezkoder</groupId>
Expand Down Expand Up @@ -52,6 +52,12 @@
<version>0.9.1</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
package com.bezkoder.springjwt;

import com.bezkoder.springjwt.models.ERole;
import com.bezkoder.springjwt.models.Role;
import com.bezkoder.springjwt.repository.RoleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PostConstruct;
import java.util.Optional;

@SpringBootApplication
public class SpringBootSecurityJwtApplication {

public static void main(String[] args) {
SpringApplication.run(SpringBootSecurityJwtApplication.class, args);
}
@Autowired
private RoleRepository roleRepository;

public static void main(String[] args) {
SpringApplication.run(SpringBootSecurityJwtApplication.class, args);
}

}
@PostConstruct
public void init() {
// Create roles if they don't exist
for (ERole role : ERole.values()) {
Optional<Role> optionalRole = roleRepository.findByName(role);
if (!optionalRole.isPresent()) {
Role newRole = new Role();
newRole.setName(role);
roleRepository.save(newRole);
}
}
}
}
Loading

AltStyle によって変換されたページ (->オリジナル) /