0003 - AWS Amplify for Authentication¶
Date¶
2022-05-27
Status¶
Accepted
Context¶
Authentication behaviour is written with custom code, and requires reasonably low level understanding of React to implement including context providers and custom hooks. We want a way to authenticate front-end users in the most maintainable and secure way possible.
Decision¶
We will refactor the current front-end auth framework to use AWS Amplify Auth.
Consequences¶
Positive Consequences: Refactoring to an Amplify authentication flow drastically reduces the amount of code that needs to be maintained by Evenergi developers. This provides more time to work on core feature development and also reduces the maintenance and security risks associated with in-house authentication code.
Using Amplify is also a transition made easier because of our current use of a Cognito backend authentication server as specified in 0002 - Cognito for Authentication and Authorisation.
In the future, having a fully-fledged design system will be important to the consistent and quick development of frontend behaviour. Amplify comes with a built-in design system and component library for easy use. We imagine that this will incur significant reductions to the creation time for new UI elements.
Negative Consequences: Amplify itself is a relatively large library. This means that the bundle size of the frontend application may increase in size compared to a custom-code auth strategy. However, the bundle size can be reduced through multiple strategies such as smart importing.
The ability to migrate easily to a different cloud service provider may require more effort than a native auth implementation because of the intrinsic link between Amplify and AWS.