Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added all auth url in oathkeeper #3299

Merged
merged 3 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/api/dev/ory/oathkeeper_rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
upstream:
url: "http://bats-tests:4012"
match:
url: "<(http|https)>://<[a-zA-Z0-9-.:]+>/auth/<(clearCookies|login|logout|email/code|email/login|totp/validate|email/login/cookie)>"
url: "<(http|https)>://<[a-zA-Z0-9-.:]+>/auth/<(clearCookies|login|logout|email/code|email/login|totp/validate|email/login/cookie|phone/captcha|phone/code|phone/login)>"
methods: ["GET", "POST", "OPTIONS"]
authenticators:
- handler: anonymous
Expand Down
20 changes: 10 additions & 10 deletions core/api/src/servers/authorization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,23 +422,24 @@ authRouter.post("/email/login/cookie", async (req: Request, res: Response) => {

authRouter.post("/phone/captcha", async (req: Request, res: Response) => {
const result = await registerCaptchaGeetest()
if (result instanceof Error) return res.json({ error: "error creating challenge" })
if (result instanceof Error) {
return res.status(500).send({ error: "error creating challenge" })
}

const { success, gt, challenge, newCaptcha } = result

return {
return res.send({
result: {
id: gt,
challengeCode: challenge,
newCaptcha,
failbackMode: success === 0,
},
}
})
})

authRouter.post("/phone/code", async (req: Request, res: Response) => {
const ip = req.originalIp

const phoneRaw = req.body.phone
const challengeCodeRaw = req.body.challengeCode
const validationCodeRaw = req.body.validationCode
Expand All @@ -449,7 +450,7 @@ authRouter.post("/phone/code", async (req: Request, res: Response) => {
return res.status(400).send({ error: "missing inputs" })

const phone = checkedToPhoneNumber(phoneRaw)
if (phone instanceof Error) return res.status(400).send("invalid phone")
if (phone instanceof Error) return res.status(400).send({ error: "invalid phone" })

const geetestChallenge = challengeCodeRaw
const geetestValidate = validationCodeRaw
Expand All @@ -464,25 +465,24 @@ authRouter.post("/phone/code", async (req: Request, res: Response) => {
channel,
})

if (result instanceof Error) return res.status(400).json({ error: result })
if (result instanceof Error) return res.status(400).send({ error: result })

return res.json({
return res.send({
success: true,
})
})

authRouter.post("/phone/login", async (req: Request, res: Response) => {
const ip = req.originalIp

const codeRaw = req.body.code
const phoneRaw = req.body.phone
if (!codeRaw || !phoneRaw) {
return res.status(400).send({ error: "missing inputs" })
}
const code = validOneTimeAuthCodeValue(codeRaw)
if (code instanceof Error) return res.status(400).send("invalid code")
if (code instanceof Error) return res.status(400).send({ error: "invalid code" })
const phone = checkedToPhoneNumber(phoneRaw)
if (phone instanceof Error) return res.status(400).send("invalid phone")
if (phone instanceof Error) return res.status(400).send({ error: "invalid phone" })

const loginResp = await Authentication.loginWithPhoneToken({
phone,
Expand Down
Loading