44
55namespace SimpleSAML \Module \oidc \Controllers \VerifiableCredentials ;
66
7+ use Base64Url \Base64Url ;
78use League \OAuth2 \Server \ResourceServer ;
89use SimpleSAML \Module \oidc \Bridges \PsrHttpBridge ;
910use SimpleSAML \Module \oidc \ModuleConfig ;
@@ -63,15 +64,29 @@ public function credential(Request $request): Response
6364
6465 // TODO mivanci validate requested credential identifier
6566
66- $ jwk = $ this ->jwk ->jwkDecoratorFactory ()->fromPkcs1Or8KeyFile (
67+ $ signingKey = $ this ->jwk ->jwkDecoratorFactory ()->fromPkcs1Or8KeyFile (
6768 $ this ->moduleConfig ->getProtocolPrivateKeyPath (),
6869 null ,
6970 );
7071
72+ $ publicKey = $ this ->jwk ->jwkDecoratorFactory ()->fromPkcs1Or8KeyFile (
73+ $ this ->moduleConfig ->getProtocolCertPath (),
74+ null ,
75+ [
76+ //ClaimsEnum::Use->value => 'sig',
77+ ]
78+ );
79+
80+ $ base64PublicKey = json_encode ($ publicKey ->jwk ()->all (), JSON_UNESCAPED_SLASHES );
81+ $ base64PublicKey = Base64Url::encode ($ base64PublicKey );
82+
83+ $ issuerDid = 'did:jwk: ' . $ base64PublicKey ;
84+
85+
7186 $ issuedAt = new \DateTimeImmutable ();
7287
7388 $ verifiableCredential = $ this ->verifiableCredentials ->jwtVcJsonFactory ()->fromData (
74- $ jwk ,
89+ $ signingKey ,
7590 SignatureAlgorithmEnum::from ($ this ->moduleConfig ->getProtocolSigner ()->algorithmId ()),
7691 [
7792 ClaimsEnum::Vc->value => [
@@ -82,7 +97,9 @@ public function credential(Request $request): Response
8297 CredentialTypesEnum::VerifiableCredential->value ,
8398 'ResearchAndScholarshipCredentialJwtVcJson ' ,
8499 ],
85- ClaimsEnum::Issuer->value => $ this ->moduleConfig ->getIssuer (),
100+ // ClaimsEnum::Issuer->value => $this->moduleConfig->getIssuer(),
101+ // ClaimsEnum::Issuer->value => $issuerDid,
102+ ClaimsEnum::Issuer->value => 'https://idp.mivanci.incubator.hexaa.eu/ssp/module.php/oidc/jwks ' ,
86103 ClaimsEnum::Issuance_Date->value => $ issuedAt ->format (\DateTimeInterface::RFC3339 ),
87104 ClaimsEnum::Id->value => $ this ->moduleConfig ->getIssuer () . '/vc/1234567890 ' ,
88105 ClaimsEnum::Credential_Subject->value => [
@@ -96,16 +113,16 @@ public function credential(Request $request): Response
96113 'eduPersonScopedAffiliation ' =>
'[email protected] ' ,
97114 ],
98115 ],
99- ClaimsEnum::Iss->value => $ this ->moduleConfig ->getIssuer (),
116+ // ClaimsEnum::Iss->value => $this->moduleConfig->getIssuer(),
117+ // ClaimsEnum::Iss->value => $issuerDid,
118+ ClaimsEnum::Iss->value => 'https://idp.mivanci.incubator.hexaa.eu/ssp/module.php/oidc/jwks ' ,
100119 ClaimsEnum::Iat->value => $ issuedAt ->getTimestamp (),
101120 ClaimsEnum::Nbf->value => $ issuedAt ->getTimestamp (),
102121 ClaimsEnum::Sub->value => $ this ->moduleConfig ->getIssuer () . '/sub/1234567890 ' ,
103122 ClaimsEnum::Jti->value => $ this ->moduleConfig ->getIssuer () . '/vc/1234567890 ' ,
104123 ],
105124 [
106- ClaimsEnum::Kid->value => FingerprintGenerator::forFile (
107- $ this ->moduleConfig ->getProtocolCertPath (),
108- ),
125+ ClaimsEnum::Kid->value => $ issuerDid . '#0 ' ,
109126 ],
110127 );
111128
0 commit comments