Backend of the ScholarX project
- Java
- Maven
- PostgreSQL
- Google Developer Account
- Gmail Account with an App Password
Here are the steps you need to follow to configure Google for social login:
- Go to https://console.developers.google.com/ and register for a developer account.
- Create a Google API Console project.
- Once your Google App is open, click on the Credentials menu and then Create Credentials followed by Auth client ID.
- Select Web Application as the Application type.
- Give the client a name.
- Fill in the Authorized redirect URIs field to include the redirect URI to your app:
http://<your-domain>/login/oauth2/code/google
.- example:
http://localhost:8080/login/oauth2/code/google
- example:
- Click Create. Copy the client ID and client secret, as you'll need them later.
- Create a new gmail account if you don't have one already
- Enable Two Factor Authorisation
- Generate a new
App Password
(help?)
- Fork and clone the repository
git clone https://github.com/<your profile name>/scholarx
- Open the cloned repo, Find and open the
application.yml
file - Replace the
${CLIENT_ID}
and${CLIENT-SECRET}
with the values from the above google auth client setup.
example:
google:
client-id: 123456789123-456rtyfghvbnyui.apps.googleusercontent.com
client-secret: ABCDEF-qweqrtyuiopasdfghjklzxcv
- Replace the datasource dummy values with your local postgresql server instance credentials
example:
datasource:
url: jdbc:postgresql://localhost:5432/scholarx_DB?allowPublicKeyRetrieval=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: rootuser
password: rootpassword
platform: postgres
- Find and open the
simplejavamail.properties
file. Replace the mail${EMAIL}
and${APP_PASSWORD}
values with the generatedApp Password
and the corresponding gmail address
example:
simplejavamail.smtp.username = example@gmail.com
simplejavamail.smtp.password = ytrewwqlkjmkolkj
- Update the SecurityConfig.java to allow requests from the origin http://localhost:3000. The file path is scholarx/src/main/java/org/sefglobal/scholarx/config/SecurityConfig.java
example:
configuration.setAllowedOrigins(ImmutableList.of("http://localhost:3000"));
- Run the application
mvn spring-boot:run
- Add the
mysql-connector-java
dependency to thepom.xml
file.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
- Replace the
spring.jpa
andspring.datasource
configurations inapplication.yml
with the following configuration.
jpa:
database: postgresql
hibernate:
ddl-auto: update
datasource:
url: jdbc:postgresql://${DB_URL}/${DB_NAME}?allowPublicKeyRetrieval=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: ${DB_USER_NAME}
password: ${DB_USER_PASSWORD}
platform: postgres