feat: Sign in with GitHub (#4881)

Implemented GitHub sign in button with ability to link Google account to it.
Fixes: https://github.com/flutter/flutter/issues/177627

There several possible scenarios:
1. User signing in to the dashboard with a Github account. In this scenario:
    - Firebase account created based on Github account:
      - User email: Github account primary email
      - User avatar: Github account avatar
      - User First and Last name: Github account First and Last name
    - Google account can be linked using “Link Google Account” menu item
2. User signing in to the dashboard with a Github account and trying to link to a Google account that was never used before. In this scenario:
    - After linking Google, Github account will be deleted from firebase and then linked to that Google account:
      - User email: Google account primary email
      - User avatar: Google account avatar
      - User First and Last name: Google account First and Last name
    - Github credential will be used for future signing in but “Unlink Google Account” menu item will be shown for user
3. User is trying to sign in with a Github account that has a primary email already registered as a Google account. In this scenario: 
    - Dashboard will ask the user to sign in with a Google account first (in most cases the account is already cached and the user would not see Sign in with Google popup).
    - After signing in with Google, Github account automatically linked to that Google account
    - Firebase account remains based on Google account:
      - User email: Google account primary email
      - User avatar: Google account avatar
      - User First and Last name: Google account First and Last name
    - Github credential will be used for future signing in but “Unlink Google Account” menu item will be shown for user
4. User signed in with a Github account that primary email was never registered but trying to link google account that already registered. In that scenario:
    - Github needs to be deleted from firebase. In order to do that:
      - To avoid [FirebaseAuthException] with requires-recent-login error code user will be automatically re signed in
      - Then Github account will be deleted from firebase
    - Then the dashboard will ask the user to sign in with a Google account (in most cases the account is already cached and the user would not see Sign in with Google popup).
    - Lastly Github account automatically linked to that Google account
    - Firebase account remains based on Google account:
      - User email: Google account primary email
      - User avatar: Google account avatar
      - User First and Last name: Google account First and Last name
    - Github credential will be used for future signing in but “Unlink Google Account” menu item will be shown for user.
4. If a user already signed with a Google account after dashboard update they would have the option to link Github Account to their Google account.
10 files changed
tree: 3fb0bceb89066758fb6964fa2f3e35862504b80d
  1. .github/
  2. analyze/
  3. app_dart/
  4. auto_submit/
  5. cipd_packages/
  6. cloud_build/
  7. dashboard/
  8. dev/
  9. licenses/
  10. packages/
  11. test_utilities/
  12. tooling/
  13. .ci.yaml
  14. .gitattributes
  15. .gitignore
  16. analysis_options.yaml
  17. CI_YAML.md
  18. cloudbuild_cron.yaml
  19. cocoon.code-workspace
  20. CODEOWNERS
  21. CONTRIBUTING.md
  22. cron.yaml
  23. Dockerfile.app_dart
  24. Dockerfile.auto_submit
  25. LICENSE
  26. pubspec.yaml
  27. README.md
  28. tests.yaml
README.md

Flutter CI Status SLSA 3

Cocoon is a Dart App Engine custom runtime (backend) with a frontend of Flutter apps (build and repository dashboard). Cocoon coordinates and aggregates the results of flutter/flutter builds.

It is not designed to help developers build Flutter apps.

Cocoon is not a Google product.

Using Cocoon

Forcing a refresh from GitHub

The server is driven by commits made to https://github.com/flutter/flutter repo. It periodically syncs new commits. If you need to manually force a refresh, query https://flutter-dashboard.appspot.com/api/refresh-github-commits.

You will need to be authenticated with Cocoon to do this.

Developing Cocoon

Cocoon has several components:

  • A server, which coordinates everything. This is a Dart App Engine application. If you have never used that before, you may want to peruse the samples for Dart App Engine. The server is found in app_dart.

  • A Flutter app (generally used as a Web app) for the build dashboards. The dashboard is found in dashboard.

Cocoon creates a checklist for each Flutter commit. A checklist is made of multiple tasks. Tasks are performed by LUCI bots.

Getting started

First, set up a Flutter development environment. This will, as a side-effect, provide you with a Dart SDK. Your life will be easier if you add that (.../flutter/bin/cache/dart-sdk/bin/) to your path.

To update the production server, you will need the Google Cloud SDK. Since there is no Dart SDK, we just use the command line tools.

Developing the server

All the commands in this section assume that you are in the app_dart/ directory.

Running a local dev server

dart bin/local_server.dart

This will output Serving requests at 0.0.0.0:8080 indicating the server is working.

New requests will be logged to the console.

Deploying a test version on Google Cloud

To run live tests, build the app, and provide instructions for deploying to Google App Engine, run this command:

dart dev/deploy.dart --project {PROJECT} --version {VERSION}

You can test the new version by accessing {VERSION}-dot-flutter-dashboard.appspot.com in your browser. If the result is satisfactory, the new version can be activated by using the Cloud Console UI: https://console.cloud.google.com/appengine/versions?project=flutter-dashboard&serviceId=default

Optional flags

--profile: Deploy a profile mode of dashboard application for debugging purposes.

--ignore-version-check: Ignore the version of Flutter on path (expects to be relatively recent)

Developing the dashboard

The dashboard application will use dummy data when it is not connected to the server, so it can be developed locally without a dev server.

To run the dashboard locally, go into the dashboard directory and run flutter run -d chrome. The dashboard will be served from localhost (the exact address will be given on the console); copy the URL into your browser to view the application. (The dashboard should also be able to run on non-Web platforms, but since the Web is our main target that is the one that should generally be used for development.)

You can run flutter packages upgrade to update the dependencies. This may be necessary if you see a failure in the dependencies.