From ebefa6f3ea9063eff7658134725f4edbaef36e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Prokop?= Date: Mon, 30 Oct 2023 16:54:10 +0100 Subject: [PATCH] feat: ADD configurable showcases of api curl calls --- example-config.php | 23 +++-- refreshtoken.php | 176 +++++++++++++++++++++++------------- src/MitreIdConnectUtils.php | 4 +- 3 files changed, 131 insertions(+), 72 deletions(-) diff --git a/example-config.php b/example-config.php index a0593d9..a601826 100644 --- a/example-config.php +++ b/example-config.php @@ -8,9 +8,9 @@ // Client configuration $issuer = "https://example.com/oidc/"; $clientId = "some-client-id"; -$clientSecret = "some-client-secret"; // comment if you are using PKCE +$clientSecret = "some-client-secret"; // comment if you are using PKCE // $pkceCodeChallengeMethod = "S256"; // uncomment to use PKCE -$redirectPage = "refreshtoken.php"; // select between "refreshtoken.php" and "auth.php" +$redirectPage = "refreshtoken.php"; // select between "refreshtoken.php" and "auth.php" $redirectUrl = "http://localhost/simple-oidc-client-php/" . $redirectPage; // add scopes as keys and a friendly message of the scope as value $scopesDefine = array( @@ -23,10 +23,21 @@ $accessTokenNote = "NOTE: New access tokens expire in 1 hour."; $manageTokenNote = "You can manage your refresh tokens in the following link: "; $manageTokens = $issuer . "manage/user/services"; -$sessionName = "simple-oidc-client-php"; // This value must be the same with the name of the parent directory -$sessionLifetime = 60 * 60; // must be equal to access token validation time in seconds +$sessionName = "simple-oidc-client-php"; // This value must be the same with the name of the parent directory +$sessionLifetime = 60 * 60; // must be equal to access token validation time in seconds $bannerText = ""; -$bannerType = "info"; // Select one of "info", "warning", "error" or "success" +$bannerType = "info"; // Select one of "info", "warning", "error" or "success" $allowIntrospection = false; -$enableActiveTokensTable = false; // This option works only for MITREid Connect based OPs +$enableActiveTokensTable = false; // This option works only for MITREid Connect based OPs $showIdToken = false; + +/* + Optional. Use when you want to generate a custom RPC API showcase. +*/ +$customAPIs = [ + [ + 'title' => 'To call Perun RPC API, use the following curl command:', + 'url' => 'https://idm.ics.muni.cz/oauth/rpc/json/authzResolver/getPerunPrincipal', + 'note' => 'NOTE: Full documentation is available at perun-aai.org' + ] +]; diff --git a/refreshtoken.php b/refreshtoken.php index 42595b5..f972661 100644 --- a/refreshtoken.php +++ b/refreshtoken.php @@ -1,74 +1,121 @@ - - -
-
-
- Logo -

-

Client ID:

- Client Secret: $clientSecret

"; - } - ?> -
+ + +
+
+
+ Logo +

+ +

+

Client ID: + +

+ Client Secret: $clientSecret

"; + } + ?> +
- + - + -
-
- +
+
+

ID Token:

- - + +
- + +
+

Access Token:

+ + +
+
+

To get the user info use the following curl command:

+ + +
+ + +
+

+ +

+ " /> + +

+ +

+
+ + +
-

Access Token:

- - +

To introspect the token use the following curl command:

+ +
-
-

To get the user info use the following curl command:

- - + +

+ +

+ +
+

Refresh Token:

+ + +

+ +

-
-

To introspect the token use the following curl command:

- - +

To generate access tokens from this refresh token use the following + curl command:

+ + +

+ +

- -

- -
-

Refresh Token:

- - -

-
-
-

To generate access tokens from this refresh token use the following curl command:

- - -

-
-
- -
- - -
- -

-
- +
+ +
+ + +
+ +

+ + + +

+
+
@@ -84,9 +131,10 @@
Active Refresh Tokens
- -
- +
-
- \ No newline at end of file + +
+
+ + diff --git a/src/MitreIdConnectUtils.php b/src/MitreIdConnectUtils.php index 6c23731..bc7d8b5 100644 --- a/src/MitreIdConnectUtils.php +++ b/src/MitreIdConnectUtils.php @@ -17,9 +17,9 @@ function getCurlRefresh($refreshToken, $tokenEndpoint, $clientId, $clientSecret . "| python -m json.tool;"; } -function getCurlUserInfo($accessToken, $userInfoEndpoint) +function getCurlForEndpoint($accessToken, $endpoint) { - return "curl ${userInfoEndpoint} " + return "curl ${endpoint} " . "-H 'Authorization: Bearer ${accessToken}' " . "-H 'Content-type: application/json' " . "| python -m json.tool;";