Skip to content
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

V1.0.2 #44

Open
wants to merge 209 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
209 commits
Select commit Hold shift + click to select a range
0d12e8d
added script and file-writer
aroranamita09 Feb 19, 2019
136a2bc
issues resolved for authentication backend and whole angular
ishumatil Feb 19, 2019
7314c1a
Added few(working) services
iamkishlayverma Feb 19, 2019
97592f1
Added modules for services in pom.xml
iamkishlayverma Feb 19, 2019
1d8afbf
Added Question service and recommendation service
iamkishlayverma Feb 19, 2019
1476b9c
Some changes in eventbrite-service
iamkishlayverma Feb 19, 2019
0750454
Some changes in application.yml file of execution-engine
iamkishlayverma Feb 19, 2019
b646945
Changed dependency for EurekaClient in pom of authentication service
iamkishlayverma Feb 19, 2019
2dcc4b7
Added submission service and added module for that in pom file
iamkishlayverma Feb 19, 2019
229999f
dockerization has been done for angular
ishumatil Feb 19, 2019
77e9e5f
file-appender in code ex
aroranamita09 Feb 19, 2019
5f157e3
Namita changes Merge branch 'v1.0.2' of https://github.com/stackroute…
aroranamita09 Feb 19, 2019
7630d48
Changed container name for services in docker-compose file
iamkishlayverma Feb 20, 2019
7f14d76
added comments in question service
Feb 20, 2019
8ec74e8
Added appliaction port
aroranamita09 Feb 20, 2019
5567043
added app port
aroranamita09 Feb 20, 2019
4763fac
added get methods in controller and service and testcases also
Feb 20, 2019
7ceafdb
deleted old basic recommend-service and added new(till 2nd sprint)
Feb 20, 2019
d37b26b
Edited README file
Feb 20, 2019
33b5b75
updated execution-engine
aroranamita09 Feb 20, 2019
2fe287a
changes committed in ex-engineMerge branch 'v1.0.2' of https://github…
aroranamita09 Feb 20, 2019
b453f56
added getQuestion method in controller,getQuestionById method in serv…
Feb 20, 2019
2cce912
issues resolved for fronted and authentication backend
ishumatil Feb 20, 2019
ef4618e
Execution-engine
aroranamita09 Feb 20, 2019
db38255
Added dockerfile for recommendation service
iamkishlayverma Feb 21, 2019
ee4192b
Added few changed in execution servcie for Eureka
iamkishlayverma Feb 21, 2019
5757fd5
Two scripts for code-exec
aroranamita09 Feb 21, 2019
7ea1f0f
Namita added code execMerge branch 'v1.0.2' of https://github.com/st…
aroranamita09 Feb 21, 2019
2ef1057
Added few changes in execution engine
iamkishlayverma Feb 21, 2019
eb9be8e
same-changes
aroranamita09 Feb 21, 2019
e2799ac
same changesMerge branch 'v1.0.2' of https://github.com/stackroute/bo…
aroranamita09 Feb 21, 2019
73ab553
Added few changes in Userprofile
iamkishlayverma Feb 21, 2019
8829d3a
Added few changes in Userprofile
iamkishlayverma Feb 21, 2019
aa573a0
added getQuestionByTag method and exception handling and testcases of…
Feb 21, 2019
3cf7d63
resolved issues
Feb 21, 2019
f64c222
Changed the limit for password size
iamkishlayverma Feb 21, 2019
dd25ad3
Changed the limit for password size
iamkishlayverma Feb 21, 2019
a827b49
modified domain class
Feb 21, 2019
4f93ee4
commit merge
Feb 21, 2019
5d19b8e
Update .gitignore
ishumatil Feb 21, 2019
95fc10e
modified kafka for question
Feb 21, 2019
5e0e14b
modified kafka for question
Feb 21, 2019
c27a960
Added sout in userprofile
iamkishlayverma Feb 21, 2019
bd5ce2e
Added sout in userprofile
iamkishlayverma Feb 21, 2019
93ad3c6
Sorted-code
aroranamita09 Feb 21, 2019
495bd2d
code-exec-sortedMerge branch 'v1.0.2' of https://github.com/stackrout…
aroranamita09 Feb 21, 2019
057ed42
Dockerizing angular app
iamkishlayverma Feb 21, 2019
1aff858
Dockerizing angular app
iamkishlayverma Feb 21, 2019
33bb563
sorted execution-engine
aroranamita09 Feb 21, 2019
78765be
Added few changes in Dockerfile for angular app
iamkishlayverma Feb 21, 2019
41319c6
Added few changes in Dockerfile for angular app
iamkishlayverma Feb 21, 2019
df3bf7b
Added few changes in Dockerfile for angular app
iamkishlayverma Feb 21, 2019
5e24a00
Added few changes in Dockerfile for angular app
iamkishlayverma Feb 21, 2019
95f5364
navbar and footer component added to frontend
Feb 21, 2019
35870a2
all raised issues resolved
ishumatil Feb 21, 2019
ded5fec
added scoreandbadge service
Feb 21, 2019
2d5628e
userprofile redirected to submission
iamkishlayverma Feb 21, 2019
ac0c839
updated up and down voting component
Feb 21, 2019
299f858
moved navbar and footer into different component
Feb 21, 2019
31defda
Added score and Badge service and configured the connection between s…
iamkishlayverma Feb 21, 2019
ef5dbaa
added kafka file and tests
Feb 21, 2019
be4fb5d
changes done in recoomendation
keshav174 Feb 21, 2019
44d0ef2
exec-engine integrated with ques-service
aroranamita09 Feb 21, 2019
755261e
integrated-code-ex
aroranamita09 Feb 21, 2019
767fa03
changes done in app component html file
ishumatil Feb 21, 2019
74d4fee
search service added
ishumatil Feb 21, 2019
a9efcc4
Creating a new directory for every instance
aroranamita09 Feb 21, 2019
6633537
Added voting servie backend with CRUD operations and custom MongoDB q…
Feb 22, 2019
6f704fd
Working Service-execution
aroranamita09 Feb 22, 2019
7d6e870
Added README.md to voting service
Feb 22, 2019
9f5da00
Execution-engine-cloning-fine
aroranamita09 Feb 22, 2019
8dbc2e8
ex-eng-cloning
aroranamita09 Feb 22, 2019
a762bbf
ex-engine-cloningMerge branch 'v1.0.2' of https://github.com/stackrou…
aroranamita09 Feb 22, 2019
2aaae9e
error resolved in recommendation
keshav174 Feb 22, 2019
6f5df84
submission object send to userprofile through kafka
iamkishlayverma Feb 22, 2019
0ee04ff
submission object send to userprofile through kafka
iamkishlayverma Feb 22, 2019
2ce91e6
executionEnginetestcasesend
Feb 22, 2019
28598c2
message from kafka parsed
iamkishlayverma Feb 22, 2019
df180e6
added scorebadge component and service
Feb 22, 2019
10bbb4b
routing recommendation with editor
Feb 22, 2019
2cde751
submission component moved to _components
Feb 22, 2019
ac69f8b
submission component moved to _components
Feb 22, 2019
a530588
Changed few things in Submission service
iamkishlayverma Feb 22, 2019
0609783
Changed few things in Submission service
iamkishlayverma Feb 22, 2019
44da1ea
Changed Dockerfile contents
iamkishlayverma Feb 22, 2019
da6cf85
Added voting-service and modified authentication-service Dockerfile
iamkishlayverma Feb 22, 2019
c407015
Chnaged docker-compose for mashup-frontend
iamkishlayverma Feb 22, 2019
8578e7c
Added new service in docker-compose file
iamkishlayverma Feb 22, 2019
af48545
Added Dockerfile in recommendation-service
iamkishlayverma Feb 22, 2019
9db0c40
Added Dockerfile for search service and modified score and badge service
iamkishlayverma Feb 22, 2019
9ba6409
Added Dockerfile for voting service
iamkishlayverma Feb 22, 2019
6aa4633
fixed header and footer
keshav174 Feb 22, 2019
dbc3454
Changed dockerfile for mashup-frontend
iamkishlayverma Feb 22, 2019
e13bcb6
Changed dockerfile for mashup-frontend
iamkishlayverma Feb 22, 2019
1147e70
footer navr modified
keshav174 Feb 22, 2019
0a8a15d
Changed dockerfile for recommendation-service
iamkishlayverma Feb 22, 2019
267de60
footer navr modified
keshav174 Feb 22, 2019
dd11d4f
footer navr modified
keshav174 Feb 22, 2019
5ec8574
Changed dockerfile for mashup-frontend
iamkishlayverma Feb 22, 2019
6211570
Added submission service in docker-compose
iamkishlayverma Feb 22, 2019
9f81228
Update pom.xml
Ujjawala Feb 23, 2019
603f238
Update pom.xml
Ujjawala Feb 23, 2019
adc1144
Update pom.xml
Ujjawala Feb 23, 2019
2aab63f
Update pom.xml
Ujjawala Feb 23, 2019
e435392
Update pom.xml
Ujjawala Feb 23, 2019
89e08d0
Update pom.xml
Ujjawala Feb 23, 2019
62aa604
Update pom.xml
Ujjawala Feb 23, 2019
48f1ea3
Update pom.xml
Ujjawala Feb 23, 2019
fd0fd50
Update pom.xml
Ujjawala Feb 23, 2019
a539a72
Update pom.xml
Ujjawala Feb 23, 2019
f667fe2
Update pom.xml
Ujjawala Feb 23, 2019
9ee8097
Update pom.xml
Ujjawala Feb 23, 2019
cf81528
Update pom.xml
Ujjawala Feb 23, 2019
971d2fc
Update pom.xml
Ujjawala Feb 23, 2019
557fd2f
Update pom.xml
Ujjawala Feb 23, 2019
5491833
Update pom.xml
Ujjawala Feb 23, 2019
0256678
Update pom.xml
Ujjawala Feb 23, 2019
42cf629
changes in frontend and userprofile service
Feb 23, 2019
7ef10cb
changes in frontend
Feb 23, 2019
445a821
changes in pom
Feb 23, 2019
e56d8b8
Update pom.xml
Ujjawala Feb 23, 2019
677fe7e
Added some changes
iamkishlayverma Feb 23, 2019
ada7ed7
Added some changes
iamkishlayverma Feb 23, 2019
06a11b0
changes in pom
Feb 23, 2019
6664b23
Merge branch 'v1.0.2' of https://github.com/stackroute/boeing-wave3-m…
Feb 23, 2019
db54905
Update pom.xml
Ujjawala Feb 23, 2019
aeedb20
changes question pom
Feb 23, 2019
bd224bd
changes question pom
Feb 23, 2019
4342aa2
Update pom.xml
Ujjawala Feb 23, 2019
8bbe1d7
changes authentication pom
Feb 23, 2019
a04efde
changes authentication pom
Feb 23, 2019
d4cf478
Update pom.xml
Ujjawala Feb 23, 2019
c0626c8
Update Dockerfile
Ujjawala Feb 23, 2019
6903aac
Update pom.xml
Ujjawala Feb 23, 2019
d0fe889
Update Dockerfile
Ujjawala Feb 23, 2019
3543944
Update pom.xml
Ujjawala Feb 23, 2019
cef979a
Update Dockerfile
Ujjawala Feb 23, 2019
ec25e2f
Update pom.xml
Ujjawala Feb 23, 2019
339fd3f
Update Dockerfile
Ujjawala Feb 23, 2019
4fc5689
Update pom.xml
Ujjawala Feb 23, 2019
77d430c
Update Dockerfile
Ujjawala Feb 23, 2019
9f67643
Update pom.xml
Ujjawala Feb 23, 2019
1f00b15
Update Dockerfile
Ujjawala Feb 23, 2019
e9dd22d
Update pom.xml
Ujjawala Feb 23, 2019
8acff69
Update Dockerfile
Ujjawala Feb 23, 2019
e0ff78e
Update pom.xml
Ujjawala Feb 23, 2019
26badb1
Update Dockerfile
Ujjawala Feb 23, 2019
2c7cd85
Update pom.xml
Ujjawala Feb 23, 2019
3962f37
Update Dockerfile
Ujjawala Feb 23, 2019
e0492a7
Update pom.xml
Ujjawala Feb 23, 2019
df12544
Update Dockerfile
Ujjawala Feb 23, 2019
45b977d
Update pom.xml
Ujjawala Feb 23, 2019
6a17ca1
Update Dockerfile
Ujjawala Feb 23, 2019
2df7b61
Update pom.xml
Ujjawala Feb 23, 2019
5616293
Update Dockerfile
Ujjawala Feb 23, 2019
60bdfe1
Update pom.xml
Ujjawala Feb 23, 2019
19d6582
Update Dockerfile
Ujjawala Feb 23, 2019
7b16036
Changed UI and integrated few services in frontend
iamkishlayverma Feb 23, 2019
503a937
Changed UI and integrated few services in frontend
iamkishlayverma Feb 23, 2019
02511e7
Changed UI and integrated few services in frontend
iamkishlayverma Feb 23, 2019
63f2646
sending data to submission service
Feb 23, 2019
01b1e80
sending data to submission service
Feb 23, 2019
eed54ae
Made some changes required for the integration of services
iamkishlayverma Feb 23, 2019
83b7475
changes in service testcases
Feb 25, 2019
a1fc83e
Configured the port and eureka service for other services
iamkishlayverma Feb 25, 2019
0d64d21
Configured the port and eureka service for other services
iamkishlayverma Feb 25, 2019
60ca4ce
Configured the kafka for authentication service
iamkishlayverma Feb 25, 2019
f7bccce
Updated navbar and footer
Feb 25, 2019
c855401
Merge branch 'v1.0.2' of https://github.com/stackroute/boeing-wave3-m…
Feb 25, 2019
b34c2a0
Configured imports for neo4j
iamkishlayverma Feb 25, 2019
a328f16
Added CSV for imports in neo4j
iamkishlayverma Feb 25, 2019
89cce12
Configured application.properties for neo4j
iamkishlayverma Feb 25, 2019
3c4849b
Added mashup-frontend in docker-compose file
iamkishlayverma Feb 25, 2019
d1335cb
Changed dockerfile for Angular app
iamkishlayverma Feb 25, 2019
3b2cd35
Changed the url in angular app
iamkishlayverma Feb 25, 2019
7eaaf03
Changed the url in angular app
iamkishlayverma Feb 25, 2019
342b8bc
modified the urls for funtionalities
iamkishlayverma Feb 25, 2019
4e913cd
modified the urls for funtionalities
iamkishlayverma Feb 25, 2019
35b1887
modified the urls for funtionalities
iamkishlayverma Feb 25, 2019
5df1b9c
modified the urls for funtionalities
iamkishlayverma Feb 25, 2019
11c6039
modified the urls for funtionalities
iamkishlayverma Feb 25, 2019
256315e
Corrected question-part of edit.ts
aroranamita09 Feb 25, 2019
197f1c5
Modified the urls for redirection
iamkishlayverma Feb 26, 2019
5944c81
Modified the urls for redirection
iamkishlayverma Feb 26, 2019
0c405c6
Modified edit.ts file for question fetching
iamkishlayverma Feb 26, 2019
0ab73f5
added methods in controller and service
Feb 26, 2019
398d5fd
Modified docker-compose file for mongo(opened port 27017 as expose)
iamkishlayverma Feb 26, 2019
b2f9372
Modified docker-compose file for mongo(opened port 27017 as expose)
iamkishlayverma Feb 26, 2019
b41af1c
changed java version in dockerfile and pom
Feb 26, 2019
beb6494
modefied docker file
Feb 26, 2019
c2abb53
Updated nav links
Feb 26, 2019
f2d75db
Modified question-service for seed data
iamkishlayverma Feb 26, 2019
157b469
Modified question-service for seed data
iamkishlayverma Feb 26, 2019
ce2b7d2
Modified question and recommendation service for eureka conne tivity
iamkishlayverma Feb 26, 2019
6966230
Modified recommendation service for eureka conne tivity
iamkishlayverma Feb 26, 2019
705f108
Modified question service for csv seed data
iamkishlayverma Feb 26, 2019
28376b1
Made some changes for seed data in question service
iamkishlayverma Feb 26, 2019
f26cb42
Update pom.xml
iamkishlayverma Feb 27, 2019
edf8c2b
Update KafkaConfiguration.java
Ujjawala Feb 27, 2019
7968be2
Update UserController.java
Ujjawala Feb 27, 2019
41464d1
Update Question.java
Ujjawala Feb 27, 2019
8e9f75b
Update UserProfile.java
Ujjawala Feb 27, 2019
bc7454a
Update KafkaListenerService.java
Ujjawala Feb 27, 2019
dca754d
Delete QuestionService.java
Ujjawala Feb 27, 2019
3ac165e
Delete QuestionServiceImpl.java
Ujjawala Feb 27, 2019
d4771f2
Update UserProfileService.java
Ujjawala Feb 27, 2019
96079bd
Update UserDBProfileServiceImpl.java
Ujjawala Feb 27, 2019
418a39e
Update UserprofileServiceApplication.java
Ujjawala Feb 27, 2019
dc1d468
wrote test cases
aroranamita09 Feb 27, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

/node/
node_tmp/
node_modules/
npm-debug.log.*

######################
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

****Running the System****
1.Docker compose up

Run ```mvn clean compile package``` on all the services
2.Run ```mvn clean compile package``` on all the services

3.Services depend upon



25 changes: 25 additions & 0 deletions authentication-service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
/build/
6 changes: 6 additions & 0 deletions authentication-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM openjdk:10

ADD ./target/authentication-service-1.0.2-SNAPSHOT.jar authentication-service.jar
EXPOSE 8021

ENTRYPOINT ["java","-jar","authentication-service.jar"]
103 changes: 103 additions & 0 deletions authentication-service/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.stackroute</groupId>
<artifactId>mashup</artifactId>
<version>1.0.2-SNAPSHOT</version>
</parent>
<artifactId>authentication-service</artifactId>
<name>authentication-service</name>
<description>Authentication Service</description>

<properties>
<java.version>10</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-xc</artifactId>
<version>1.9.11</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>


</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.stackroute;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;

@EnableEurekaClient
@SpringBootApplication
public class AuthenticationServiceApplication {

public static void main(String[] args) {

SpringApplication.run(AuthenticationServiceApplication.class, args);
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.stackroute.config;

import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;

import java.util.HashMap;
import java.util.Map;

@EnableKafka
@Configuration
public class KafkaConfiguration {
@Bean
public ConsumerFactory<String,String> consumerFactory(){
Map<String,Object> config = new HashMap<>();

config.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,"localhost:9092");
config.put(ConsumerConfig.GROUP_ID_CONFIG,"group_id_auth");
config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,StringDeserializer.class);

return new DefaultKafkaConsumerFactory<>(config);
}

@Bean
public ConcurrentKafkaListenerContainerFactory<String,String> kafkaListenerContainerFactory(){
ConcurrentKafkaListenerContainerFactory<String,String> factory = new ConcurrentKafkaListenerContainerFactory();
factory.setConsumerFactory(consumerFactory());
return factory;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.stackroute.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import static springfox.documentation.builders.PathSelectors.regex;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select().apis(RequestHandlerSelectors.basePackage("com.stackroute.authenticationservice.controller"))
.paths(regex("/api/auth.*"))
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.stackroute.controller;

import javax.validation.Valid;
import com.stackroute.message.request.LoginForm;
import com.stackroute.message.response.JwtResponse;
import com.stackroute.repository.UserRepository;
import com.stackroute.security.jwt.JwtProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@CrossOrigin("*")
@RestController
@RequestMapping("/api/auth")
public class AuthRestAPIs {

@Autowired
AuthenticationManager authenticationManager;

@Autowired
UserRepository userRepository;

@Autowired
PasswordEncoder encoder;

@Autowired
JwtProvider jwtProvider;

// post mapping class for signin of a user have parameters username and password
@PostMapping("/signin")
public ResponseEntity<?> authenticateUser(@Valid @RequestBody LoginForm loginRequest) {

Authentication authentication = authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken(loginRequest.getUsername(), loginRequest.getPassword()));

SecurityContextHolder.getContext().setAuthentication(authentication);

// generate jwt token string for the user that are logging in
String jwt = jwtProvider.generateJwtToken(authentication);
UserDetails userDetails = (UserDetails) authentication.getPrincipal();

// return jwt token and the username from the user details
return ResponseEntity.ok(new JwtResponse(jwt, userDetails.getUsername(), userDetails.getAuthorities()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.stackroute.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
public class TestRestAPIs {

// map the user to the role user during sign in
@GetMapping("/api/test/user")
@PreAuthorize("hasRole('USER')")
public String userAccess() {

return ">>> User Contents!";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.stackroute.message.request;

import javax.validation.constraints.NotBlank;

// setter and getter functions for the username and password to login
public class LoginForm {
@NotBlank
private String username;

@NotBlank
private String password;

public String getUsername() {

return username;
}

public void setUsername(String username) {

this.username = username;
}

public String getPassword() {

return password;
}

public void setPassword(String password) {

this.password = password;
}
}
Loading