“App Dev: Adding User Authentication to your Application – Python”
Daftar Isi
Pengantar
Identity Platform menyediakan layanan autentikasi drop-in yang dapat disesuaikan untuk pendaftaran dan masuk pengguna. Aktivitas pengembangan dan admin menjadi lebih mudah dengan berbagai SDK aplikasi (Android, iOS, dan web) serta SDK admin (Node.js, Java, Python, dan lainnya). Untuk informasi selengkapnya tentang Platform Identitas, lihat Platform Identitas.
Aplikasi yang digunakan dalam lab ini adalah aplikasi Quiz online. Anda menambahkan autentikasi Identity Platform, lalu mengonfigurasi autentikasi untuk menggunakan alamat email sederhana dan kredensial kata sandi. Terakhir, Anda memastikan bahwa pengguna harus mendaftar dan masuk sebelum mengikuti kuis.
Praktikum
Task 1. Prepare the case study application
Clone source code in Cloud Shell
- Clone the application skeleton from a repository on GitHub.com:
git clone https://github.com/GoogleCloudPlatform/training-data-analyst
ln -s ~/training-data-analyst/courses/developingapps/v1.3/python/firebase ~/firebase
Configure and run the case study application
- Navigate to the directory that contains the sample files for this lab:
cd ~/firebase/start
. prepare_environment.sh
python run_server.py
Start the case study application
- In Cloud Shell, click Web preview Web preveiw icon > Preview on port 8080 to preview the Quiz application.
Task 2. Examine the case study application code
Review the client application
- Navigate to the
/firebase/start
folder using the file browser panel on the left side of the code editor. - Continue navigating. Open
...quiz/webapp/static/client/
. Click on theindex.html
file. - Select the
qiq-login-template.html
file in the...quiz/webapp/static/client/app/auth/
folder. - Still in this folder, select the
qiq-login.js
file.
Task 3. Configure Identity Platform Authentication
Configure Identity Platform for email and password
- In the Google Cloud Console, on the Navigation menu (
- Click Enable Identity Platform.
- Click Add a Provider.
- In the Sign-in method window, for Select a provider, select Email / Password.
- Click Enabled.
- In the Authorized Domains pane, click Add Domain.
- Return to the running Quiz Application and copy the domain (which has the format
8080-27542cac-44d0-41a9-9e96-065800c2100c.ql-europe-west1-ctgq.cloudshell.dev
).
- Paste the domain into the Domain field.
- Modify the pasted domain so that only the domain name is in the Domain field.
- Click Save.
- In the new identity provider window click Save.
Add a user
- In the Identity Platform pane, click Users.
- Click Add User.
- In the Add user dialog box, specify the following:
- Click Add.
Task 4. Integrate a client-side web application with Identity Platform
- In the navigation pane, click Providers.
- Click Application Setup Details.
- In the Configure your application dialog box, copy the Identity Platform markup.
- Click Close.
- In the Cloud Shell code editor, open the
index.html
file in...webapp/static/client/
. - Paste the configuration markup just before the other
<script></script>
tags at the bottom of the page. - Save the
index.html
file.
Task 5. Run the application
- Return to the Quiz application and refresh your browser.
- In the navigation bar, click Take Test.
- In the navigation bar, click GCP, People, or Places.
- in the navigation bar, enter the following invalid credentials:
- Click Login.
- Enter the following credentials that you created in a previous task:
- Click Login.
- In the navigation bar, click Logout.
- Click the Register link.
- In the new form, enter the following credentials:
- Click Register.
- In the navigation bar, click Logout.
- In the Google Cloud Console, in the Identity Platform navigation pane, click Users.
Penutup
Sahabat Blog Learning & Doing demikianlah penjelasan mengenai App Dev: Adding User Authentication to your Application – Python. Semoga Bermanfaat . Sampai ketemu lagi di postingan berikut nya.