|
|
|
@ -32,9 +32,9 @@ import { standardRequest } from "../config/request";
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
|
|
|
const GoogleStrategy = require("passport-google-oauth20").Strategy;
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
|
|
|
const GitHubStrategy = require("passport-github").Strategy;
|
|
|
|
|
const GitHubStrategy = require("passport-oauth2").Strategy;
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
|
|
|
const GitLabStrategy = require("passport-gitlab2").Strategy;
|
|
|
|
|
const GitLabStrategy = require("passport-oauth2").Strategy;
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
|
|
|
const { MultiSamlStrategy } = require("@node-saml/passport-saml");
|
|
|
|
|
|
|
|
|
@ -158,10 +158,12 @@ const initializePassport = async () => {
|
|
|
|
|
|
|
|
|
|
if (clientIdGitHubLogin && clientSecretGitHubLogin) {
|
|
|
|
|
passport.use(new GitHubStrategy({
|
|
|
|
|
passReqToCallback: true,
|
|
|
|
|
authorizationURL: 'https://git.cereg.com/login/oauth/authorize',
|
|
|
|
|
tokenURL: 'https://git.cereg.com/login/oauth/access_token',
|
|
|
|
|
clientID: clientIdGitHubLogin,
|
|
|
|
|
clientSecret: clientSecretGitHubLogin,
|
|
|
|
|
callbackURL: "/api/v1/sso/github",
|
|
|
|
|
accessType: 'offline',
|
|
|
|
|
scope: ["user:email"]
|
|
|
|
|
},
|
|
|
|
|
async (req : express.Request, accessToken : any, refreshToken : any, profile : any, done : any) => {
|
|
|
|
@ -173,7 +175,7 @@ const initializePassport = async () => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { data }: { data: GitHubEmail[] } = await standardRequest.get(
|
|
|
|
|
`${INTEGRATION_GITHUB_API_URL}/user/emails`,
|
|
|
|
|
`https://git.cereg.com/api/v1/user/emails`,
|
|
|
|
|
{
|
|
|
|
|
headers: {
|
|
|
|
|
Authorization: `Bearer ${accessToken}`
|
|
|
|
@ -231,9 +233,12 @@ const initializePassport = async () => {
|
|
|
|
|
if (urlGitLab && clientIdGitLabLogin && clientSecretGitLabLogin) {
|
|
|
|
|
passport.use(new GitLabStrategy({
|
|
|
|
|
passReqToCallback: true,
|
|
|
|
|
authorizationURL: 'https://git.cereg.com/login/oauth/authorize',
|
|
|
|
|
tokenURL: 'https://git.cereg.com/login/oauth/access_token',
|
|
|
|
|
clientID: clientIdGitLabLogin,
|
|
|
|
|
clientSecret: clientSecretGitLabLogin,
|
|
|
|
|
callbackURL: "/api/v1/sso/gitlab",
|
|
|
|
|
accessType: 'offline',
|
|
|
|
|
baseURL: urlGitLab
|
|
|
|
|
},
|
|
|
|
|
async (req : express.Request, accessToken : any, refreshToken : any, profile : any, done : any) => {
|
|
|
|
@ -252,6 +257,10 @@ const initializePassport = async () => {
|
|
|
|
|
}).save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(">>>>>>accessToken",accessToken);
|
|
|
|
|
console.log(">>>>>>refreshToken",refreshToken);
|
|
|
|
|
console.log(">>>>>>profile",profile);
|
|
|
|
|
|
|
|
|
|
let isLinkingRequired = false;
|
|
|
|
|
if (!user.authMethods.includes(AuthMethod.GITLAB)) {
|
|
|
|
|
isLinkingRequired = true;
|
|
|
|
|