Skip to content

Commit

Permalink
Provide endpoints for actuator and graphql.
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoDinizMonteiro committed Oct 29, 2018
1 parent 2e86e27 commit 78a81d6
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 27 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ Travis
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.<init>(JdbcEnvironmentImpl.java:271) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
```
Note: If you try to get GraphQL Schema ou try to access GraphiQL you must have an authorization token in your local storage. This may be inconvenient, but the graph-tool provided in `spring-boot-start-*` does not yet have the functionality to automatically generate authentication, but there is already a published issue for this:
https://github.com/graphql-java/graphql-spring-boot/issues/106
## Running maven tasks
Expand Down
17 changes: 17 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,23 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-tools</artifactId>
<version>4.3.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphiql-spring-boot-starter</artifactId>
<version>4.0.0</version>
</dependency>


<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
Expand Down
55 changes: 28 additions & 27 deletions src/main/java/quem/me/ajuda/security/SecurityConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,33 @@
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private UserAuthenticationProvider authProvider;

@Autowired
private JwtAuthenticationEntryPoint jwtAuthEndPoint;

@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();

http.authorizeRequests()
.antMatchers("/login").permitAll()
.antMatchers(HttpMethod.POST, "/students").permitAll()
.antMatchers(HttpMethod.GET, "/students").permitAll()
.antMatchers(HttpMethod.OPTIONS, "**").permitAll()
.anyRequest().authenticated()
.and()
.addFilterBefore(new JwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
.exceptionHandling()
.authenticationEntryPoint(jwtAuthEndPoint);
}

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authProvider);

}
@Autowired
private UserAuthenticationProvider authProvider;

@Autowired
private JwtAuthenticationEntryPoint jwtAuthEndPoint;

@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();

http.authorizeRequests()
.antMatchers("/actuator/**").permitAll()
.antMatchers("/graphiql").permitAll()
.antMatchers(HttpMethod.POST, "/login").permitAll()
.antMatchers(HttpMethod.POST, "/students").permitAll()
.antMatchers(HttpMethod.GET, "/students").permitAll()
.antMatchers(HttpMethod.OPTIONS, "**").permitAll()
.anyRequest()
.authenticated().and()
.addFilterBefore(new JwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
.exceptionHandling().authenticationEntryPoint(jwtAuthEndPoint);
}

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authProvider);

}

}
8 changes: 8 additions & 0 deletions src/main/resources/graphql/Student.graphqls
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type Student {
id: ID!
registration: String!
name: String!
phone: String!
email: String!
password: String!
}

0 comments on commit 78a81d6

Please sign in to comment.