Skip to content

Commit

Permalink
#463 filled out logic for cassandra oauth plugin. fixed broken querie…
Browse files Browse the repository at this point in the history
…s. got cassandra generally working it seems
  • Loading branch information
tuxranger committed Mar 17, 2021
1 parent 5a362e3 commit c7081e2
Show file tree
Hide file tree
Showing 14 changed files with 472 additions and 81 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM ubuntu:20.04

COPY cassandra/schema.sql /usr/local/bin

ADD janus /bin/janus
RUN chmod a+x /bin/janus && \
mkdir -p /etc/janus/apis && \
Expand Down
10 changes: 10 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ WORKDIR /janus

COPY . ./

######## Set Up github credentials to we can access private modules ########
RUN apk add git
ARG GITHUB_USER
ENV GITHUB_USER=$GITHUB_USER
RUN echo $GITHUB_USER
ARG GITHUB_TOKEN
ENV GITHUB_TOKEN=$GITHUB_TOKEN
RUN git config --global url."https://$GITHUB_USER:[email protected]".insteadOf "https://github.com"

# Add tooling to install GCC
RUN apk add build-base
# Add cqlsh to the image.
Expand Down Expand Up @@ -38,6 +47,7 @@ HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl -f http://localhost:
FROM build-debug-common as dev
EXPOSE 8080 8081 8443 8444 40000
COPY entry-dev.sh /usr/local/bin
COPY cassandra/schema.sql /usr/local/bin
RUN chmod 755 /usr/local/bin/entry-dev.sh
ENTRYPOINT ["/usr/local/bin/entry-dev.sh"]
#ENTRYPOINT ["/janus", "start"]
5 changes: 5 additions & 0 deletions cassandra/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ CREATE TABLE IF NOT EXISTS janus.api_definition (
name text,
definition text,
PRIMARY KEY (name));

CREATE TABLE IF NOT EXISTS janus.oauth (
name text,
oauth text,
PRIMARY KEY (name));
12 changes: 5 additions & 7 deletions cassandra/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cassandra

import (
"github.com/motiv-labs/cassandra"
"github.com/opentracing/opentracing-go"
)

const (
Expand All @@ -19,15 +20,12 @@ const (
var sessionHolder cassandra.Holder

func GetSession() cassandra.SessionInterface {
//span := opentracing.StartSpan("GetSession", opentracing.ChildOf(parentSpan.Context()))
//defer span.Finish()
//span.SetTag("Package", "cassandra")
return sessionHolder.GetSession(nil)
span := opentracing.StartSpan("GetSession")
defer span.Finish()
span.SetTag("Package", "cassandra")
return sessionHolder.GetSession(span)
}

func SetSessionHolder(holder cassandra.Holder) {
//span := opentracing.StartSpan("SetSessionHolder", opentracing.ChildOf(parentSpan.Context()))
//defer span.Finish()
//span.SetTag("Package", "cassandra")
sessionHolder = holder
}
14 changes: 14 additions & 0 deletions examples/front-proxy-cassandra/apis/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name" : "my-endpoint",
"active" : true,
"proxy" : {
"listen_path" : "/example/*",
"upstreams" : {
"balancing": "roundrobin",
"targets": [
{"target": "http://www.mocky.io/v2/595625d22900008702cd71e8"}
]
},
"methods" : ["GET"]
}
}
34 changes: 34 additions & 0 deletions examples/front-proxy-cassandra/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3'
services:

janus:
image: motivlabs/janus:debug
ports:
- "8080:8080"
- "8081:8081"
- "40000:40000"
environment:
- debug=1
depends_on:
- service1
- janus-database
volumes:
- ./janus.toml:/etc/janus/janus.toml
- ~/dev/motiv/janus:/janus

janus-database:
image: cassandra:latest
container_name: db
ports:
- "9042:9042"
environment:
- MAX_HEAP_SIZE=1G
- HEAP_NEWSIZE=250M
- JAVA_OPTS="-Dcassandra.skip_wait_for_gossip_to_settle=0 -Dcassandra.num_tokens=1 -Dcassandra.initial_token=1"

service1:
image: rodolpheche/wiremock
ports:
- '9089:8080'
volumes:
- ../front-proxy/stubs:/home/wiremock/mappings
22 changes: 22 additions & 0 deletions examples/front-proxy-cassandra/janus.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
################################################################
# Global configuration
################################################################
port = 8080

[log]
level = "debug"

################################################################
# API configuration backend
################################################################
[web]
port = 8081

[web.credentials]
secret = "secret"

[web.credentials.basic]
users = {admin = "admin"}

[database]
dsn = "cassandra:///db/system/janus/300"
33 changes: 12 additions & 21 deletions examples/front-proxy-mongo/apis/example.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
[
{
"name" : "example",
"active" : true,
"proxy" : {
"preserve_host" : false,
"listen_path" : "/example/*",
"upstreams" : {
"balancing": "roundrobin",
"targets": [
{"target": "http://service1:8080/"}
]
},
"strip_path" : false,
"append_path" : false,
"methods" : ["GET"]
{
"name" : "my-endpoint",
"active" : true,
"proxy" : {
"listen_path" : "/example/*",
"upstreams" : {
"balancing": "roundrobin",
"targets": [
{"target": "http://www.mocky.io/v2/595625d22900008702cd71e8"}
]
},
"health_check": {
"url": "http://service1:8080/status",
"timeout": 3
}
"methods" : ["GET"]
}
]
}
24 changes: 14 additions & 10 deletions examples/front-proxy-mongo/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,36 @@ version: '3'
services:

janus:
image: hellofreshtech/janus
image: motivlabs/janus:debug
ports:
- "8080:8080"
- "8081:8081"
- "8082:8080"
- "8083:8081"
- "40001:40000"
depends_on:
- service1
- janus-database
environment:
- debug=1
volumes:
- ./janus.toml:/etc/janus/janus.toml
- ~/dev/motiv/janus:/janus

janus-database:
image: mongo
ports:
- "27017:27017"

# This container is just a helper to seed the database
mongo-seed:
build:
context: .
dockerfile: seed.Dockerfile
depends_on:
- janus-database
# mongo-seed:
# build:
# context: .
# dockerfile: seed.Dockerfile
# depends_on:
# - janus-database

service1:
image: rodolpheche/wiremock
ports:
- '9089:8080'
- '9090:8080'
volumes:
- ../front-proxy/stubs:/home/wiremock/mappings
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.1.2
github.com/motiv-labs/cassandra v0.0.0-20210126221137-4ac871dd211e
github.com/opentracing/opentracing-go v1.2.0
github.com/rafaeljesus/retry-go v0.0.0-20171214204623-5981a380a879
github.com/rs/cors v1.4.0
github.com/sirupsen/logrus v1.7.0
Expand Down
Loading

0 comments on commit c7081e2

Please sign in to comment.