Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-3503] Add *_jwt token endpoint auth methods #376

Merged
merged 13 commits into from
Jul 20, 2022
5 changes: 1 addition & 4 deletions end-to-end/fixture/oidc-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ const config = {
keys: [
{
kty: 'RSA',
n: '20yjkC7WmelNZN33GAjFaMvKaInjTz3G49eUwizpuAW6Me9_1FMSAK6nM1XI7VBpy_o5-ffNleRIgcvFudZuSvZiAYBBS2HS5F5PjluVExPwHTD7X7CIwqJxq67N5sTeFkh_ZL4fWK-Na4VlFEsKhcjDrLGxhPCuOgr9FmL0u0Vx_TM3Mk3DEhaf-tMlFx-K3R2GRJRe1wnYhOt1sXm8SNUM2uMZI05W6eRFn1gUAdTLNdCTvDY67ZAl6wyOewYo-WGpzwFYXLXDvc-f8vYucRM3Hq_GSzvFQ4l0nRLLj_33vlCg8mB1CEw_LudadzticAir3Ux3bnpno9yndUZR6w',
e: 'AQAB',
use: 'sig',
kid: 'cZNBq0YuRtJ2W9K2xSKZunnLayHcARrjcKtvbkELbdY',
alg: 'RS256',
n: 'wJ0FAxJvhTqQGORKMdYInzfjduWHmjikWPv4t-gze-NPgCawwsmOC5N5pgb2qPK_3hdvLAucm36kJyq1C9XDdmA6va51qDHWsAwOd0ob5Tm1xosiULr83KiFhGPCBsgWEPvO3vkdqEwTOq0_p55TfJFfnP5IrwrrUPPwCfDXlGc5xiV-ah4JcqlTdZTk_CfIO7zdhAJUBORam5dDoPzZ035f8GOw6k1ktcX2QxquO3zVcQ4ZOeSwve9ox2ZwNTXOassurfR8jC_E8LcytY083UJ0DdRUJ-8NKjnH_RczfKYmd8nyvjAsD4HBMu97xBat1vP975oHsVA5a9rE-j0lQw',
},
],
},
Expand Down
55 changes: 28 additions & 27 deletions examples/private-key.pem
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAwJ0FAxJvhTqQGORKMdYInzfjduWHmjikWPv4t+gze+NPgCaw
wsmOC5N5pgb2qPK/3hdvLAucm36kJyq1C9XDdmA6va51qDHWsAwOd0ob5Tm1xosi
ULr83KiFhGPCBsgWEPvO3vkdqEwTOq0/p55TfJFfnP5IrwrrUPPwCfDXlGc5xiV+
ah4JcqlTdZTk/CfIO7zdhAJUBORam5dDoPzZ035f8GOw6k1ktcX2QxquO3zVcQ4Z
OeSwve9ox2ZwNTXOassurfR8jC/E8LcytY083UJ0DdRUJ+8NKjnH/RczfKYmd8ny
vjAsD4HBMu97xBat1vP975oHsVA5a9rE+j0lQwIDAQABAoIBAAtObEfk4iT47hJ3
/B72yGTIPBLzoEUeRA9xIwVwnO0Nx9Hm84NLn4nwaziiugHq1fZse7sjJ1s9UNd3
u07pimK9fVU7E27/FfIZkxPPhtmqzI/OBQKmJ0ewoL3HuVD6l8kBbwBJsUL6zDoq
h00IjzAFvI4ToyKbSnrjBtkeiRkN6BVN+tphvOWdwKTjvNxWvNMVIe/1mx92pWO8
n5s2K6GqsO70Z0fD+KeFKypl17h6jMhLAA4cdEfKJE005KBoazdkiCxtNqfi4VJJ
6Abo/u8TLmzyk/K5KG/bfh035gX4/1sV5ndU6qJQkH0VFSpsjM26QH5Fzoi4nkzT
8PcSrwkCgYEA34YEDR3P4qFp/bXOds06zcpQWfNl1o+/XXvSjO89J4HxIrgzB6L7
1jO678RK9cBJ3btf/tUrd2egwkdg6Z2ZKHd9u6NJZH0Vj/e2PkGbG0FTcDvFggft
O0+7gJZNT/s+Y1N9YyKOma4LqhmY92JwPelJ7/YBJTRsM4Ni6GZtK7cCgYEA3JlM
FnCIfk0Li5uun7Ad8d7k05zi0rKUy3St7quCJwzJ9IJMmDtS3BExpIC9nMbo4qAR
O4aPrHHDKk2iQEzg4dqQfUrb3cI08cAoqVXdpU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NPwePfsT/2KqrbnftQnAKNnhsgcYGo8NAvntX4FokOAEdunyYmm85mLp
BGKYgVXJqnm6+TJyCRac1ro3noG898P/LZ8MOBoaYQtWeWRpDc46jPrA0FqUJy+i
ca/T0LLtgmbMmxSv/MmzIg==
-----END PRIVATE KEY-----
21 changes: 18 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
UserinfoResponse,
} from 'openid-client';
import { Request, Response, RequestHandler } from 'express';
import { KeyInput } from 'jose';
import { JSONWebKey, KeyInput } from 'jose';
import { KeyObject } from 'crypto';
adamjmcgrath marked this conversation as resolved.
Show resolved Hide resolved

/**
* Session object
Expand Down Expand Up @@ -492,13 +493,27 @@ interface ConfigParams {
* ...
* clientAssertionSigningKey: {
* kty: 'RSA',
* n: 'u2fhZbXdBdp3_p5bVfq15LaP4iuiV9cMLYLbCPfXJEQSDyhatRmEvNLAy5twwY1GG5jKgfKa4jYIrfLVVdT252uyBhe97Lx9uB2Y8NnzEmdYVpXlnTGLo1Ts-QwLISBiDgjltoVT3p4XkEoSODWQq-4JwLgmbP1pV64IVWoyaoVXmy-_oRHVSyD57wtRBBObXHGi1xeBzSiyt0YFDxkfFcuLUSplQQbZNtjUdmH8K6zrLRUryQslUmz2XeiR6Oe6SJ_GcePpgBYTktxD7iU0X6eRheAsioF2uuw-0JKjxMK_cy3ybreE3MkpvT_88hBHqidLnHOP68XZ6bMp3XIqhQ',
* e: 'AQAB',
* n: '12oBZRhCiZFJLcPg59LkZZ9mdhSMTKAQZYq32k_ti5SBB6jerkh-WzOMAO664r_qyLkqHUSp3u5SbXtseZEpN3XPWGKSxjsy-1JyEFTdLSYe6f9gfrmxkUF_7DTpq0gn6rntP05g2-wFW50YO7mosfdslfrTJYWHFhJALabAeYirYD7-9kqq9ebfFMF4sRRELbv9oi36As6Q9B3Qb5_C1rAzqfao_PCsf9EPsTZsVVVkA5qoIAr47lo1ipfiBPxUCCNSdvkmDTYgvvRm6ZoM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4fDIP_128ItrBEqbtoGL379OUlNGbvbyq5-zOnloij7X8hPQsDnaes',
* qi: 'JTtu5XhXvr4xRg9EomRbqs5Si1nIsVLs3MVRggutGlEOvYZQZTxjEqAb6dnl-DSKEV3fSdxM_I61P0oE8eLpboTvqYoNZB4jL3CY_gS8-81SWrNqfk8z2P6UIGyRmKAfAZ2oKZZoHv2neygqD6AvKTV8AWHXTGUOw5n90YP2HMw'
* },
* }))
*
* Or KeyObject:
*
* app.use(auth({
* ...
* clientAssertionSigningKey: crypto.createPrivateKey({ key: '-----BEGIN PRIVATE KEY-----\nMIIEo...PgCaw\n-----END PRIVATE KEY-----' }),
* }))
*
* ```
*/
clientAssertionSigningKey?: KeyInput | object;
clientAssertionSigningKey?: KeyInput | KeyObject | JSONWebKey;

/**
* The algorithm to sign the client assertion JWT.
Expand Down
13 changes: 7 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
},
"devDependencies": {
"@types/express": "^4.17.6",
"@types/node": "^18.0.6",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"connect-redis": "^5.1.0",
Expand Down