diff --git a/.gitignore b/.gitignore index b7e2accd..62aeb548 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ __pycache__ # Compiled python bytecode files *.pyc .cache/ +atst.ini # static/fonts for now, since it is just symlink static/fonts diff --git a/README.md b/README.md index 7b9b4d95..1d51b51d 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,16 @@ To enter the virtualenv manually (a la `source .venv/bin/activate`): If you want to automatically load the virtual environment whenever you enter the project directory, take a look at [direnv](https://direnv.net/). An `.envrc` file is included in this repository. direnv will activate and deactivate virtualenvs for you when you enter and leave the directory. +## Configuration + +A sample configuration is included in atst.ini.example. + + cp atst.ini.example atst.ini + +Be sure to modify it and change the 'secret' key. + +`script/config` (called by script/setup) will provide a default configuration. + ## Running (development) To start the app and watch for changes: diff --git a/app.py b/app.py index 185bf8d3..7d524e7d 100755 --- a/app.py +++ b/app.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import os import tornado.ioloop from atst.app import make_app, make_config diff --git a/atst.ini.example b/atst.ini.example new file mode 100644 index 00000000..7c7c7f59 --- /dev/null +++ b/atst.ini.example @@ -0,0 +1,2 @@ +[server] +secret = change_me_into_something_secret diff --git a/atst/app.py b/atst/app.py index 06e00a9e..85e69038 100644 --- a/atst/app.py +++ b/atst/app.py @@ -16,7 +16,7 @@ from atst.api_client import ApiClient ENV = os.getenv("TORNADO_ENV", "dev") -def make_app(config): +def make_app(config,**kwargs): authz_client = ApiClient(config["default"]["AUTHZ_BASE_URL"]) authnid_client = ApiClient(config["default"]["AUTHNID_BASE_URL"]) diff --git a/atst/handlers/request_new.py b/atst/handlers/request_new.py index 55a39bc9..cb37a11a 100644 --- a/atst/handlers/request_new.py +++ b/atst/handlers/request_new.py @@ -1,5 +1,6 @@ import tornado from atst.handler import BaseHandler +import tornado.httputil class RequestNew(BaseHandler): screens = [ @@ -23,6 +24,18 @@ class RequestNew(BaseHandler): def initialize(self, page): self.page = page + @tornado.web.authenticated + def post(self, screen = 1): + self.check_xsrf_cookie() + all = { + arg: self.get_argument(arg) + for arg in self.request.arguments + if not arg.startswith('_') + } + print( all ) + import json + self.write( json.dumps( all ) ) + @tornado.web.authenticated def get(self, screen = 1): self.render( 'requests/screen-%d.html.to' % int(screen), @@ -30,4 +43,3 @@ class RequestNew(BaseHandler): screens = self.screens, current = int(screen), next_screen = int(screen) + 1 ) - diff --git a/script/config b/script/config new file mode 100755 index 00000000..e3857c54 --- /dev/null +++ b/script/config @@ -0,0 +1,3 @@ +cp atst.ini.example atst.ini +rand=`head -c 400 /dev/random | tr -dc A-Za-z0-9_=,@-` +perl -p -i -e "s/change_me_into_something_secret/$rand/" atst.ini diff --git a/script/setup b/script/setup index 3ce4e8f0..1833f1d9 100755 --- a/script/setup +++ b/script/setup @@ -24,5 +24,8 @@ fi # Install application dependencies script/bootstrap +# Generate default configuration +script/config + # Symlink uswds fonts into the /static directory ln -s ../node_modules/uswds/src/fonts ./static/fonts diff --git a/templates/footer.html.to b/templates/footer.html.to index 47efdb36..fadd677b 100644 --- a/templates/footer.html.to +++ b/templates/footer.html.to @@ -5,5 +5,5 @@
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque placeat distinctio accusamus quo temporibus facilis, dicta delectus asperiores. Nihil aut quod quibusdam id fugit, officia dolorum laudantium! Quidem tempora, aliquam.
- - - {% end %} diff --git a/templates/requests_new.html.to b/templates/requests_new.html.to index f72f69db..93629515 100644 --- a/templates/requests_new.html.to +++ b/templates/requests_new.html.to @@ -8,19 +8,21 @@