Skip to content

Commit

Permalink
auth changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bestarch committed Apr 26, 2022
1 parent 0ef6d19 commit 01e6232
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,16 @@ Execute the following command to run the application. This will create 2 contain
Execute the following command to destroy the above 2 containers in the private network:
> **docker compose down**
<hr/>

**Executing mandatory index scripts**

Before using the application, make sure to execute following index scripts. This is necessary for the search feature to work.

FT.CREATE idx-status ON JSON SCHEMA $.status as status TAG
FT.CREATE idx-aptDate ON JSON SCHEMA $.appointmentDateTime as appointmentDateTime NUMERIC SORTABLE
FT.CREATE idx-desc ON JSON SCHEMA $.description as description TEXT
FT.CREATE idx-createdTime ON JSON SCHEMA $.createdTime as createdTime NUMERIC SORTABLE


8 changes: 5 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
version: "3.9"
services:
web:
image: "abhishekcoder/appointment-directory"
image: "abhishekcoder/appointment-directory:latest"
networks:
- web-network
environment:
- SPRING_REDIS_HOST=redis
- SPRING_REDIS_PORT=6379
- SPRING_REDIS_PASSWORD="e9gydixtEWqN4tYKgRnhUXysXADYJzZ9"
- SPRING_REDIS_PASSWORD="wUJjKN6j9VdVoWYPDKN8Zp910zeP9vWn"
- SPRING_REDIS_AUTH=false
depends_on:
- redis
build: .
ports:
- "8080:8080"
redis:
image: "redis"
image: "redis/redis-stack:latest"
networks:
- web-network
restart: always
ports:
- "6377:6379"
- "8001:8001"
networks:
web-network:
driver: bridge
15 changes: 11 additions & 4 deletions src/main/java/com/bestarch/demo/config/RedisConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.springframework.data.redis.stream.Subscription;

import com.bestarch.demo.domain.AppointmentRequestStream;
//import com.redislabs.modules.rejson.JReJSON;
import com.redislabs.modules.rejson.JReJSON;

import redis.clients.jedis.DefaultJedisClientConfig;
Expand All @@ -49,22 +48,30 @@ class RedisConfiguration {
@Value("${spring.redis.password}")
private String pswd;

@Value("${spring.redis.auth}")
private boolean requiresPswd;

@Autowired
private StreamListener<String, ObjectRecord<String, AppointmentRequestStream>> streamListener;

@Bean
public RedisConnectionFactory redisConnectionFactory() {
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(server, Integer.valueOf(port));
RedisPassword rp = RedisPassword.of(pswd);
redisStandaloneConfiguration.setPassword(rp);
if (requiresPswd) {
RedisPassword rp = RedisPassword.of(pswd);
redisStandaloneConfiguration.setPassword(rp);
}
return new LettuceConnectionFactory(redisStandaloneConfiguration);
}


@Bean
public JReJSON jreJSON() {
HostAndPort hostAndPort = new HostAndPort(server, Integer.valueOf(port));
JedisClientConfig jedisClientConfig = DefaultJedisClientConfig.builder().password(pswd).build();
JedisClientConfig jedisClientConfig = DefaultJedisClientConfig.builder().build();
if (requiresPswd) {
jedisClientConfig.updatePassword(pswd);
}
Jedis jedis = new Jedis(hostAndPort, jedisClientConfig);
JReJSON jreJSON = new JReJSON(jedis);
return jreJSON;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ spring:
host: redis-10209.c100.us-east-1-4.ec2.cloud.redislabs.com
port: 10209
password: wUJjKN6j9VdVoWYPDKN8Zp910zeP9vWn
auth: true
main:
allow-circular-references: true

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Data Model:
"doctorName": "Dr. ABC",
"contactNo": "12321",
"appointmentDate": "2022-04-11T20:58",
"status": "Approved",
"status": "Confirmed",
"description": "fweferferererre",
"createdTime": "2022-04-19T20:58:21.748",
"appointmentId": "ID2772",
Expand Down

0 comments on commit 01e6232

Please sign in to comment.