|
1 | 1 | <?php |
2 | 2 | /** |
3 | 3 | * SSO data implementation, based on this doc: |
4 | | - * https://developers.staffbase.com/api/plugin-sso/ |
| 4 | + * https://developers.staffbase.com/guide/customplugin-overview |
5 | 5 | * |
6 | 6 | * PHP version 5.5.9 |
7 | 7 | * |
8 | 8 | * @category Authentication |
9 | | - * @copyright 2017-2019 Staffbase, GmbH. |
| 9 | + * @copyright 2017-2020 Staffbase, GmbH. |
10 | 10 | * @author Vitaliy Ivanov |
11 | 11 | * @license http://www.apache.org/licenses/LICENSE-2.0 |
12 | 12 | * @link https://github.com/staffbase/plugins-sdk-php |
|
20 | 20 | */ |
21 | 21 | abstract class SSOData |
22 | 22 | { |
23 | | - const CLAIM_AUDIENCE = 'aud'; |
24 | | - const CLAIM_EXPIRE_AT = 'exp'; |
25 | | - const CLAIM_NOT_BEFORE = 'nbf'; |
26 | | - const CLAIM_ISSUED_AT = 'iat'; |
27 | | - const CLAIM_ISSUER = 'iss'; |
28 | | - const CLAIM_SESSION_ID = 'sid'; |
29 | | - const CLAIM_INSTANCE_ID = 'instance_id'; |
30 | | - const CLAIM_INSTANCE_NAME = 'instance_name'; |
31 | | - const CLAIM_BRANCH_ID = 'branch_id'; |
32 | | - const CLAIM_BRANCH_SLUG = 'branch_slug'; |
33 | | - const CLAIM_USER_ID = 'sub'; |
34 | | - const CLAIM_USER_EXTERNAL_ID = 'external_id'; |
35 | | - const CLAIM_USER_FULL_NAME = 'name'; |
36 | | - const CLAIM_USER_FIRST_NAME = 'given_name'; |
37 | | - const CLAIM_USER_LAST_NAME = 'family_name'; |
38 | | - const CLAIM_USER_ROLE = 'role'; |
39 | | - const CLAIM_ENTITY_TYPE = 'type'; |
40 | | - const CLAIM_THEME_TEXT_COLOR = 'theming_text'; |
41 | | - const CLAIM_THEME_BACKGROUND_COLOR = 'theming_bg'; |
42 | | - const CLAIM_USER_LOCALE = 'locale'; |
43 | | - const CLAIM_USER_TAGS = 'tags'; |
| 23 | + const CLAIM_AUDIENCE = 'aud'; |
| 24 | + const CLAIM_EXPIRE_AT = 'exp'; |
| 25 | + const CLAIM_NOT_BEFORE = 'nbf'; |
| 26 | + const CLAIM_ISSUED_AT = 'iat'; |
| 27 | + const CLAIM_ISSUER = 'iss'; |
| 28 | + const CLAIM_SESSION_ID = 'sid'; |
| 29 | + const CLAIM_INSTANCE_ID = 'instance_id'; |
| 30 | + const CLAIM_INSTANCE_NAME = 'instance_name'; |
| 31 | + const CLAIM_BRANCH_ID = 'branch_id'; |
| 32 | + const CLAIM_BRANCH_SLUG = 'branch_slug'; |
| 33 | + const CLAIM_USER_ID = 'sub'; |
| 34 | + const CLAIM_USER_EXTERNAL_ID = 'external_id'; |
| 35 | + const CLAIM_USER_USERNAME = 'username'; |
| 36 | + const CLAIM_USER_PRIMARY_EMAIL_ADDRESS = 'primary_email_address'; |
| 37 | + const CLAIM_USER_FULL_NAME = 'name'; |
| 38 | + const CLAIM_USER_FIRST_NAME = 'given_name'; |
| 39 | + const CLAIM_USER_LAST_NAME = 'family_name'; |
| 40 | + const CLAIM_USER_ROLE = 'role'; |
| 41 | + const CLAIM_ENTITY_TYPE = 'type'; |
| 42 | + const CLAIM_THEME_TEXT_COLOR = 'theming_text'; |
| 43 | + const CLAIM_THEME_BACKGROUND_COLOR = 'theming_bg'; |
| 44 | + const CLAIM_USER_LOCALE = 'locale'; |
| 45 | + const CLAIM_USER_TAGS = 'tags'; |
44 | 46 |
|
45 | 47 | const USER_ROLE_EDITOR = 'editor'; |
46 | 48 |
|
@@ -217,6 +219,26 @@ public function getUserExternalId() { |
217 | 219 | return $this->getClaimSafe(self::CLAIM_USER_EXTERNAL_ID); |
218 | 220 | } |
219 | 221 |
|
| 222 | + /** |
| 223 | + * Get the username of the user accessing. |
| 224 | + * |
| 225 | + * @return null|string |
| 226 | + */ |
| 227 | + public function getUserUsername() { |
| 228 | + |
| 229 | + return $this->getClaimSafe(self::CLAIM_USER_USERNAME); |
| 230 | + } |
| 231 | + |
| 232 | + /** |
| 233 | + * Get the primary email address of the user accessing. |
| 234 | + * |
| 235 | + * @return null|string |
| 236 | + */ |
| 237 | + public function getUserPrimaryEmailAddress() { |
| 238 | + |
| 239 | + return $this->getClaimSafe(self::CLAIM_USER_PRIMARY_EMAIL_ADDRESS); |
| 240 | + } |
| 241 | + |
220 | 242 | /** |
221 | 243 | * Get either the combined name of the user or the name of the token. |
222 | 244 | * |
|
0 commit comments