Commit Graph
51 Commits
Author SHA1 Message Date
Diogo BiazusandJoe Nelson 41c1cf6e01 Reduce app function (#733)
Simplify the big app function
2016-11-10 20:42:00 -08:00
Joe Nelson 5a166e8e80 Fix custom pre-request handler
Uses Ruslan's technique
2016-09-27 23:17:08 -07:00
Joe Nelson 06363ccc77 WIP: add argument for custom pre-request handler 2016-09-27 00:19:05 -07:00
Joe Nelson 2f8ac24128 Do not share JWT secret with SQL 2016-09-24 23:40:54 -07:00
Joe Nelson 71bc666a8e Forgot jwt fixture, also hlint fix 2016-09-24 21:32:47 -07:00
Joe Nelson 12a8c682bd Use sql to generate jwt, rather than custom haskell 2016-09-24 21:32:47 -07:00
Joe Nelson 62ed9e2c4d Do not require jwt secret, but die on auth without it 2016-09-24 21:28:08 -07:00
Joe Nelson 7bf5b0106d Semantic WWW-Authenticate headers for problematic JWT
Adapting an OAuth 2.0 convention from RFC 6750 for use with JWT
2016-09-24 21:28:08 -07:00
Joe Nelson fb5fce026d Issue http 401 for expired jwt
Fixes #512
2016-09-24 21:28:08 -07:00
Diogo BiazusandJoe Nelson 6f737056a2 Protolude completion in library and executable (#697) 2016-08-21 15:10:19 -07:00
Joe NelsonandGitHub 1d5a0e4316 Per-route content negotiation, and OpenAPI only for root (#693)
* WIP: remove non-openapi root spec

* Refactor ContentType

Different endpoints will favor one type over another

* Permit different Accept headers per endpoint

* Lint

* Add charset to Content-Type only when used as a header

Keep it out of error messages

* Accept: */* is last resort, not first

* Changelog

* makeMimeList consistently

* Remove schema description from OPTIONS response
2016-08-19 16:07:22 -07:00
Diogo BiazusandJoe Nelson df6cbc4afa Protolude second movement (#677)
* Replace Prelude import for Protolude in middleware

* Remove qualifier from Text type

* Replace Prelude for Protolude, replace 'cs' for 'toS' calls, also change some name bindings

* Replace Prelude in main for Protolude. Replace error calls for panic calls. Also replace cs for toS

* Replace Prelude for Protolude

* Replace Prelude for Protolude in OpenAPI
2016-07-23 12:20:36 -07:00
Jacky Hu d3d1fbe7e5 Return HTTP 415 on non root path for openapi req 2016-06-18 10:18:43 +08:00
Diogo Biazus abd81c998b jwtClaims should always return Left for invalid JWT 2016-05-21 13:18:45 -04:00
Joe Nelson 18e3c30ad8 Return proper 401/403 when access denied
Fixes #584
2016-05-15 00:56:47 -07:00
Joe Nelson 5aadfba84b Use read-only transaction mode for read requests (#561)
* Make middleware use ApiRequest rather than Request

* Fix outdated comments

* Use read-only transaction mode for read requests

This allows API requests against read replicas
2016-04-15 12:26:40 -07:00
Joe Nelson eae5857d0e Set role only once, and set it before other GUC vars (#560)
* Set role only once, and set it before other GUC vars

Fixes #559

* Unify role/claim logic in claimsToSQL

Suggested by @diogob
2016-04-15 07:30:36 -07:00
Joe Nelson 358254639a Merge @ruslantalpa's fk improved detection 2016-03-12 12:42:57 -08:00
Joe Nelson a779e9eb8b Batch the sql commands to set local vars 2016-03-11 23:45:05 -08:00
Joe Nelson f67e195f76 Expose all claims via sql postgrest.claims 2016-03-11 20:51:22 -08:00
Ruslan Talpa 40eec0b2ff code beautify using stylish-haskell 2016-02-29 14:53:41 +02:00
Joe Nelson d5c1438c6e Use hasql-transaction
Also use hspec before-wrapper
2016-02-21 18:05:25 -08:00
Joe Nelson 6122bc4108 Middleware compiles 2016-01-24 18:09:18 -08:00
Joe Nelson 72cd6c37bd Change some import statements and Session types 2016-01-24 18:09:18 -08:00
calebmer b651a45734 Fix time fetch on initialization 2015-11-28 16:49:12 -05:00
Ruslan Talpa 50745ad48b Type refactoring (ApiRequest/DbRequest) 2015-11-23 10:12:29 +02:00
Ruslan Talpa f18cfbd7f4 Stricter pattern matching & case branches rearangement + remove a few small functions 2015-11-20 15:36:04 +02:00
Joe Nelson 87c946ef52 Treat JWT as a Secret, not String 2015-11-19 09:58:41 -08:00
calebmer ad555986d4 Error refactors 2015-11-16 17:28:39 -05:00
Ruslan Talpa 6e9a28ba3c fix the missing status400 include 2015-11-12 15:19:11 +02:00
Joe Nelson 22c50392e5 Merge pull request #344 from calebmer/feature/jwt-expire
Ensure JWT expires
2015-11-11 08:31:20 -08:00
calebmer 62cb8e0453 Cleanup JWT expires 2015-11-11 08:34:50 -05:00
calebmer c024687629 Remove secure flag entirely 2015-11-08 13:03:50 -05:00
calebmer 34c153086c Do not redirect insecure requests 2015-11-05 17:42:48 -05:00
calebmer aab2f0d1f1 Ensure JWT expires 2015-11-05 17:04:54 -05:00
Joe Nelson 7692693aae Enforce GHC >= 7.10 and fix Stack warnings 2015-10-23 10:33:27 -07:00
Diogo Biazus d000a6c61a Eliminates SET role duplication and changes Auth module interface 2015-10-22 00:08:02 -04:00
Diogo Biazus 4e9afc8096 Adds import needed by ghc 7.8 2015-10-18 20:05:34 -04:00
Diogo Biazus 241a38e958 Makes JWT generation possible in RPC endpoints
Fixes SET execution to execute in separate statements as Hasql uses
prepared statements we need to send 1 commend per statement.
2015-10-18 02:30:32 -04:00
Diogo Biazus 31f1a30d6f Cleans imports in Middleware and define exports in Auth 2015-10-16 15:56:07 -04:00
Diogo Biazus 3add3f5b6c First draft of big auth simplification 2015-10-16 15:55:47 -04:00
Joe Nelson 3733a84a38 Use type alias for clarity 2015-10-12 17:10:57 -07:00
calebmer 5feb334191 Use postgres connection string 2015-10-11 16:26:29 -04:00
Ruslan Talpa 812135d1e5 cleanup suggested by @begriffs 2015-10-01 10:30:41 +03:00
Ruslan Talpa c42832f1c5 code cleanup 2015-09-25 11:51:37 +03:00
Ruslan Talpa 6f55e1d389 fix for one of the failing tests (acl for tables added) 2015-09-22 18:17:24 +03:00
Joe Nelson 35f05f6fe1 Standardize indentation 2015-09-06 16:13:11 -07:00
Joe Nelson 1656fb9f57 Let the transaction reset the role and user id for us 2015-08-26 20:49:23 -07:00
Diogo BiazusandJoe Nelson 3b017dfdf6 Adds 415 response for any non-empty Accept header different from application/json or text/csv. Uses apropriate Content-Type header when sending CSV format. 2015-08-20 20:47:36 -07:00
Federico Rampazzo 83f48dcd15 User_id support (via user_vars) 2015-05-24 03:26:42 +01:00