-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from COS301-SE-2024/development
Final Demo 3 merge
- Loading branch information
Showing
155 changed files
with
15,213 additions
and
3,129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy | ||
# More GitHub Actions for Azure: https://github.com/Azure/actions | ||
|
||
name: Build and deploy ASP.Net Core app to Azure Web App - BeakPeekApi | ||
|
||
env: | ||
# DOTNET_ROOT: ./dotnet/BeakPeekApi/ | ||
DOTNET_ROOT: . | ||
AZURE_SQL_CONNECTIONSTRING: ${{ secrets.AZURE_SQL_CONNECTIONSTRING }} | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- development | ||
paths-ignore: | ||
- 'doc/**' | ||
- 'res/**' | ||
- 'beakpeek/**' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up .NET Core | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: '8.x' | ||
include-prerelease: true | ||
|
||
- name: Get App Setting | ||
run: | | ||
cd ./dotnet/BeakPeekApi | ||
cp ../../appsettings.json . | ||
- name: Build with dotnet | ||
run: dotnet build --configuration Release ./dotnet/BeakPeekApi/BeakPeekApi.csproj | ||
|
||
- name: dotnet publish | ||
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/BeakPeekApi ./dotnet/BeakPeekApi/BeakPeekApi.csproj | ||
|
||
- name: Copy CSV files | ||
run: | | ||
mkdir -p ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species | ||
cp -r ./res/species/* ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species/ | ||
mkdir -p ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species_list/ | ||
cp -r ./res/species_list/* ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species_list/ | ||
- name: Upload artifact for deployment job | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: .net-app | ||
path: ${{env.DOTNET_ROOT}}/BeakPeekApi | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
environment: | ||
name: 'Production' | ||
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | ||
permissions: | ||
id-token: write #This is required for requesting the JWT | ||
|
||
steps: | ||
- name: Download artifact from build job | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: .net-app | ||
|
||
- name: Login to Azure | ||
uses: azure/login@v1 | ||
with: | ||
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_F91BBE34AB4B45898BF82BFADF359BE8 }} | ||
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_F1EE328E09964C2EA0E92A6629C60647 }} | ||
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_97F61458BB2B43A89AB06261472988FE }} | ||
|
||
- name: Deploy to Azure Web App | ||
id: deploy-to-webapp | ||
uses: azure/webapps-deploy@v2 | ||
with: | ||
app-name: 'BeakPeekBirdApi' | ||
slot-name: 'Production' | ||
package: . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "interactive" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ | |
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
"AllowedHosts": "*", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
description: This file stores settings for Dart & Flutter DevTools. | ||
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states | ||
extensions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// ignore_for_file: use_build_context_synchronously | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_web_auth_2/flutter_web_auth_2.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'dart:convert' show jsonDecode; | ||
import 'package:http/http.dart' as http; | ||
import 'package:beakpeek/config_azure.dart' as config; | ||
|
||
void loginFunction(BuildContext context) async { | ||
final url = Uri.https( | ||
'beakpeak.b2clogin.com', | ||
'beakpeak.onmicrosoft.com/B2C_1_SignUpAndSignInUserFlow/oauth2/v2.0/authorize', | ||
{ | ||
'response_type': 'code', | ||
'client_id': config.clientID, | ||
'redirect_uri': config.redirectURL, | ||
'scope': config.scope, | ||
}, | ||
); | ||
|
||
final result = await FlutterWebAuth2.authenticate( | ||
url: url.toString(), callbackUrlScheme: 'com.example.beakpeek'); | ||
|
||
final code = Uri.parse(result).queryParameters['code']; | ||
|
||
final tokenUrl = Uri.https(config.initialUrl, config.tokenUrl); | ||
|
||
final response = await http.post( | ||
tokenUrl, | ||
body: { | ||
'client_id': config.clientID, | ||
'scope': 'openid', | ||
'redirect_uri': config.redirectURL, | ||
'grant_type': 'authorization_code', | ||
'code': code, | ||
}, | ||
); | ||
|
||
if (response.statusCode == 400) { | ||
context.go('/'); | ||
return; | ||
} | ||
|
||
final accessToken = jsonDecode(response.body)['id_token'] as String; | ||
|
||
config.accessToken = accessToken; | ||
config.loggedIN = true; | ||
context.go('/home'); | ||
} |
Oops, something went wrong.