Skip to content

Commit

Permalink
Update bicep for APIM authN (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinyoo committed Oct 2, 2023
1 parent 2fa1e87 commit 2a7d65a
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
18 changes: 18 additions & 0 deletions infra/apim-policy-github-operation-getaccesstoken.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<policies>
<inbound>
<base />
<get-authorization-context provider-id="github" authorization-id="github" context-variable-name="auth-context" identity-type="managed" ignore-error="false" />
<return-response>
<set-body>@(((Authorization)context.Variables.GetValueOrDefault("auth-context"))?.AccessToken)</set-body>
</return-response>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
26 changes: 26 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,32 @@ var apps = [
operations: []
}
}
{
name: 'github'
isFunctionApp: false
functionAppSuffix: 'github'
appSettings: {}
apimIntegrated: true
api: {
name: 'GITHUB'
path: 'github'
serviceUrl: 'https://api.github.com'
referenceUrl: 'https://raw.githubusercontent.com/${gitHubUsername}/${gitHubRepositoryName}/${gitHubBranchName}/infra/openapi-{{SUFFIX}}.{{EXTENSION}}'
format: 'openapi-link'
extension: 'yaml'
subscription: true
product: 'default'
operations: [
{
name: 'GetAccessToken'
policy: {
format: 'xml-link'
value: 'https://raw.githubusercontent.com/${gitHubUsername}/${gitHubRepositoryName}/${gitHubBranchName}/infra/apim-policy-github-operation-getaccesstoken.xml'
}
}
]
}
}
]

module apim './provision-ApiManagement.bicep' = {
Expand Down
30 changes: 30 additions & 0 deletions infra/openapi-github.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
openapi: 3.0.1
info:
title: GitHub Auth API
description: This is a set of APIs that deals with GitHub authN APIs.
license:
name: MIT
url: http://opensource.org/licenses/MIT
version: 1.0.0
servers:
- url: http://localhost:7071/api
paths:
/access-token:
post:
tags:
- auth
summary: Gets the GitHub OAuth access token
description: This gets the OAuth access token for GitHub API.
operationId: getAccessToken
responses:
'200':
description: This returns the completion generated from the OpenAI API.
content:
text/plain:
schema:
type: string
examples:
access-token:
value: "WW91VHViZSBTZXJpYWxpc2Vy"
x-ms-summary: The access token generated from GitHub.
x-ms-visibility: important

0 comments on commit 2a7d65a

Please sign in to comment.