-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from christianstubbe/feature-mongo
Features: Database, Blob Upload, Transformations
- Loading branch information
Showing
38 changed files
with
476 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,3 +107,5 @@ override.tf.json | |
.terraformrc | ||
terraform.rc | ||
toolbox/terraform/.terraform.lock.hcl | ||
|
||
creds.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Preliminary Benchmarks | ||
|
||
## Requirements | ||
|
||
Linux: `sudo apt install apache2-utils` | ||
macOS: *Comes pre-installed* | ||
|
||
## Usage | ||
|
||
- Download [the Google API Discovery list](https://discovery.googleapis.com/discovery/v1/apis) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import subprocess | ||
from google.oauth2 import service_account | ||
|
||
credentials = service_account.Credentials.from_service_account_file('../src/creds.json') | ||
|
||
|
||
def run_ab(benchmark_url, number_of_requests, concurrency_level): | ||
ab_command = f"ab -n {number_of_requests} -c {concurrency_level} {benchmark_url}" | ||
try: | ||
process = subprocess.run(ab_command, shell=True, check=True, stdout=subprocess.PIPE, universal_newlines=True) | ||
except subprocess.CalledProcessError as e: | ||
print(f"Error occurred while trying to run `ab` command: {e}") | ||
return None | ||
output = process.stdout | ||
|
||
return output | ||
|
||
|
||
output = run_ab("http://localhost:8000", 1000, 10) | ||
if output: | ||
print(output) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
""" | ||
This class provides an interface for Casbin to use the custom, | ||
provided model for our data structure. | ||
""" | ||
from casbin_sqlalchemy_adapter import Adapter | ||
from access.db import engine | ||
|
||
adapter = Adapter(engine) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
""" This package for querying and uploading data to different cloud data storage solutions. """ | ||
import os | ||
from sqlalchemy import create_engine, MetaData, Column, Integer, String, ForeignKey, Table | ||
from sqlalchemy.orm import relationship, sessionmaker, Session | ||
from sqlalchemy_utils import UUIDType | ||
from sqlalchemy.ext.declarative import declarative_base | ||
from contextlib import contextmanager | ||
from databases import Database | ||
import uuid | ||
|
||
username = os.getenv("DB_USERNAME") | ||
password = os.getenv("DB_PASSWORD") | ||
url = os.getenv("DB_URL") | ||
db_name = os.getenv("DB_NAME") | ||
connection_str = f"postgresql://{username}:{password}@{url}/{db_name}" | ||
engine = create_engine(connection_str, echo=True) | ||
database = Database(connection_str) | ||
|
||
|
||
@contextmanager | ||
def session_scope(): | ||
"""Provide a transactional scope around a series of operations.""" | ||
session = Session(engine) | ||
try: | ||
yield session | ||
session.commit() | ||
except: | ||
session.rollback() | ||
raise | ||
finally: | ||
session.close() | ||
|
||
|
||
meta = MetaData() | ||
|
||
Base = declarative_base() | ||
|
||
|
||
class Purposes(Base): | ||
__tablename__ = "purposes" | ||
id = Column(Integer, primary_key=True) | ||
name = Column(String(100), nullable=False, unique=True) | ||
# Column("parent_id", Integer, ForeignKey('tree.id')), | ||
# relationship("parent", 'Tree', remote_side=[id]) | ||
|
||
|
||
class Exceptions(Base): | ||
__tablename__ = "exceptions" | ||
id = Column(Integer, primary_key=True) | ||
name = Column(String(100), unique=True) | ||
purpose_id = Column(Integer, ForeignKey('purposes.id')) | ||
exception_list = Column(String(100)) | ||
|
||
|
||
class Transformations(Base): | ||
__tablename__ = "transformations" | ||
id = Column(Integer, primary_key=True) | ||
name = Column(Integer, ForeignKey('purposes.id'), unique=True) | ||
transformation_list = Column("transformation_list", String(100)) | ||
|
||
|
||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | ||
|
||
Base.metadata.create_all(bind=engine) | ||
|
||
|
||
def populate(): | ||
""" | ||
Populate the database with basic information (purposes, exceptions, transformations, ...) provided by the config file | ||
""" | ||
|
||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
abac = """ | ||
[request_definition] | ||
r = sub, obj, act | ||
[policy_definition] | ||
p = sub, obj, act | ||
[policy_effect] | ||
e = some(where (p.eft == allow)) | ||
[matchers] | ||
m = r.sub == r.obj.Owner | ||
""" | ||
|
||
rbac = """ | ||
[request_definition] | ||
r = sub, obj, act | ||
[policy_definition] | ||
p = sub, obj, act | ||
[role_definition] | ||
g = _, _ | ||
[policy_effect] | ||
e = some(where (p.eft == allow)) | ||
[matchers] | ||
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act | ||
""" | ||
|
||
pbac = """ | ||
[request_definition] | ||
r = sub, obj, act, purp | ||
[policy_definition] | ||
p = sub, obj, act, purp | ||
[role_definition] | ||
g = _, _ | ||
[policy_effect] | ||
e = some(where (p.eft == allow)) | ||
[matchers] | ||
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act && r.purp == p.purp | ||
""" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.