Skip to content

Commit

Permalink
Add public option to documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Oz-Okun committed Jun 8, 2023
1 parent 7fda608 commit e3662c8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 37 deletions.
4 changes: 1 addition & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,4 @@ runs:
- name: Upload files to azure storage
shell: bash
run: |
curl --request POST --header "Authorization: Bearer ${{steps.token.outputs.token}}" --header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' --form Docs=@vuepress/docs/.vuepress/dist/Docs.zip "https://developer.bcc.no/UploadDoc?isPublic=${{inputs.public}}"
curl --request POST --header "Authorization: Bearer ${{steps.token.outputs.token}}" --header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' --form Docs=@vuepress/docs/.vuepress/dist/Docs.zip "https://developer.bcc.no/UploadDoc?isPublic=${{inputs.public}}"
61 changes: 29 additions & 32 deletions auth-proxy/backend/documentation-site/Models/CustomTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,54 +85,51 @@ public override async ValueTask TransformRequestAsync(HttpContext httpContext,Ht
}
#endregion

if (containerName != "bcc-core-api")
{
#region authenticate user access
var usersInRepo = await getmembers.GetUsersInRepo("", containerName); //Gets the cached list of users who have access to the repository
#region authenticate user access
var usersInRepo = await getmembers.GetUsersInRepo("", containerName); //Gets the cached list of users who have access to the repository

//Checks if repository members exsists in the cache
if (usersInRepo.IsNullOrEmpty())
{
//Checks if repository members exsists in the cache
if (usersInRepo.IsNullOrEmpty())
{

string gitToken = await getmembers.GetTokenFromAzurePem(); //Calling this method to get github token using the azure vault pem file
string gitToken = await getmembers.GetTokenFromAzurePem(); //Calling this method to get github token using the azure vault pem file

var users = await getmembers.GetUsersInRepo(gitToken, containerName); //Calling method to retrive users who have access to the repo
var users = await getmembers.GetUsersInRepo(gitToken, containerName); //Calling method to retrive users who have access to the repo

//Checks if repo is not public (if list contains the element "404", repo is public) or Public file within container exists
if (!(users.Contains(404)) && !(await token.IsPublic(containerName)))
//Checks if repo is not public (if list contains the element "404", repo is public) or Public file within container exists
if (!(users.Contains(404)) && !(await token.IsPublic(containerName)))
{
//If the list is an empty list the repository doesnt exsists
if (users.IsNullOrEmpty())
{
//If the list is an empty list the repository doesnt exsists
if (users.IsNullOrEmpty())
httpContext.Response.StatusCode = 403;
return;
}
//Returns if the current logged user exsists whitin the list of allowed people
else
{
if (!users.Contains(int.Parse(httpContext.Request.Headers["X-MS-CLIENT-PRINCIPAL-ID"])))
{
httpContext.Response.StatusCode = 403;
return;
}
//Returns if the current logged user exsists whitin the list of allowed people
else
{
if (!users.Contains(int.Parse(httpContext.Request.Headers["X-MS-CLIENT-PRINCIPAL-ID"])))
{
httpContext.Response.StatusCode = 403;
return;
}
}
}
}
else
}
else
{
//Checks if cached repo is public or not
if (!usersInRepo.Contains(404) && !(await token.IsPublic(containerName)))
{
//Checks if cached repo is public or not
if (!usersInRepo.Contains(404) && !(await token.IsPublic(containerName)))
//Checks if user exsists in the cached repo
if (!usersInRepo.Contains(int.Parse(httpContext.Request.Headers["X-MS-CLIENT-PRINCIPAL-ID"])))
{
//Checks if user exsists in the cached repo
if (!usersInRepo.Contains(int.Parse(httpContext.Request.Headers["X-MS-CLIENT-PRINCIPAL-ID"])))
{
httpContext.Response.StatusCode = 403;
return;
}
httpContext.Response.StatusCode = 403;
return;
}
}
#endregion
}
#endregion
}

#region SubPath check
Expand Down
19 changes: 17 additions & 2 deletions docs/deploying-site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Build documentation site
uses: bcc-code/bcc-documentation-base@v2
uses: bcc-code/bcc-documentation-base@v3
with:
title: FILL IN
description: FILL IN
Expand All @@ -59,7 +59,7 @@ It is possible to use a different folder than `docs` for documentation. This can
```yml
steps:
- name: Build documentation site
uses: bcc-code/bcc-documentation-base@v1
uses: bcc-code/bcc-documentation-base@v3
with:
...
docs-dir: documentation
Expand All @@ -73,3 +73,18 @@ on:
paths:
- documentation/**
```

#### Make documentation publicly available
For private repositories by default, the documentation is only visible to github members who are apart of the bcc-code organization or the collaborators of the repository.
But if you want your documentation to be accessiable to **anyone** with a github account, than it can be configured using the `public` option in the action:
```yml
steps:
- name: Build documentation site
uses: bcc-code/bcc-documentation-base@v3
with:
...
public: true
```
::: warning <del></del>
Be sure you are using **v3** or later of the action.
:::
7 changes: 7 additions & 0 deletions docs/deploying-site/action.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,10 @@ The directory from where Vue components should automatically be registered
Type: `string`

Default: `src/components`

### public <Badge type="warning" text="v3 or later" vertical="middle" />
Wheter or not the documentation will be publicly available or not (works only for private repositories)

Type: `bool`

Default: `false`

0 comments on commit e3662c8

Please sign in to comment.