mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
moved oauth controller endpoints to auth
This commit is contained in:
@@ -267,3 +267,7 @@ export const getNewToken = async (req: Request, res: Response) => {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const handleAuthProviderCallback = (req: Request, res: Response) => {
|
||||
res.redirect(`/login/provider/success?token=${encodeURIComponent(req.providerAuthToken)}`);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import * as integrationController from './integrationController';
|
||||
import * as keyController from './keyController';
|
||||
import * as membershipController from './membershipController';
|
||||
import * as membershipOrgController from './membershipOrgController';
|
||||
import * as oauthController from './oauthController';
|
||||
import * as organizationController from './organizationController';
|
||||
import * as passwordController from './passwordController';
|
||||
import * as secretController from './secretController';
|
||||
@@ -24,7 +23,6 @@ export {
|
||||
keyController,
|
||||
membershipController,
|
||||
membershipOrgController,
|
||||
oauthController,
|
||||
organizationController,
|
||||
passwordController,
|
||||
secretController,
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import { Request, Response } from 'express';
|
||||
|
||||
export const handleAuthProviderCallback = (req: Request, res: Response) => {
|
||||
res.redirect(`/login/provider/success?token=${encodeURIComponent(req.providerAuthToken)}`);
|
||||
}
|
||||
@@ -39,7 +39,6 @@ import {
|
||||
membership as v1MembershipRouter,
|
||||
key as v1KeyRouter,
|
||||
inviteOrg as v1InviteOrgRouter,
|
||||
oauth as v1OAuth,
|
||||
user as v1UserRouter,
|
||||
userAction as v1UserActionRouter,
|
||||
secret as v1SecretRouter,
|
||||
@@ -135,7 +134,6 @@ const main = async () => {
|
||||
// v1 routes (default)
|
||||
app.use("/api/v1/signup", v1SignupRouter);
|
||||
app.use("/api/v1/auth", v1AuthRouter);
|
||||
app.use("/api/v1/oauth", v1OAuth);
|
||||
app.use("/api/v1/bot", v1BotRouter);
|
||||
app.use("/api/v1/user", v1UserRouter);
|
||||
app.use("/api/v1/user-action", v1UserActionRouter);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import express from 'express';
|
||||
const router = express.Router();
|
||||
import { body } from 'express-validator';
|
||||
import passport from 'passport';
|
||||
import { requireAuth, validateRequest } from '../../middleware';
|
||||
import { authController } from '../../controllers/v1';
|
||||
import { authLimiter } from '../../helpers/rateLimiter';
|
||||
@@ -44,4 +45,20 @@ router.post(
|
||||
);
|
||||
|
||||
|
||||
|
||||
router.get(
|
||||
'/redirect/google',
|
||||
authLimiter,
|
||||
passport.authenticate('google', {
|
||||
scope: ['profile', 'email'],
|
||||
session: false,
|
||||
}),
|
||||
)
|
||||
|
||||
router.get(
|
||||
'/callback/google',
|
||||
passport.authenticate('google', { failureRedirect: '/login/provider/error', session: false }),
|
||||
authController.handleAuthProviderCallback,
|
||||
)
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -16,7 +16,6 @@ import stripe from './stripe';
|
||||
import integration from './integration';
|
||||
import integrationAuth from './integrationAuth';
|
||||
import secretsFolder from './secretsFolder';
|
||||
import oauth from './oauth';
|
||||
|
||||
export {
|
||||
signup,
|
||||
@@ -30,7 +29,6 @@ export {
|
||||
membership,
|
||||
key,
|
||||
inviteOrg,
|
||||
oauth,
|
||||
secret,
|
||||
serviceToken,
|
||||
password,
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import express from 'express';
|
||||
const router = express.Router();
|
||||
import passport from 'passport';
|
||||
import { oauthController } from '../../controllers/v1';
|
||||
import { authLimiter } from '../../helpers/rateLimiter';
|
||||
|
||||
router.get(
|
||||
'/redirect/google',
|
||||
authLimiter,
|
||||
passport.authenticate('google', {
|
||||
scope: ['profile', 'email'],
|
||||
session: false,
|
||||
}),
|
||||
)
|
||||
|
||||
router.get(
|
||||
'/callback/google',
|
||||
passport.authenticate('google', { failureRedirect: '/login/provider/error', session: false }),
|
||||
oauthController.handleAuthProviderCallback,
|
||||
)
|
||||
|
||||
export default router;
|
||||
@@ -68,7 +68,7 @@ const initializePassport = async () => {
|
||||
passReqToCallback: true,
|
||||
clientID: googleClientId,
|
||||
clientSecret: googleClientSecret,
|
||||
callbackURL: '/api/v1/oauth/callback/google',
|
||||
callbackURL: '/api/v1/auth/callback/google',
|
||||
scope: ['profile', ' email'],
|
||||
}, async (
|
||||
req: express.Request,
|
||||
|
||||
@@ -6,7 +6,7 @@ To enable Google Auth for your Infisical project, you first need to set up a Goo
|
||||
Follow Google's Setting up OAuth 2.0 documentation [here](https://support.google.com/googleapi/answer/6158849). After the setup, copy the Client ID and Client secret. You will need them below.
|
||||
|
||||
## Configure Redirect URI
|
||||
Add the following URI to the Authorized redirect URIs section in the OAuth Client credentials page - `BASE_URL/api/v1/oauth/callback/google`. Replace BASE_URL with the URL of your hosted Infisical instance.
|
||||
Add the following URI to the Authorized redirect URIs section in the OAuth Client credentials page - `BASE_URL/api/v1/auth/callback/google`. Replace BASE_URL with the URL of your hosted Infisical instance.
|
||||

|
||||
|
||||
## General Configuration
|
||||
|
||||
@@ -20,7 +20,7 @@ export default function InitialLoginStep({
|
||||
colorSchema="primary"
|
||||
variant="solid"
|
||||
onClick={() => {
|
||||
window.open('/api/v1/oauth/redirect/google')
|
||||
window.open('/api/v1/auth/redirect/google')
|
||||
}}
|
||||
leftIcon={<FontAwesomeIcon icon={faGoogle} className="mr-1" />}
|
||||
className="h-14 w-full mx-0"
|
||||
|
||||
@@ -19,7 +19,7 @@ export default function InitialSignupStep({
|
||||
colorSchema="primary"
|
||||
variant="solid"
|
||||
onClick={() => {
|
||||
window.open('/api/v1/oauth/redirect/google')
|
||||
window.open('/api/v1/auth/redirect/google')
|
||||
}}
|
||||
leftIcon={<FontAwesomeIcon icon={faGoogle} className="mr-1" />}
|
||||
className="h-14 w-full mx-0"
|
||||
|
||||
Reference in New Issue
Block a user