Compare commits
10 Commits
12e4b46761
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| af0e2919f4 | |||
| beea84a6e9 | |||
| b6570b2385 | |||
| d514029e5a | |||
| 086db87972 | |||
| e90bf240e8 | |||
| 3a56a6b892 | |||
| 6c176b3cdb | |||
| b97c2f7fbc | |||
| 13a5edc9ac |
@ -1,7 +1,6 @@
|
||||
name: build-docker-imge
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -17,12 +16,35 @@ jobs:
|
||||
- name: "Git checkout"
|
||||
run: git checkout "${{ gitea.sha }}"
|
||||
- uses: aevea/action-kaniko@master
|
||||
name: Run Kaniko to build our docker container.
|
||||
name: Run Kaniko to build our api docker container.
|
||||
with:
|
||||
image: kocoded/nachhilfesystem/nachhilfesystem
|
||||
tag: ${{ gitea.workflow_sha }}
|
||||
tag_with_latest: true
|
||||
image: kocoded/nachhilfesystem/api
|
||||
tag: ${{ git.workflow_sha }}
|
||||
tag_with_latest: github.ref == 'refs/heads/master'
|
||||
registry: git.kocoder.xyz
|
||||
username: ${{ secrets.CI_RUNNER_USER }}
|
||||
password: ${{ secrets.CI_RUNNER_TOKEN }}
|
||||
build_file: Dockerfile
|
||||
target: api_serve
|
||||
- uses: aevea/action-kaniko@master
|
||||
name: Run Kaniko to build our web docker container.
|
||||
with:
|
||||
image: kocoded/nachhilfesystem/web
|
||||
tag: ${{ git.workflow_sha }}
|
||||
tag_with_latest: github.ref == 'refs/heads/master'
|
||||
registry: git.kocoder.xyz
|
||||
username: ${{ secrets.CI_RUNNER_USER }}
|
||||
password: ${{ secrets.CI_RUNNER_TOKEN }}
|
||||
build_file: Dockerfile
|
||||
target: web_serve
|
||||
- uses: aevea/action-kaniko@master
|
||||
name: Run Kaniko to build our console docker container.
|
||||
with:
|
||||
image: kocoded/nachhilfesystem/console
|
||||
tag: ${{ git.workflow_sha }}
|
||||
tag_with_latest: github.ref == 'refs/heads/master'
|
||||
registry: git.kocoder.xyz
|
||||
username: ${{ secrets.CI_RUNNER_USER }}
|
||||
password: ${{ secrets.CI_RUNNER_TOKEN }}
|
||||
build_file: Dockerfile
|
||||
target: console
|
||||
|
||||
@ -6,6 +6,10 @@
|
||||
"@redwoodjs/api": "8.3.0",
|
||||
"@redwoodjs/api-server": "8.3.0",
|
||||
"@redwoodjs/auth-dbauth-api": "8.3.0",
|
||||
"@redwoodjs/graphql-server": "8.3.0"
|
||||
"@redwoodjs/graphql-server": "8.3.0",
|
||||
"crypto-js": "^4.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/crypto-js": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,9 +27,10 @@ export const handler = async (event: APIGatewayEvent, _context: Context) => {
|
||||
case '/oauth/microsoft/callback':
|
||||
return await callback(event)
|
||||
default:
|
||||
return {
|
||||
return await callback(event)
|
||||
/*return {
|
||||
statusCode: 404,
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
8
api/src/functions/oauthStart/oauthStart.scenarios.ts
Normal file
8
api/src/functions/oauthStart/oauthStart.scenarios.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import type { ScenarioData } from '@redwoodjs/testing/api'
|
||||
|
||||
export const standard = defineScenario({
|
||||
// Define the "fixture" to write into your test database here
|
||||
// See guide: https://redwoodjs.com/docs/testing#scenarios
|
||||
})
|
||||
|
||||
export type StandardScenario = ScenarioData<unknown>
|
||||
29
api/src/functions/oauthStart/oauthStart.test.ts
Normal file
29
api/src/functions/oauthStart/oauthStart.test.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { mockHttpEvent, mockContext } from '@redwoodjs/testing/api'
|
||||
|
||||
import { handler } from './oauthStart'
|
||||
|
||||
// Improve this test with help from the Redwood Testing Doc:
|
||||
// https://redwoodjs.com/docs/testing#testing-functions
|
||||
|
||||
describe('oauthStart function', () => {
|
||||
it('Should respond with 200', async () => {
|
||||
const httpEvent = mockHttpEvent({
|
||||
queryStringParameters: {
|
||||
id: '42', // Add parameters here
|
||||
},
|
||||
})
|
||||
|
||||
const response = await handler(httpEvent, mockContext())
|
||||
const { data } = JSON.parse(response.body)
|
||||
|
||||
expect(response.statusCode).toBe(200)
|
||||
expect(data).toBe('oauthStart function')
|
||||
})
|
||||
|
||||
// You can also use scenarios to test your api functions
|
||||
// See guide here: https://redwoodjs.com/docs/testing#scenarios
|
||||
//
|
||||
// scenario('Scenario test', async () => {
|
||||
//
|
||||
// })
|
||||
})
|
||||
42
api/src/functions/oauthStart/oauthStart.ts
Normal file
42
api/src/functions/oauthStart/oauthStart.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import type { APIGatewayEvent, Context } from 'aws-lambda'
|
||||
|
||||
import { logger } from 'src/lib/logger'
|
||||
|
||||
/**
|
||||
* The handler function is your code that processes http request events.
|
||||
* You can use return and throw to send a response or error, respectively.
|
||||
*
|
||||
* Important: When deployed, a custom serverless function is an open API endpoint and
|
||||
* is your responsibility to secure appropriately.
|
||||
*
|
||||
* @see {@link https://redwoodjs.com/docs/serverless-functions#security-considerations|Serverless Function Considerations}
|
||||
* in the RedwoodJS documentation for more information.
|
||||
*
|
||||
* @typedef { import('aws-lambda').APIGatewayEvent } APIGatewayEvent
|
||||
* @typedef { import('aws-lambda').Context } Context
|
||||
* @param { APIGatewayEvent } event - an object which contains information from the invoker.
|
||||
* @param { Context } _context - contains information about the invocation,
|
||||
* function, and execution environment.
|
||||
*/
|
||||
export const handler = async (event: APIGatewayEvent, _context: Context) => {
|
||||
logger.info(`${event.httpMethod} ${event.path}: oauth function`)
|
||||
|
||||
switch (event.path) {
|
||||
case '/oauthStart/microsoft':
|
||||
return await callback()
|
||||
default:
|
||||
return await callback()
|
||||
/* return {
|
||||
statusCode: 404,
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
||||
const callback = async () => {
|
||||
return {
|
||||
statusCode: 302,
|
||||
headers: {
|
||||
Location: `https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=${process.env.MICROSOFT_OAUTH_CLIENT_ID}&grant_type=authorization_code&response_type=code&redirect_uri=${process.env.MICROSOFT_OAUTH_REDIRECT_URI}&scope=${process.env.MICROSOFT_OAUTH_SCOPES.split(' ').join('+')}`,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -8,11 +8,8 @@
|
||||
[web]
|
||||
title = "Redwood App"
|
||||
port = 8910
|
||||
apiUrl = "/.redwood/functions" # You can customize graphql and dbauth urls individually too: see https://redwoodjs.com/docs/app-configuration-redwood-toml#api-paths
|
||||
apiUrl = "/api" # You can customize graphql and dbauth urls individually too: see https://redwoodjs.com/docs/app-configuration-redwood-toml#api-paths
|
||||
includeEnvironmentVariables = [
|
||||
"MICROSOFT_OAUTH_CLIENT_ID",
|
||||
"MICROSOFT_OAUTH_SCOPES",
|
||||
"MICROSOFT_OAUTH_REDIRECT_URI",
|
||||
# Add any ENV vars that should be available to the web side to this array
|
||||
# See https://redwoodjs.com/docs/environment-variables#web
|
||||
]
|
||||
|
||||
@ -53,11 +53,7 @@ export default function Hero() {
|
||||
</p>
|
||||
<div className="mt-10 flex items-center gap-x-6">
|
||||
<a
|
||||
href={`https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=${
|
||||
process.env.MICROSOFT_OAUTH_CLIENT_ID
|
||||
}&grant_type=authorization_code&response_type=code&redirect_uri=${
|
||||
process.env.MICROSOFT_OAUTH_REDIRECT_URI
|
||||
}&scope=${process.env.MICROSOFT_OAUTH_SCOPES.split(' ').join('+')}`}
|
||||
href={`${window.RWJS_API_URL}/oauthStart/microsoft`}
|
||||
className="rounded-md bg-indigo-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
|
||||
>
|
||||
Anmelden
|
||||
|
||||
@ -7476,6 +7476,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/crypto-js@npm:^4":
|
||||
version: 4.2.2
|
||||
resolution: "@types/crypto-js@npm:4.2.2"
|
||||
checksum: 10c0/760a2078f36f2a3a1089ef367b0d13229876adcf4bcd6e8824d00d9e9bfad8118dc7e6a3cc66322b083535e12be3a29044ccdc9603bfb12519ff61551a3322c6
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/debug@npm:^4.1.7":
|
||||
version: 4.1.12
|
||||
resolution: "@types/debug@npm:4.1.12"
|
||||
@ -8624,6 +8631,8 @@ __metadata:
|
||||
"@redwoodjs/api-server": "npm:8.3.0"
|
||||
"@redwoodjs/auth-dbauth-api": "npm:8.3.0"
|
||||
"@redwoodjs/graphql-server": "npm:8.3.0"
|
||||
"@types/crypto-js": "npm:^4"
|
||||
crypto-js: "npm:^4.2.0"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
|
||||
Reference in New Issue
Block a user