avoinministerio/am-signing — pull request #3 by jjuutila (2012-08-09 07:28:14+00:00)
Title: Signing error handling

Moved some validations to Signature from SignaturesController. SignaturesController uses exceptions for illegal actions instead of a @error variable. Message from AM application should HMAC signed.

TO-DO:
* Proper name validation in Signature.
* Age validation in Signature.
* Change Signature.accept_science to a not mandatory field.
* Update begin_authenticating view to have form for just one TUPAS service.
* Add controller actions rejected and cancelled.
* Add missing TUPAS MAC validation to controller. Jaakkos' TUPAS gem probably implements this but it is not ready yet.
* Current controller rescue_from methods are "stubs". Controller should probably redirect user back to AM when those resqued errors have occurred.
* Add timestamp field (returned_at) for time when the user has returned from TUPAS service (in Signature#authenticate).
* Test is it possible to "invalidate" a Signature in "signed" state.
* Signature#authenticate does not change the state (as Jyrki noted) if trying to authenticate a Signature that is in some other state than "init" (line 32). For me it is unclear what should be done.
* Also the Signature state is not changed when using Signature#find_authenticated_by_citizen method. E.g. some other user, then the one who created the Signature, is trying to finalize signing. Is the state change needed anyway?
* Clear sessions when returning back to AM application.