Merge pull request #23265 from swnia/master
Fix for atlassian OAuth flow
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-auth-backend-module-atlassian-provider': patch
|
||||
---
|
||||
|
||||
Addressed OAuth flow issue in Atlassian auth module
|
||||
@@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Strategy as AtlassianStrategy } from 'passport-atlassian-oauth2';
|
||||
import {
|
||||
createOAuthAuthenticator,
|
||||
PassportOAuthAuthenticatorHelper,
|
||||
PassportOAuthDoneCallback,
|
||||
PassportProfile,
|
||||
} from '@backstage/plugin-auth-node';
|
||||
import { Strategy as AtlassianStrategy } from 'passport-atlassian-oauth2';
|
||||
|
||||
/** @public */
|
||||
export const atlassianAuthenticator = createOAuthAuthenticator({
|
||||
@@ -29,8 +29,7 @@ export const atlassianAuthenticator = createOAuthAuthenticator({
|
||||
initialize({ callbackUrl, config }) {
|
||||
const clientId = config.getString('clientId');
|
||||
const clientSecret = config.getString('clientSecret');
|
||||
const baseUrl =
|
||||
config.getOptionalString('audience') || 'https://atlassian.com';
|
||||
const baseUrl = 'https://auth.atlassian.com';
|
||||
|
||||
return PassportOAuthAuthenticatorHelper.from(
|
||||
new AtlassianStrategy(
|
||||
@@ -39,7 +38,7 @@ export const atlassianAuthenticator = createOAuthAuthenticator({
|
||||
clientSecret: clientSecret,
|
||||
callbackURL: callbackUrl,
|
||||
baseURL: baseUrl,
|
||||
authorizationURL: `${baseUrl}/oauth/authorize`,
|
||||
authorizationURL: `${baseUrl}/authorize`,
|
||||
tokenURL: `${baseUrl}/oauth/token`,
|
||||
profileURL: `${baseUrl}/api/v4/user`,
|
||||
},
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
|
||||
import { mockServices, startTestBackend } from '@backstage/backend-test-utils';
|
||||
import { authModuleAtlassianProvider } from './module';
|
||||
import request from 'supertest';
|
||||
import { decodeOAuthState } from '@backstage/plugin-auth-node';
|
||||
import request from 'supertest';
|
||||
import { authModuleAtlassianProvider } from './module';
|
||||
|
||||
describe('authModuleAtlassianProvider', () => {
|
||||
it('should start', async () => {
|
||||
@@ -60,8 +60,8 @@ describe('authModuleAtlassianProvider', () => {
|
||||
expect(nonceCookie).toBeDefined();
|
||||
|
||||
const startUrl = new URL(res.get('location'));
|
||||
expect(startUrl.origin).toBe('https://atlassian.com');
|
||||
expect(startUrl.pathname).toBe('/oauth/authorize');
|
||||
expect(startUrl.origin).toBe('https://auth.atlassian.com');
|
||||
expect(startUrl.pathname).toBe('/authorize');
|
||||
expect(Object.fromEntries(startUrl.searchParams)).toEqual({
|
||||
response_type: 'code',
|
||||
client_id: 'my-client-id',
|
||||
|
||||
@@ -14,9 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AuthHandler } from '../types';
|
||||
import { OAuthResult } from '../../lib/oauth';
|
||||
import { createAuthProviderIntegration } from '../createAuthProviderIntegration';
|
||||
import { atlassianAuthenticator } from '@backstage/plugin-auth-backend-module-atlassian-provider';
|
||||
import {
|
||||
SignInResolver,
|
||||
createOAuthProviderFactory,
|
||||
@@ -25,7 +23,9 @@ import {
|
||||
adaptLegacyOAuthHandler,
|
||||
adaptLegacyOAuthSignInResolver,
|
||||
} from '../../lib/legacy';
|
||||
import { atlassianAuthenticator } from '@backstage/plugin-auth-backend-module-atlassian-provider';
|
||||
import { OAuthResult } from '../../lib/oauth';
|
||||
import { createAuthProviderIntegration } from '../createAuthProviderIntegration';
|
||||
import { AuthHandler } from '../types';
|
||||
|
||||
/**
|
||||
* Auth provider integration for Atlassian auth
|
||||
|
||||
Reference in New Issue
Block a user