Skip to content

Commit 3b0bad9

Browse files
committed
Updated resource provisioning script with creation and assignment of Oauth roles associated with app registrations governing our function app and static website
1 parent 0eab1b7 commit 3b0bad9

File tree

13 files changed

+196
-13
lines changed

13 files changed

+196
-13
lines changed

README.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Once the CSV has been uploaded to the storage blob, another, blob-triggered Azur
66
The computed statistics are then stored in a new blob container, which is used to serve the results to the user.
77
These two functions are defined in the python script [function_app.py](hvalfangst_function/function_app.py) - which is the main entrypoint of our Azure Function App instance.
88

9+
The SPA is protected with Oauth2.0 authorization code flow with PKCE and OIDC. The user is redirected to the Azure AD login page, where they must authenticate before being redirected back to the SPA.
10+
11+
912
The associated Azure infrastructure is deployed with a script (more on that below).
1013

1114
A branch-triggered pipeline has been set up to deploy our code to the respective Azure resources using a GitHub Actions Workflows [script](.github/workflows/deploy_to_azure.yml).
@@ -24,7 +27,7 @@ Thus, deploying the website is simply a matter of uploading the static files to
2427

2528
## Allocate resources
2629

27-
The shell script [allocate_resources](infra/allocate_resources.sh) creates Azure resources using the Azure CLI and a
30+
The shell script [allocate_resources](infra/allocate_resources.sh) creates Azure resources using the Azure CLI in conjunction with a
2831
[Bicep](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/overview?tabs=bicep) template [file](infra/main.bicep).
2932

3033
It will create the following hierarchy of resources:
@@ -47,6 +50,26 @@ graph TD
4750
B -->|Contains| F
4851
```
4952

53+
## Registrations
54+
In addition to the resources listed above, the script will also create a **service principal** and two Microsoft Entra ID **app registrations.**
55+
56+
### Service Principal for GitHub Actions
57+
The service principal has been assigned contributor role to our resource group, which is sufficient in order to deploy the static web app to the storage blob.
58+
It has been assigned a federated credential configured to work with this repository as it is utilized in our CI/CD [GitHub Actions Workflow script](.github/workflows/deploy_to_azure.yml).
59+
60+
### App Registration for Azure Function App
61+
62+
Exposes the scopes **Csv.Writer** and **Csv.Reader** under URI **api://hvalfangst-function-app**
63+
64+
![img.png](images/img.png)
65+
66+
### App Registration for SPA
67+
68+
Has a redirect URI configured to the static web app's URL and the permissions **Csv.Writer** and the OIDC ones.
69+
70+
![img_1.png](images/img_1.png)
71+
72+
5073
## GitHub secrets
5174
Four secrets are required in order for the GitHub Actions Workflow script to deploy the code to the Azure resources.
5275
As may be observed in the [script](.github/workflows/deploy_to_azure.yml), these are:
@@ -56,4 +79,33 @@ As may be observed in the [script](.github/workflows/deploy_to_azure.yml), these
5679
- **AZURE_TENANT_ID**: Used to authenticate the service principal in order to deploy the static web app
5780
- **PUBLISH_PROFILE**: Used to deploy our two functions to the Azure Function App
5881

59-
![img_1.png](images/img_1.png)
82+
![secrets.png](images/secrets.png)
83+
84+
## Usage
85+
After provisioning resources, setting up secrets, and pushing the code to the repository, one
86+
may access the static web app by navigating to the following URL:
87+
88+
```plaintext
89+
https://<storage_account_name>.z6.web.core.windows.net
90+
```
91+
92+
You will be presented with the following.
93+
94+
![img_2.png](images/img_2.png)
95+
96+
Click on **Sign In** to initiate the OIDC flow - which redirects to the Azure AD permission consent screen.
97+
98+
![oidc.png](images/oidc.png)
99+
100+
Clik on **Accept** to be redirected back to the SPA, where you will be greeted with the following.
101+
102+
![authenticated_user.png](images/authenticated_user.png)
103+
104+
Proceed to click on **Upload** to choose a file to upload. Pick the CSV file named [input](input.csv) which has been provided for this purpose.
105+
106+
![img_5.png](images/img_5.png)
107+
108+
![img_6.png](images/img_6.png)
109+
110+
The file name will be displayed in the input field. Click on **Upload** to attempt to upload the file to the storage blob.
111+

images/authenticated_user.png

11.3 KB
Loading

images/img.png

93.6 KB
Loading

images/img_1.png

69.2 KB
Loading

images/img_2.png

9.11 KB
Loading

images/img_3.png

8.57 KB
Loading

images/img_4.png

63.7 KB
Loading

images/img_5.png

8.19 KB
Loading

images/img_6.png

3.67 KB
Loading

images/oidc.png

26.8 KB
Loading

0 commit comments

Comments
 (0)