Compare commits

..

10 Commits

Author SHA1 Message Date
af0e2919f4 Move callbacks to the default switch blocks...
All checks were successful
build-docker-imge / Build the docker container (push) Successful in 28m24s
2024-10-06 21:10:50 +02:00
beea84a6e9 Remove trailing spaces in link
All checks were successful
build-docker-imge / Build the docker container (push) Successful in 28m7s
2024-10-06 20:38:14 +02:00
b6570b2385 use window instead of global for the RWJS_API_URL Variable
Some checks failed
build-docker-imge / Build the docker container (push) Has been cancelled
2024-10-06 20:13:15 +02:00
d514029e5a Move link-building to the server...
All checks were successful
build-docker-imge / Build the docker container (push) Successful in 28m38s
2024-10-06 17:55:27 +02:00
086db87972 Adjust apiUrl
All checks were successful
build-docker-imge / Build the docker container (push) Successful in 27m50s
2024-10-06 16:47:47 +02:00
e90bf240e8 Reset typescript version in yarn.lock
All checks were successful
build-docker-imge / Build the docker container (push) Successful in 29m35s
2024-10-06 15:32:35 +02:00
3a56a6b892 Add crypto-js to required Modules
Some checks failed
build-docker-imge / Build the docker container (push) Failing after 44s
2024-10-06 14:44:37 +02:00
6c176b3cdb Container-tags: add version, use diffrent names for web, api, and console
All checks were successful
build-docker-imge / Build the docker container (push) Successful in 27m43s
2024-10-06 10:22:54 +02:00
b97c2f7fbc Container-tags: remove version
All checks were successful
build-docker-imge / Build the docker container (push) Successful in 38m47s
2024-10-04 20:36:19 +02:00
13a5edc9ac Build each target container individually
Some checks failed
build-docker-imge / Build the docker container (push) Failing after 8m29s
build-docker-imge / Build the docker container (pull_request) Failing after 8m7s
2024-10-04 19:55:55 +02:00
9 changed files with 125 additions and 17 deletions

View File

@ -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

View File

@ -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"
}
}

View File

@ -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,
}
}*/
}
}

View 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>

View 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 () => {
//
// })
})

View 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('+')}`,
},
}
}

View File

@ -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
]

View File

@ -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

View File

@ -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