move sso-init-form to a handlebars view as well

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2024-10-22 13:32:47 +02:00
parent 85958e0967
commit 0e43286435
No known key found for this signature in database
3 changed files with 17 additions and 17 deletions

View file

@ -26,7 +26,6 @@ import {
} from '../service-provider.ee';
import type { SamlLoginBinding } from '../types';
import { SamlConfiguration } from '../types/requests';
import { getInitSSOFormView } from '../views/init-sso-post';
@RestController('/sso/saml')
export class SamlController {
@ -207,7 +206,7 @@ export class SamlController {
if (result?.binding === 'redirect') {
return result.context.context;
} else if (result?.binding === 'post') {
return res.send(getInitSSOFormView(result.context as PostBindingContext));
return res.render('sso/saml-init-form', result.context);
} else {
throw new AuthError('SAML redirect failed, please check your SAML configuration.');
}

View file

@ -1,15 +0,0 @@
import type { PostBindingContext } from 'samlify/types/src/entity';
export function getInitSSOFormView(context: PostBindingContext): string {
return `
<form id="saml-form" method="post" action="${context.entityEndpoint}" autocomplete="off">
<input type="hidden" name="${context.type}" value="${context.context}" />
${context.relayState ? '<input type="hidden" name="RelayState" value="{{relayState}}" />' : ''}
</form>
<script type="text/javascript">
// Automatic form submission
(function(){
document.forms[0].submit();
})();
</script>`;
}

View file

@ -0,0 +1,16 @@
<html>
<body>
<form id="saml-form" method="post" action="{{entityEndpoint}}" autocomplete="off">
<input type="hidden" name="{{type}}" value="{{context}}" />
{{#if relayState}}
<input type="hidden" name="RelayState" value="{{relayState}}" />
{{/if}}
</form>
<script type="text/javascript">
// Automatic form submission
(function(){
document.forms[0].submit();
})();
</script>
</body>
</html>