Skip to content

Commit

Permalink
Gitlab enabled OWASP#9-Gitlab
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-winter committed Feb 6, 2024
1 parent d5e58c3 commit 4a32e45
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 6 deletions.
8 changes: 8 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,13 @@ GITHUB_ENTERPRISE_PORT=optional_if_enterprise_and_non_standard
GITHUB_ENTERPRISE_PROTOCOL=optional_if_enterprise_and_non_standard
GITHUB_SCOPE=public_repo



GITLAB_CLIENT_ID=01234567890123456789
GITLAB_CLIENT_SECRET=0123456789abcdef0123456789abcdef0123456
GITLAB_SCOPE=read_user read_repository write_repository profile read_api api
GITLAB_REDIRECT_URI=http://localhost:3000/api/oauth/return


NODE_ENV=development
SERVER_API_PROTOCOL=http
3 changes: 3 additions & 0 deletions td.server/src/config/env.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import EncryptionEnv from '../env/Encryption.js';
import env from '../env/Env.js';
import GithubEnv from '../env/Github.js';
import ThreatDragonEnv from '../env/ThreatDragon.js';
import GitlabEnv from "../env/Gitlab";

const tryLoadDotEnv = () => {
const github = new GithubEnv();
const gitlab = new GitlabEnv();
const bitbucket = new BitbucketEnv();
const encryption = new EncryptionEnv();
const threatDragon = new ThreatDragonEnv();
env.get().addProvider(github);
env.get().addProvider(gitlab);
env.get().addProvider(encryption);
env.get().addProvider(bitbucket);
env.get().addProvider(threatDragon);
Expand Down
9 changes: 5 additions & 4 deletions td.server/src/controllers/configcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ const logger = loggerHelper.get('controllers/configcontroller.js');
const config = (req, res) => responseWrapper.sendResponse(() => getConfig(), req, res, logger);

export const getConfig = () => ({
bitbucketEnabled: env.get().config.BITBUCKET_CLIENT_ID !== undefined && env.get().config.BITBUCKET_CLIENT_ID !== null,
githubEnabled: env.get().config.GITHUB_CLIENT_ID !== undefined && env.get().config.GITHUB_CLIENT_ID !== null,
localEnabled: true,
});
bitbucketEnabled: env.get().config.BITBUCKET_CLIENT_ID !== undefined && env.get().config.BITBUCKET_CLIENT_ID !== null,
githubEnabled: env.get().config.GITHUB_CLIENT_ID !== undefined && env.get().config.GITHUB_CLIENT_ID !== null,
gitlabEnabled: env.get().config.GITLAB_CLIENT_ID !== undefined && env.get().config.GITLAB_CLIENT_ID !== null,
localEnabled: true,
});

export default {
config
Expand Down
2 changes: 2 additions & 0 deletions td.server/src/providers/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import bitbucket from './bitbucket.js';
import github from './github.js';
import gitlab from "./gitlab";

/**
* An immutable object containing all
Expand All @@ -8,6 +9,7 @@ import github from './github.js';
*/
const all = Object.freeze({
github,
gitlab,
bitbucket
});

Expand Down
2 changes: 2 additions & 0 deletions td.server/src/repositories/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import bitbucketrepo from "./bitbucketrepo";
import githubrepo from "./githubrepo";
import gitlabrepo from "./gitlabrepo";

/**
* An immutable object containing all
Expand All @@ -8,6 +9,7 @@ import githubrepo from "./githubrepo";
*/
const all = Object.freeze({
githubrepo,
gitlabrepo,
bitbucketrepo,
});

Expand Down
4 changes: 4 additions & 0 deletions td.vue/src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const eng = {
displayName: 'GitHub',
loginWith: 'Login with'
},
gitlab: {
displayName: 'GitLab',
loginWith: 'Login with'
},
bitbucket: {
displayName: 'Bitbucket',
loginWith: 'Login with'
Expand Down
3 changes: 2 additions & 1 deletion td.vue/src/plugins/fontawesome-vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ import {
faDiagramProject
} from '@fortawesome/free-solid-svg-icons';

import {faBitbucket, faGithub, faVuejs} from '@fortawesome/free-brands-svg-icons';
import {faBitbucket, faGithub, faGitlab, faVuejs} from '@fortawesome/free-brands-svg-icons';

// Add icons to the library for use
library.add(
faSignOutAlt,
faQuestionCircle,
faGift,
faGithub,
faGitlab,
faBitbucket,
faVuejs,
faPlus,
Expand Down
26 changes: 26 additions & 0 deletions td.vue/src/service/provider/gitlab.provider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { providerTypes } from './providerTypes.js';

const providerType = providerTypes.git;

const getDashboardActions = () => ([
{
to: `/${providerType}/gitlab/repository`,
key: 'openExisting',
icon: 'gitlab',
iconPreface: 'fab'
},
{
to: `/${providerType}/gitlab/repository?action=create`,
key: 'createNew',
icon: 'plus'
},
{
to: '/demo/select',
key: 'readDemo',
icon: 'cloud-download-alt'
}
]);

export default {
getDashboardActions
};
8 changes: 8 additions & 0 deletions td.vue/src/service/provider/providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import localProvider from './local.provider.js';
import desktopProvider from './desktop.provider.js';
import { providerTypes } from './providerTypes.js';
import bitbucketProvider from '@/service/provider/bitbucket.provider';
import gitlabProvider from "@/service/provider/gitlab.provider";

const providers = {
desktop: {
Expand All @@ -19,6 +20,13 @@ const providers = {
type: providerTypes.git,
icon: ['fab', 'github']
},
gitlab: {
key: 'gitlab',
displayName: 'Gitlab',
provider: gitlabProvider,
type: providerTypes.git,
icon: ['fab', 'gitlab']
},
bitbucket: {
key: 'bitbucket',
displayName: 'Bitbucket',
Expand Down
1 change: 0 additions & 1 deletion td.vue/src/store/modules/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const actions = {
try {
console.log('FETCHING');
const response = await api.getAsync('/api/config',);
console.log('RETRIEVED ' + JSON.stringify(response.data));

commit(CONFIG_LOADED, { config: response.data });
} catch (error) {
Expand Down
3 changes: 3 additions & 0 deletions td.vue/src/views/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ export default {
if (state.config.config.bitbucketEnabled) {
providers.bitbucket = allProviders.bitbucket;
}
if (state.config.config.gitlabEnabled) {
providers.gitlab = allProviders.gitlab;
}
if (state.config.config.localEnabled) {
providers.local = allProviders.local;
}
Expand Down

0 comments on commit 4a32e45

Please sign in to comment.