Skip to content

Commit

Permalink
feat: Alterando SecurityConfig para suportar os novos endpoints e alt…
Browse files Browse the repository at this point in the history
…erações nas novas entidades
  • Loading branch information
IsaacAndra committed Sep 22, 2024
1 parent 796fad5 commit bfbc4e1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.isaacandrade.blog.domain.projects;


import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.isaacandrade.blog.domain.technologies.Technology;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
Expand All @@ -22,12 +23,13 @@ public class Project {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "title")
private String title;
@Column(name = "name")
private String name;
@Column(name = "description")
private String description;

@OneToMany(mappedBy = "project", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonManagedReference
private List<Technology> technologies;

@Column(name = "url")
Expand All @@ -37,5 +39,4 @@ public class Project {
private String urlGitHub;



}
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
package com.isaacandrade.blog.domain.technologies;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.isaacandrade.blog.domain.projects.Project;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
@Table(name = "technologies")
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
public class Technology {

@Id
Expand All @@ -19,8 +28,14 @@ public class Technology {
private TechnologyType type; // FRONTEND ou BACKEND

@ManyToOne
@JoinColumn(name = "project_id", nullable = false)
@JoinColumn(name = "project_id")
@JsonBackReference
private Project project;



public Technology(CreateTechnologyDto data) {
this.name = data.name();
this.type = data.type();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws
.requestMatchers(HttpMethod.POST, "/auth/login").permitAll()
.requestMatchers(HttpMethod.POST, "/users").permitAll()
.requestMatchers(HttpMethod.GET, "/users/**").permitAll()
.requestMatchers(HttpMethod.GET, "/projects/**").permitAll()
.requestMatchers(HttpMethod.PUT, "/users/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.DELETE, "/users/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.POST, "/posts/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.GET, "/posts/**").permitAll()
.requestMatchers(HttpMethod.PUT, "/posts/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.DELETE, "/posts/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.POST, "/projects/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.POST, "/technologies/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.GET, "/technologies/**").hasRole("ADMIN")

.requestMatchers("/v3/api-docs/**").permitAll()
.requestMatchers("/swagger-ui/**").permitAll()
Expand Down

0 comments on commit bfbc4e1

Please sign in to comment.