Skip to content

Commit

Permalink
Add information about using GitHub codespace
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-kiaer committed Sep 26, 2023
1 parent fd1d428 commit 2656553
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,20 @@ git push upstream <featurebranchname>:review --force
```
The `main` branch only accepts commits through pull requests.

NB: Note that Radix will always use the `radixconfig.yml` as it is in `main` branch (unless changed in Radix UI).
NB: Note that Radix will always use the `radixconfig.yml` as it is in `main` branch (unless changed in Radix UI).

### Usage in GitHub codespaces

Using the standard GitHub codespace image, you can easily start up the application by running
the same command as locally:
```
docker-compose up
```
in the terminal. When using GitHub codespaces you do not have to create the `.env` file since
environment variables are automatically set up for you at startup through repository settings.
Note that you need to have at least "collaborator" role in the repository in order to have
environment variables automatically set up.

When you start up the docker containers, GitHub codespace will automatically make a link where
you can access the application in development mode (i.e. changes you do the code will automatically
be reflected in the application).
13 changes: 9 additions & 4 deletions backend/src/backend/auth/auth_helper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import base64
import time
from typing import List, Optional
Expand Down Expand Up @@ -33,11 +34,15 @@ async def _login_route(self, request: Request, redirect_url_after_login: Optiona
for value in config.RESOURCE_SCOPES_DICT.values():
all_scopes_list.extend(value)

if "CODESPACE_NAME" in os.environ:
# Developer is using GitHub codespace, so we use the GitHub codespace provided URL instead of localhost.
redirect_uri = f"https://{os.environ['CODESPACE_NAME']}-8080.app.github.dev/api/auth-callback"
print("You are using GitHub codespace. Remember to allo app registration redirect URI {redirect_uri}")
else:
redirect_uri = str(request.url_for("_authorized_callback_route"))

cca = _create_msal_confidential_client_app(token_cache=None)
flow_dict = cca.initiate_auth_code_flow(
scopes=all_scopes_list,
redirect_uri=str(request.url_for("_authorized_callback_route")),
)
flow_dict = cca.initiate_auth_code_flow(scopes=all_scopes_list, redirect_uri=redirect_uri)

request.session["flow"] = flow_dict

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:
- WEBVIZ_SMDA_RESOURCE_SCOPE
- WEBVIZ_SMDA_SUBSCRIPTION_KEY
- WEBVIZ_SUMO_ENV
- CODESPACE_NAME # Automatically set env. variable by GitHub codespace
volumes:
- ./backend/src:/home/appuser/backend/src

Expand Down

0 comments on commit 2656553

Please sign in to comment.