Skip to content

Commit

Permalink
Added router to rediect github auth (rancher#9262)
Browse files Browse the repository at this point in the history
* Added router to rediect github auth

* Added env variables for client id

* Fixed broken server Middleware

* Removed e2e changes

* Fixed lint

* Removed code for test

* Clean code
  • Loading branch information
bisht-richa committed Jul 14, 2023
1 parent e183948 commit 141d277
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
1 change: 1 addition & 0 deletions shell/edit/auth/github.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export default {
<RadioGroup
v-model="targetType"
name="targetType"
data-testid="authConfig-gitHub"
:options="['public','private']"
:mode="mode"
:labels="[ t(`authConfig.${NAME}.target.public`), t(`authConfig.${NAME}.target.private`)]"
Expand Down
16 changes: 4 additions & 12 deletions shell/server/server-middleware.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import { URL } from 'url';

export default function(req, res, next) {
const parsed = new URL(req.url, 'https://localhost');

if ( parsed.searchParams.has('spa') ) {
res.spa = true;
console.log('SPA mode enabled'); // eslint-disable-line no-console
}

module.exports = function(req, res, next) {
// We do this redirect so that /verify-auth can work with both standalone and
// while dashboard is nested under ember.
if (req.url.includes('/verify-auth') || req.url.includes('/verify-auth-azure')) {
res.writeHead(301, { Location: req.url.replace(/verify-auth(-azure)?/, 'auth/verify') });
res.end();
}

return;
}
next();
}
};
5 changes: 3 additions & 2 deletions shell/vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const serveStatic = require('serve-static');
const webpack = require('webpack');
const { generateDynamicTypeImport } = require('./pkg/auto-import');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const serverMiddlewares = require('./server/server-middleware.js');

// Suppress info level logging messages from http-proxy-middleware
// This hides all of the "[HPM Proxy created] ..." messages
Expand Down Expand Up @@ -218,8 +219,6 @@ module.exports = function(dir, _appConfig) {
serverMiddleware.push({ path: `/pkg/`, handler: serveStatic(`${ dir }/dist-pkg/`) });
// Endpoint to download and unpack a tgz from the local verdaccio rgistry (dev)
serverMiddleware.push(path.resolve(dir, SHELL, 'server', 'verdaccio-middleware'));
// Add the standard dashboard server middleware after the middleware added to serve up UI packages
serverMiddleware.push(path.resolve(dir, SHELL, 'server', 'server-middleware'));

// ===============================================================================================
// Dashboard nuxt configuration
Expand Down Expand Up @@ -319,6 +318,8 @@ module.exports = function(dir, _appConfig) {
process.exit(1);
});

app.use(serverMiddlewares);

Object.keys(proxy).forEach((p) => {
const px = createProxyMiddleware({
...proxy[p],
Expand Down

0 comments on commit 141d277

Please sign in to comment.