tigaron / nextjs-samlify

Next.js prototype with implementation of keycloak authorization endpoint using samlify.js
https://nextjs-samlify.vercel.app/
2 stars 0 forks source link

misunderstanding in enviroment #3

Open nvh1307 opened 1 year ago

nvh1307 commented 1 year ago

Sorry, I have clone your repository to learn because I also have to implement keycloak into NextJS (using SAML protocol). I can run your project, but when I click button login, it redirected me to keycloak but it's the page not found. So I think I missing a step?. I think the problem in enviroment in this code below

export const idp = samlify.IdentityProvider({
    metadata: Buffer.from(process.env.IDP_METADATA as string, 'base64'),
});

export const sp = samlify.ServiceProvider({
    entityID: process.env.SP_IDENTITY,
    authnRequestsSigned: true,
    wantMessageSigned: true,
    wantLogoutResponseSigned: true,
    wantLogoutRequestSigned: true,
    wantAssertionsSigned: true,
    signingCert: Buffer.from(process.env.SIGN_B64_CERTIFICATE as string, 'base64'),
    privateKey: Buffer.from(process.env.SIGN_B64_PRIVATE_KEY as string, 'base64'),
    privateKeyPass: process.env.SP_PRIVATE_KEY_PASS,
    assertionConsumerService: [
        {
            Binding: samlify.Constants.namespace.binding.post,
            Location: process.env.SSO_CALLBACK_URL as string,
        },
    ],
});

I don't know how to get base64 certificate and private key, private key pass ( sorry but all of this enviroment above =))) I researched but it have many source but none of them give me a solution, that's poor ) So could you tell me where you get private key, certificate also metadata in keycloak. By the way, I was struggling to find a good tutorial on this, but your approach is actually well thought out. It's very nice and very helpful