Skip to content
Branch: master
Find file History
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
Areas/Identity/Pages
Controllers
Data Update the SocialAuth sample to .NET 2.1. (#641) Oct 16, 2018
Models Update the SocialAuth sample to .NET 2.1. (#641) Oct 16, 2018
Services Update SocialAuth sample so it can be easily deployed to Kubernetes. (#… Jan 16, 2019
Views
wwwroot
.gitignore Update the SocialAuth sample to .NET 2.1. (#641) Oct 16, 2018
Add-KmsPermissions.ps1 Update SocialAuth sample so it can be easily deployed to Kubernetes. (#… Jan 16, 2019
Add-KmsPermissionsToAppEngine.ps1
Decrypt-AppSecrets.ps1
Dockerfile
Encrypt-AppSecrets.ps1
Get-SecretFile.ps1 Add a script to decode kubernetes secret. Jan 30, 2019
New-EncryptionKey.ps1
Program.cs
README.md Update link and text to download .NET SDK. Dec 18, 2018
SocialAuth.csproj Upgrade Google.Cloud.Kms.V1 to version 1.0.0. Feb 4, 2019
SocialAuth.sln Update SocialAuth sample so it can be easily deployed to Kubernetes. (#… Jan 16, 2019
Startup.cs Use forwarded headers (#669) Oct 22, 2018
app.yaml A SocialAuth sample for App Engine. May 31, 2017
appsecrets.json.encrypted Update the SocialAuth sample to .NET 2.1. (#641) Oct 16, 2018
appsecrets.json.keyname Update the SocialAuth sample to .NET 2.1. (#641) Oct 16, 2018
appsettings.Development.json Update the SocialAuth sample to .NET 2.1. (#641) Oct 16, 2018
appsettings.json
runTests.ps1 Update the SocialAuth sample to .NET 2.1. (#641) Oct 16, 2018
test.js Update the SocialAuth sample to .NET 2.1. (#641) Oct 16, 2018

README.md

ASP.NET with Social Log In Sample

This is the companion sample for a medium.com story.

This sample application demonstrates how to let users log into your application running in Google App Engine Flexible Environment with their Facebook or Google credentials.

This sample requires .NET Core 2.1 or newer. That means using Visual Studio 2017, or the dotnet core command line.

Build and Run

  1. Follow the set-up instructions in the documentation.

  2. Enable APIs for your project. Click here to visit Cloud Platform Console and enable the Google Cloud Key Management Service API.

  3. Create an App Engine application. Click here to create an App Engine application.

  4. Create a new encryption key.

    PS > .\New-EncryptionKey.ps1
    projects/<your-project-id>/locations/global/keyRings/socialauth/cryptoKeys/appsecrets
    
  5. Create a file called appsecrets.json and fill it with:

    {
        "Secrets": {
            "Word": "wallfish"
        },
        "Authentication": {
            "Facebook": {
                "AppId": "YOUR-FACEBOOK-APP-ID",
                "AppSecret": "YOUR-FACEBOOK-APP-SECRET"
            }
        },
        "ConnectionStrings": {
            "DefaultConnection": "Server=YOUR.SQL.SERVER-IP-ADDRESS;Database=webusers;User Id=aspnet;Password=YOUR-PASSWORD"
        }    
    }
  6. Encrypt appsecrets.json:

    PS > .\Encrypt-AppSecrets.ps1
    
  7. Initialize your database:

    SQL Server Users:

    PS > dotnet ef database update
    

    Other Database Users:

    PS > dotnet ef migrations remove
    PS > dotnet ef migrations add origin
    PS > dotnet ef database update
    
  8. Run the app locally:

    PS > dotnet run
    Using launch settings from ~/gitrepos/dds2/appengine/flexible/SocialAuth/Properties/launchSettings.json...
    info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
        User profile is available. Using '~/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
    Hosting environment: Development
    Content root path: ~/gitrepos/dds2/appengine/flexible/SocialAuth
    Now listening on: https://localhost:5001
    Now listening on: http://localhost:5000
    Application started. Press Ctrl+C to shut down.
    
  9. Add permissions so the App Engine user account can encrypt and decrypt.

    PS > .\Add-KmsPermissionsToAppEngine.ps1
    Waiting for async operation operations/tmo-acf.0f97d7e0-636a-4e7c-9837-a48c2b87dc8d to complete...
    Operation finished successfully. The following command can describe the Operation details:
    gcloud services operations describe operations/tmo-acf.0f97d7e0-636a-4e7c-9837-a48c2b87dc8d
    Adding role roles/cloudkms.admin to <your-project-id>@appspot.gserviceaccount.com.
    ...
    Adding role roles/cloudkms.cryptoKeyEncrypterDecrypter to <your-project-id>@appspot.gserviceaccount.com.
    ...
    
  10. Deploy the app to App Engine:

    PS > dotnet publish
    Microsoft (R) Build Engine version 15.7.179.6572 for .NET Core
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    Restore completed in 51.22 ms for ~/gitrepos/dds2/appengine/flexible/SocialAuth/SocialAuthMVC.csproj.
    SocialAuthMVC -> ~/gitrepos/dds2/appengine/flexible/SocialAuth/bin/Debug/netcoreapp2.1/SocialAuthMVC.dll
    SocialAuthMVC -> ~/gitrepos/dds2/appengine/flexible/SocialAuth/bin/Debug/netcoreapp2.1/SocialAuthMVC.Views.dll
    SocialAuthMVC -> ~/gitrepos/dds2/appengine/flexible/SocialAuth/bin/Debug/netcoreapp2.1/publish/
    
    PS > gcloud beta app deploy bin/Debug/netcoreapp2.1/publish/app.yaml
    Services to deploy:
    
    descriptor:      [~/gitrepos/dds2/appengine/flexible/SocialAuth/bin/Debug/netcoreapp2.1/publish/app.yaml]
    source:          [~/gitrepos/dds2/appengine/flexible/SocialAuth/bin/Debug/netcoreapp2.1/publish]
    target project:  [<your-project-id>]
    target service:  [default]
    target version:  [20180919t092928]
    target url:      [https://<your-project-id>.appspot.com]
    

Contributing changes

Licensing

Testing

You can’t perform that action at this time.