PluginProbe
ActivityPub / 9.3.1
ActivityPub v9.3.1
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
activitypub / templates / oauth-authorize.php

oauth-authorize.php in ActivityPub 9.3.1, at templates/oauth-authorize.php

133 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * OAuth Authorization Consent Form Template.
4 *
5 * @package Activitypub
6 *
7 * Variables available (passed via include from class-server.php):
8 * @var WP_User $current_user The current logged-in user.
9 * @var array $scopes Array of requested scopes.
10 * @var Activitypub\OAuth\Client $client The client object.
11 * @var array $authorize_params OAuth request parameters (client_id, redirect_uri, scope, state, code_challenge, code_challenge_method).
12 * @var string $form_url The form action URL.
13 */
14
15 // phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- Variables passed via include.
16
17 use Activitypub\OAuth\Scope;
18
19 // Use WordPress login page header.
20 $login_errors = new WP_Error();
21
22 if ( empty( $authorize_params['code_challenge'] ) ) {
23 $login_errors->add(
24 'pkce_missing',
25 __( '<strong>Warning:</strong> This client does not support PKCE. The connection may be less secure.', 'activitypub' ),
26 'message'
27 );
28 }
29
30 login_header(
31 /* translators: %s: Client name */
32 sprintf( __( 'Authorize %s', 'activitypub' ), esc_html( $client->get_display_name() ) ),
33 '',
34 $login_errors
35 );
36 ?>
37
38 <form method="post" action="<?php echo esc_url( $form_url ); ?>">
39 <div class="activitypub-oauth-client">
40 <p>
41 <strong>
42 <?php
43 $client_link_url = $client->get_link_url();
44 $client_display = esc_html( $client->get_display_name() );
45 $client_label = $client_link_url
46 ? sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $client_link_url ), $client_display )
47 : $client_display;
48
49 echo wp_kses(
50 sprintf(
51 /* translators: %s: Client name or ID */
52 __( '%s wants to access your account.', 'activitypub' ),
53 $client_label
54 ),
55 array(
56 'a' => array(
57 'href' => array(),
58 'target' => array(),
59 ),
60 )
61 );
62 ?>
63 </strong>
64 </p>
65 </div>
66
67 <div class="activitypub-oauth-user" style="background: #f6f7f7; padding: 15px; border-radius: 4px; margin: 20px 0;">
68 <?php echo get_avatar( $current_user->ID, 48 ); ?>
69 <p>
70 <?php
71 echo wp_kses(
72 sprintf(
73 /* translators: 1: User display name, 2: User login */
74 __( 'Logged in as %1$s (%2$s). You can revoke access at any time.', 'activitypub' ),
75 '<strong>' . esc_html( $current_user->display_name ) . '</strong>',
76 esc_html( $current_user->user_login )
77 ),
78 array( 'strong' => array() )
79 );
80 ?>
81 </p>
82 </div>
83
84 <?php if ( ! empty( $scopes ) ) : ?>
85 <div class="activitypub-oauth-scopes" style="margin: 20px 0;">
86 <h3><?php esc_html_e( 'Permissions requested:', 'activitypub' ); ?></h3>
87 <ul style="margin: 0; padding: 0 0 0 20px;">
88 <?php foreach ( $scopes as $scope_name ) : ?>
89 <li>
90 <strong><?php echo esc_html( $scope_name ); ?></strong>
91 <?php
92 $description = Scope::get_description( $scope_name );
93 if ( $description ) {
94 echo ' &ndash; ' . esc_html( $description );
95 }
96 ?>
97 </li>
98 <?php endforeach; ?>
99 </ul>
100 </div>
101 <?php endif; ?>
102
103 <div class="activitypub-oauth-redirect" style="background: #f0f6fc; padding: 10px 15px; border-radius: 4px; margin: 20px 0; font-size: 13px;">
104 <?php
105 echo wp_kses(
106 sprintf(
107 /* translators: %s: Redirect URI */
108 __( 'You will be redirected to %s after authorization.', 'activitypub' ),
109 '<code>' . esc_html( $authorize_params['redirect_uri'] ) . '</code>'
110 ),
111 array( 'code' => array() )
112 );
113 ?>
114 </div>
115
116 <?php wp_nonce_field( 'activitypub_oauth_authorize' ); ?>
117 <?php foreach ( $authorize_params as $param_name => $param_value ) : ?>
118 <input type="hidden" name="<?php echo esc_attr( $param_name ); ?>" value="<?php echo esc_attr( $param_value ); ?>" />
119 <?php endforeach; ?>
120
121 <p class="submit" style="display: flex; gap: 10px;">
122 <button type="submit" name="approve" value="1" class="button button-primary button-large">
123 <?php esc_html_e( 'Authorize', 'activitypub' ); ?>
124 </button>
125 <button type="submit" name="deny" value="1" class="button button-large">
126 <?php esc_html_e( 'Cancel', 'activitypub' ); ?>
127 </button>
128 </p>
129 </form>
130
131 <?php
132 login_footer();
133