Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
4ff053e
Deleted default values
May 21, 2020
5257be9
CHANGED & ADDED files
Jun 11, 2020
9b7f80e
CHANGED Models
Jun 14, 2020
9a0f49f
Update index.md
lqwert Jun 14, 2020
46f5f57
Changed CandidateService
Jul 1, 2020
9bdd8d3
Merge branch 'ba-meyer-master' of https://github.com/PatternPedia/pat…
Jul 1, 2020
c90ea8a
Merge branch 'master' into ba-meyer-merge
Jul 1, 2020
35dfccf
CHANGED interface, DELETED unused code
Jul 6, 2020
4bade8c
CHANGED index
Jul 6, 2020
679fe49
CHANGED userServiceImp
Jul 7, 2020
351ee84
ADDED features
Oct 5, 2020
02f84bf
MERGED master
Oct 5, 2020
abf98f8
CHAGE code clean up
Oct 8, 2020
24c6518
CHAGE code clean up
Oct 8, 2020
64eda53
CHANGED to new db settings
Oct 19, 2020
f2ff1d4
CHANGED to master
Oct 19, 2020
24cffed
CHANGED to authentication off
Oct 19, 2020
0f95fba
Updated .gitignore
TYueksel Jul 15, 2021
0440f46
rename folders to comply to github scheme
TYueksel Jul 15, 2021
609ea7b
MERGE from master to ba-meyer-master
TYueksel Jul 15, 2021
acc68c6
rename packages
TYueksel Jul 17, 2021
158adb4
renamed packages
TYueksel Jul 17, 2021
4c2bf08
Deleted duplicate import
TYueksel Jul 17, 2021
9e5bc3e
Added rating att to match data model with db shema
TYueksel Sep 9, 2021
3752aa2
change postgres role to patternatlas
TYueksel Sep 20, 2021
d388e90
Added candidates to languages tab
TYueksel Oct 19, 2021
e648926
Fixed typo
TYueksel Oct 30, 2021
caf6c34
Fixed typo
TYueksel Oct 30, 2021
ab97109
Fixed typo
TYueksel Oct 30, 2021
df6c97a
Resource privs for candidates & issues
TYueksel Feb 20, 2022
8804b5e
Updated DB port
TYueksel Feb 20, 2022
f44446d
Added Priv Management UI and Admin UI bug fix
TYueksel Mar 4, 2022
bb22afa
Merge branch 'master' into ba-meyer-master
mhinkie Mar 9, 2022
51ba047
changed spring-boot path
mhinkie Mar 11, 2022
e403930
fixed user creation from UI (added possibility for singular roles)
mhinkie Mar 15, 2022
4c12e74
changed role handling to mimic old behavior with single roles
mhinkie Mar 15, 2022
c022c6c
Merge branch 'master' into ba-meyer-master
mhinkie Mar 24, 2022
ba37f57
disabled swagger
mhinkie Mar 28, 2022
2c3d1b2
fixed serialisation error in exception handlers
mhinkie Mar 28, 2022
fcc63b6
added preauthorize checks for issues
mhinkie Mar 29, 2022
8601aa4
removed debug output
mhinkie Mar 29, 2022
aeb8e60
author roles are now updated when issue authors are changed
mhinkie Mar 29, 2022
ee5ef1a
added privilege checks for pattern candidate
mhinkie Mar 31, 2022
a2143ef
added framework for privilege checks without JWT supplied authorities
mhinkie Apr 1, 2022
29b8a6f
changed access control handling for issue
mhinkie Apr 1, 2022
2271b55
updated permission checks for candidate
mhinkie Apr 1, 2022
ae97f15
added filter functionality for collectionmodel
mhinkie Apr 4, 2022
923919f
added privilege checks for usercontroller
mhinkie Apr 4, 2022
181baad
finished usercontroller permission
mhinkie Apr 4, 2022
9d69d52
moved privilege checks
mhinkie Apr 4, 2022
77a5ea6
removed swagger ui
mhinkie Apr 5, 2022
8e2541e
changed resource server config for removed swagger
mhinkie Apr 5, 2022
c4b2483
added role management for authors in candidateservice
mhinkie Apr 5, 2022
e7db347
fixed author deleting for issue
mhinkie Apr 5, 2022
430107c
removed in-code checks for privileges
mhinkie Apr 5, 2022
7a297a8
fixed candidate service privilege check
mhinkie Apr 5, 2022
8ff69f4
added function for changing platform wide roles for users
mhinkie Apr 6, 2022
7f25d80
add endpoint to get all default privileges
PhilWun Apr 25, 2022
294aafe
improve endpoint naming
PhilWun Apr 25, 2022
075e9b3
add endpoint to update all resource specific roles
PhilWun May 2, 2022
224bfa9
change http method to match the REST guidelines
PhilWun May 2, 2022
829182b
add missing permission checks
PhilWun May 5, 2022
9b01014
add guest role to specify what a user can do who is not logged in
PhilWun May 6, 2022
1acd581
disable design model endpoints, because they are currently not used a…
PhilWun May 9, 2022
bfda094
disable discussions endpoints, because they are currently not used an…
PhilWun May 9, 2022
9474446
disable image endpoints, because they are currently not used and don'…
PhilWun May 9, 2022
6969599
fix error when deleting pattern from pattern language
PhilWun May 10, 2022
55a5b4d
added initial user creation for users created in keycloak
mhinkie May 10, 2022
0d295d3
add missing permission checks, fix some existing permission checks, f…
PhilWun May 10, 2022
75cc597
added logic for creating admin user on first login
mhinkie May 11, 2022
86e81ee
changed realm
mhinkie May 12, 2022
8cbbef8
Merge branch 'ba-meyer-master' of https://github.com/PatternAtlas/pat…
mhinkie May 13, 2022
0d7beea
removed old auth logic
mhinkie May 25, 2022
6d2899c
adapted dockerfile and properties template for authentication chagnes
mhinkie May 25, 2022
2b870b5
replaced imports with single class imports
mhinkie May 25, 2022
74909cb
small refactoring and code style changes
mhinkie May 25, 2022
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
6 changes: 4 additions & 2 deletions .docker/application.properties.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.use_sql_comments=true
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.liquibase.enabled={{default .Env.PATTERN_ATLAS_FETCH_INITIAL_DATA "false"}}
spring.liquibase.enabled=true
spring.liquibase.change-log=file:patternatlas.xml
spring.liquibase.password={{.Env.DB_INIT_PASSWORD}}
spring.liquibase.user={{.Env.DB_INIT_USER}}
spring.liquibase.url=jdbc:postgresql://{{.Env.JDBC_DATABASE_URL}}:{{.Env.JDBC_DATABASE_PORT}}/{{.Env.JDBC_DATABASE_NAME}}
spring.liquibase.url=jdbc:postgresql://{{.Env.JDBC_DATABASE_URL}}:{{.Env.JDBC_DATABASE_PORT}}/{{.Env.JDBC_DATABASE_NAME}}
security.oauth2.resource.jwk.key-set-uri={{.Env.JWK_URI}}
15 changes: 15 additions & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3'
services:
db:
image: postgres:10
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- "5432:5432"
networks:
- default
networks:
default:
driver: bridge
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
Expand Down Expand Up @@ -30,10 +31,13 @@ build/
### VS Code ###
.vscode/

### MacOS File System ###
**/.DS_STORE

### TexRendering ###
*.png
*.tex
*.pdf
*.log
*.aux
*.svg
*.svg
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ ENV JDBC_DATABASE_NAME postgres
ENV JDBC_DATABASE_PORT 5060
ENV HAL_EXPLORER true

ENV JWK_URI "http://localhost:8080/realms/patternatlas/protocol/openid-connect/certs"

RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
Expand Down
18 changes: 13 additions & 5 deletions docs/dev/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# PatternAtlas Developer Guide
This document provides an index to all development guidelines and background information of the PatternPedia.
This document provides an index to all development guidelines and background information of the PatternAtlas.
- [ADR](/adr) - Information on Architectural decisions can be found here

## Quick Develop
<!---
### PatternPediaAuth
PatternPediaAuth is a Spring Boot Authentication Server and it's main purpose is to give PatternAtlasAPI user management capabilities.
This is achieved through using the OAuth 2.0 Authentication Code Flow, additionally new users can create accounts.
It runs on Port 8081

### Development
1. Clone the repository `git clone https://github.com/PatternAtlas/pattern-pedia-auth.git`.
2. Navigate to repository directory `cd pattern-pedia-auth/`.
2. Build the repository
Expand All @@ -22,8 +26,12 @@ This document provides an index to all development guidelines and background inf
5. Insert the following commands `docker-compose up -d`

#### IntelliJ
3. [Follow PatternPediaAPI from Step 5 pls](#step5)
3. [Follow PatternAtlasAPI from Step 5 pls](#step5)

#### Turn authentication on/off for PatternAtlasAPI
If you don't need the capabilities of the PatternPediaAuth server during development. You can follow the instructions in the following file
[Security Config file](https://github.com/PatternAtlas/pattern-atlas-api/blob/ba-meyer-master/src/main/java/io/github/patternatlas/api/config/ResourceServerConfig.java)
to turn those off or on. An easier way will be added in a future realease.

#### Default User
During development default users are
Expand All @@ -32,9 +40,9 @@ During development default users are

### PatternAtlasAPI
--->
1. Clone the repository `git clone https://github.com/PatternPedia/pattern-atlas-api.git`.
1. Clone the repository `git clone https://github.com/PatternAtlas/pattern-atlas-api.git`.
2. Build the repository `mvn package -DskipTests` (skiping the tests for a faster build), Java 8 required.
3. Clone the repository `git clone https://github.com/PatternPedia/pattern-atlas-ui.git`.
3. Clone the repository `git clone https://github.com/PatternAtlas/pattern-atlas-ui.git`.
4. Build the repository `mvn package -DskipTests` (skiping the tests for a faster build), npm is required. (plus yarn, optionally)
5. <a name="step5"></a>Continue your IDE setup:
- [IntelliJ Ultimate](IntelliJ/)
Expand Down
18 changes: 12 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<java.version>1.8</java.version>
<springdoc-ui.version>1.5.9</springdoc-ui.version>
<spring-oauth2.version>2.5.0</spring-oauth2.version>
<jackson.version>2.13.2</jackson.version>
</properties>

<profiles>
Expand Down Expand Up @@ -137,11 +138,6 @@

<!-- Swagger -->

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>${springdoc-ui.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-data-rest</artifactId>
Expand Down Expand Up @@ -169,7 +165,17 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.0</version>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>

Expand Down
17 changes: 15 additions & 2 deletions src/main/java/io/github/patternatlas/api/PatternAtlasAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,33 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.vladmihalcea.hibernate.type.util.Configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;

import com.vladmihalcea.hibernate.type.util.Configuration;

import lombok.extern.slf4j.Slf4j;

import io.github.patternatlas.api.rest.controller.UserController;
import io.github.patternatlas.api.service.IssueService;

@EnableTransactionManagement
@Slf4j
@RestController
@SpringBootApplication
@OpenAPIDefinition(info = @Info(title = "pattern-atlas-api", version = "1.0", contact = @Contact(url = "https://github.com/PatternAtlas/pattern-atlas-api", name = "Pattern Atlas API")))
public class PatternAtlasAPI implements CommandLineRunner {

@Autowired
private UserController userController;

@Autowired
private IssueService issueService;

public static void main(String[] args) {
System.setProperty(Configuration.PropertyKey.PRINT_BANNER.getKey(), Boolean.FALSE.toString());
SpringApplication.run(PatternAtlasAPI.class, args);
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/io/github/patternatlas/api/config/Authority.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.github.patternatlas.api.config;

public interface Authority {

// TODO will be phased out - after all authority checks are changed to hasResourcePermission, this file should not be
// needed anymore

/** Pattern */
String APPROVED_PATTERN_READ = "hasAuthority('APPROVED_PATTERN_READ')";
String APPROVED_PATTERN_CREATE = "hasAuthority('APPROVED_PATTERN_CREATE')";
String APPROVED_PATTERN_EDIT = "hasAuthority('APPROVED_PATTERN_EDIT')";
String APPROVED_PATTERN_DELETE = "hasAuthority('APPROVED_PATTERN_DELETE')";
String APPROVED_PATTERN_READ_ALL = "hasAuthority('APPROVED_PATTERN_READ_ALL')";
String APPROVED_PATTERN_EDIT_ALL = "hasAuthority('APPROVED_PATTERN_EDIT_ALL')";
String APPROVED_PATTERN_DELETE_ALL = "hasAuthority('APPROVED_PATTERN_DELETE_ALL')";
/** USER */
String USER_READ = "hasAuthority('USER_READ')";
String USER_CREATE = "hasAuthority('USER_CREATE')";
String USER_EDIT = "hasAuthority('USER_EDIT')";
String USER_DELETE = "hasAuthority('USER_DELETE')";
String USER_READ_ALL = "hasAuthority('USER_READ_ALL')";
String USER_EDIT_ALL = "hasAuthority('USER_EDIT_ALL')";
String USER_DELETE_ALL = "hasAuthority('USER_DELETE_ALL')";
String USER_ALL = "hasAuthority('USER_ALL')";
/** GENERAL */
String COMMENT = "hasAuthority('COMMENT')";
String VOTE = "hasAuthority('VOTE')";
String EVIDENCE = "hasAuthority('EVIDENCE')";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.github.patternatlas.api.config;

import io.github.patternatlas.api.security.ResourceMethodSecurityExpressionHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;

@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class ResourceSecurityConfig extends GlobalMethodSecurityConfiguration {

@Autowired
private ApplicationContext applicationContext;

@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
ResourceMethodSecurityExpressionHandler handler = new ResourceMethodSecurityExpressionHandler();
handler.setApplicationContext(applicationContext);
return handler;
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
package io.github.patternatlas.api.config;

import org.springframework.boot.autoconfigure.security.oauth2.resource.JwtAccessTokenConverterConfigurer;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.DefaultTokenServices;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

import java.util.Map;

@Configuration
@EnableResourceServer
// START::Comment for local development with authorization
//@EnableGlobalMethodSecurity(prePostEnabled = true)
// END::Comment for local development with authorization
class ResourceServerConfig extends ResourceServerConfigurerAdapter {

@Override
Expand All @@ -29,17 +35,7 @@ public void configure(HttpSecurity http) throws Exception {
.antMatchers("/**")
.and()
.authorizeRequests()
.antMatchers("/swagger-ui/**").permitAll()
// START::Comment for local development with authorization
// .antMatchers(HttpMethod.GET, "/**").permitAll()
// .antMatchers(HttpMethod.POST, "/**").access("#oauth2.hasScope('write')")
// .antMatchers(HttpMethod.PUT, "/**").access("#oauth2.hasScope('write')")
// .antMatchers(HttpMethod.DELETE, "/**").hasAuthority("ADMIN")
// .anyRequest().authenticated()
//END::Comment for local development with authorization
// START::Uncomment for local development without authorization
.anyRequest().permitAll()
// END::Uncomment for local development without authorization
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
Expand Down Expand Up @@ -69,4 +65,5 @@ public FilterRegistrationBean customCorsFilter() {
bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
return bean;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class Pattern extends EntityWithURI {
private PatternLanguage patternLanguage;

@JsonIgnore
@ToString.Exclude
@OneToMany(mappedBy = "pattern", cascade = CascadeType.ALL, orphanRemoval = true)
private List<PatternViewPattern> patternViews = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Objects;

@Entity
@Data
@EqualsAndHashCode(callSuper = true)
Expand All @@ -21,4 +23,9 @@ public abstract class PatternGraph extends EntityWithURI {
@Type(type = "jsonb")
@Column(columnDefinition = "jsonb")
private Object graph;

@Override
public int hashCode() {
return Objects.hash(graph);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ public class PatternLanguage extends PatternGraph {
@JsonIgnore
@OneToMany(mappedBy = "patternLanguage", fetch = FetchType.LAZY)
private List<UndirectedEdge> undirectedEdges;


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.patternatlas.api.entities;

import java.util.List;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
Expand Down Expand Up @@ -33,4 +34,9 @@ public class PatternSchema {
@OneToOne
@MapsId
private PatternLanguage patternLanguage;

@Override
public int hashCode() {
return Objects.hash(id, patternSectionSchemas);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Entity
@Data
Expand All @@ -23,14 +24,17 @@ public class PatternView extends PatternGraph {
private URL logo;

@JsonIgnore
@ToString.Exclude
@OneToMany(mappedBy = "patternView", cascade = CascadeType.ALL, orphanRemoval = true)
private List<PatternViewPattern> patterns = new ArrayList<>();

@JsonIgnore
@ToString.Exclude
@OneToMany(mappedBy = "patternView", cascade = CascadeType.ALL, orphanRemoval = true)
private List<PatternViewDirectedEdge> directedEdges;

@JsonIgnore
@ToString.Exclude
@OneToMany(mappedBy = "patternView", cascade = CascadeType.ALL, orphanRemoval = true)
private List<PatternViewUndirectedEdge> undirectedEdges;

Expand Down
Loading