GoogleCloudPlatform / emblem

Archived: Emblem Giving is a sample application that demonstrates a serverless architecture with continuous delivery, and trouble recovery. :diamond_shape_with_a_dot_inside:
Apache License 2.0
239 stars 61 forks source link

Unstable user authentication in website #206

Closed grayside closed 2 years ago

grayside commented 3 years ago

This issue is non-standard, representing a meta bug of observed problems and churn related to user authentication in the website. In order to meet scheduled duedates, I'm going to see if I can help fix it.

Special Challenges

We are trying to use Cloud Identity Platform to tell a story of how customers can have broad SSO capability in their apps.

However, most of the technical information we need is in the Firebase Authentication documentation, using the Firebase Authentication library, and we are building a "backend website", which we perceive as being a secondary use case for the Firebase documentation. This has made it difficult to get a comprehensive understanding of what needs to happen.

Observed Problems

Gap Analysis

User Authentication Middleware

https://github.com/GoogleCloudPlatform/emblem/blob/b6db1a4c9a13609d14a7e2f97702a36d1985189b/website/middleware/auth.py#L23-L29

User Login Flow

https://github.com/GoogleCloudPlatform/emblem/blob/b6db1a4c9a13609d14a7e2f97702a36d1985189b/website/static/login.js#L35-L43

Login User Interface

https://github.com/GoogleCloudPlatform/emblem/blob/b6db1a4c9a13609d14a7e2f97702a36d1985189b/website/templates/base.html#L67-L81

Troubleshooting

Unauthenticated, Home Page, API Success

Browser -> Auth Middleware (Skip, No Token) -> API Request (List Campaigns -> API Success -> Log API Request -> Render Page

Unauthenticated, Home Page, API 5xx error

Browser -> Auth Middleware (Skip, No Token) -> API Request (List Campaigns) -> API Fail -> Log API Request -> Error Page

Future Note: We should enhance error handling to insert default text when it's a 5xx failure on read-only operations.

Authenticated, Home Page, Day 0, API Success

Browser -> Auth Middleware (Validate) -> Auth Middleware (Generate ID Token) -> API Request (List Campaigns) -> API Success -> Log API Request -> Render Page

Authenticated, Home Page, Day 20

Browser -> Auth Middleware (Validate) -> Auth Middleware (Expired Token Found) -> Redirect to Logout

Invalid Auth, Home Page

Browser -> Auth Middleware (Validate) -> Auth Middleware (Invalid Session) -> HTTP 401

Tasks

Future Tasks

grayside commented 3 years ago

After completing that analysis and starting to pursue the work, I found the amount of complexity in the implementation, the products, and the documentation seems untenable. Team is going to have some discussions on whether we're going to stick with Identity Platform, and try putting together a comprehensive approach for next steps.

grayside commented 2 years ago

This was fixed by switching to Google Identity/Google Sign-in. See #210, #212.