mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
fix(core): Return SAML service provider urls with config (#5759)
return sp urls with config
This commit is contained in:
parent
d30b892395
commit
ac18c0b9eb
|
@ -16,6 +16,7 @@ import type { PostBindingContext } from 'samlify/types/src/entity';
|
||||||
import { isSamlLicensedAndEnabled } from '../samlHelpers';
|
import { isSamlLicensedAndEnabled } from '../samlHelpers';
|
||||||
import type { SamlLoginBinding } from '../types';
|
import type { SamlLoginBinding } from '../types';
|
||||||
import { AuthenticatedRequest } from '@/requests';
|
import { AuthenticatedRequest } from '@/requests';
|
||||||
|
import { getServiceProviderEntityId, getServiceProviderReturnUrl } from '../serviceProvider.ee';
|
||||||
|
|
||||||
@RestController('/sso/saml')
|
@RestController('/sso/saml')
|
||||||
export class SamlController {
|
export class SamlController {
|
||||||
|
@ -35,7 +36,11 @@ export class SamlController {
|
||||||
@Get(SamlUrls.config, { middlewares: [samlLicensedOwnerMiddleware] })
|
@Get(SamlUrls.config, { middlewares: [samlLicensedOwnerMiddleware] })
|
||||||
async configGet(req: AuthenticatedRequest, res: express.Response) {
|
async configGet(req: AuthenticatedRequest, res: express.Response) {
|
||||||
const prefs = this.samlService.samlPreferences;
|
const prefs = this.samlService.samlPreferences;
|
||||||
return res.send(prefs);
|
return res.send({
|
||||||
|
...prefs,
|
||||||
|
entityID: getServiceProviderEntityId(),
|
||||||
|
returnUrl: getServiceProviderReturnUrl(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,11 +7,19 @@ import type { SamlPreferences } from './types/samlPreferences';
|
||||||
|
|
||||||
let serviceProviderInstance: ServiceProviderInstance | undefined;
|
let serviceProviderInstance: ServiceProviderInstance | undefined;
|
||||||
|
|
||||||
|
export function getServiceProviderEntityId(): string {
|
||||||
|
return getInstanceBaseUrl() + SamlUrls.restMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getServiceProviderReturnUrl(): string {
|
||||||
|
return getInstanceBaseUrl() + SamlUrls.restAcs;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO:SAML: make these configurable for the end user
|
// TODO:SAML: make these configurable for the end user
|
||||||
export function getServiceProviderInstance(prefs: SamlPreferences): ServiceProviderInstance {
|
export function getServiceProviderInstance(prefs: SamlPreferences): ServiceProviderInstance {
|
||||||
if (serviceProviderInstance === undefined) {
|
if (serviceProviderInstance === undefined) {
|
||||||
serviceProviderInstance = ServiceProvider({
|
serviceProviderInstance = ServiceProvider({
|
||||||
entityID: getInstanceBaseUrl() + SamlUrls.restMetadata,
|
entityID: getServiceProviderEntityId(),
|
||||||
authnRequestsSigned: prefs.authnRequestsSigned,
|
authnRequestsSigned: prefs.authnRequestsSigned,
|
||||||
wantAssertionsSigned: prefs.wantAssertionsSigned,
|
wantAssertionsSigned: prefs.wantAssertionsSigned,
|
||||||
wantMessageSigned: prefs.wantMessageSigned,
|
wantMessageSigned: prefs.wantMessageSigned,
|
||||||
|
@ -21,12 +29,12 @@ export function getServiceProviderInstance(prefs: SamlPreferences): ServiceProvi
|
||||||
{
|
{
|
||||||
isDefault: prefs.acsBinding === 'post',
|
isDefault: prefs.acsBinding === 'post',
|
||||||
Binding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
|
Binding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
|
||||||
Location: getInstanceBaseUrl() + SamlUrls.restAcs,
|
Location: getServiceProviderReturnUrl(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
isDefault: prefs.acsBinding === 'redirect',
|
isDefault: prefs.acsBinding === 'redirect',
|
||||||
Binding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-REDIRECT',
|
Binding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-REDIRECT',
|
||||||
Location: getInstanceBaseUrl() + SamlUrls.restAcs,
|
Location: getServiceProviderReturnUrl(),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue