random42 / passport-spid

Passport strategy for SPID (italian citizens) authentication
MIT License
12 stars 5 forks source link

Error: Incorrect request format when trying to call /login #2

Closed ymhmd closed 1 year ago

ymhmd commented 1 year ago

Hi,

I've just noticed one error happened to me while using example.ts. I am not sure the root cause of this issue. Could you please help me to understand the issue?

Steps

  1. Update const idp = 'https://posteid.poste.it'
  2. Update privateKey and spCert
  3. Update IPACode to be PA:IT-c_h501
  4. Run example yarn dev
  5. Open http://localhost:4000/login in the browser
  6. Browser navigates to https://posteid.poste.it/jod-fs/ssoservicepost

Error Error message messaggio di avvisoErrore: Formato richiesta non corretto - Contattare il gestore del servizio appears

Screenshot

Screenshot 2023-05-09 at 23 38 58
Gioppix commented 1 year ago

have you registered the metadata? this is how you would do it in the test env: https://demo.spid.gov.it/validator#/metadata-sp-download

ymhmd commented 1 year ago

@Gioppix, thanks a lot for the answer. It worked on test/demo env after I registered the metadata.

One more question, how can we register the metadata with real IdPs (Poste, Sielte ...etc) ? Maybe some docs can help 🙏

Gioppix commented 1 year ago

@ymhmd this is the list of IdPs - https://registry.spid.gov.it/identity-providers . I think you need to find the registration page for each one. May I ask how you updated the privateKey and spCert? I can't get this to work on the test env.

Thanks!

ymhmd commented 1 year ago

@Gioppix, To make it work, I did the following steps:

  1. Create and validate certificate and private key as per https://github.com/italia/spid-compliant-certificates-python. This step should generate crt.pem, csr.pem and key.pem
  2. Update const privateKey = (await fs.readFile("/path/key.pem")).toString();
  3. Update const privateKey = (await fs.readFile("/path/crt.pem")).toString();

I hope this will make it work for you. If not, please let me know

Gioppix commented 1 year ago

@ymhmd what command have you used to start? have you cloned the repo or just the example? thanks

ymhmd commented 1 year ago

@Gioppix

Gioppix commented 1 year ago

@ymhmd Sorry I was unclear, I meant the command to start the whole project on localhost

ymhmd commented 1 year ago

@Gioppix To run it locally:

  1. Update dev script in package.json to ts-node-dev --respawn --inspect=0.0.0.0:9229 -- examples/main.ts
  2. Run yarn dev
Gioppix commented 1 year ago

@ymhmd thanks a lot!