Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Delivery
P
Public
Open source
konnect-bundle
Commits
17ad6cb6
Commit
17ad6cb6
authored
Sep 20, 2019
by
dbourdere
🤸
Committed by
adacruz
Sep 20, 2019
Browse files
use constants
parent
57349525
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
22 deletions
+44
-22
Security/Auth0ResourceOwner.php
Security/Auth0ResourceOwner.php
+44
-22
No files found.
Security/Auth0ResourceOwner.php
View file @
17ad6cb6
...
...
@@ -10,25 +10,47 @@ use HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\GenericOAuth2ResourceOwner;
class
Auth0ResourceOwner
extends
GenericOAuth2ResourceOwner
{
const
AUTH0_USER_DATA_KEY_PICTURE
=
'picture'
;
const
AUTH0_USER_DATA_KEY_EMAIL
=
'email'
;
const
AUTH0_USER_DATA_KEY_NAME
=
'name'
;
const
AUTH0_USER_DATA_KEY_NICKNAME
=
'nickname'
;
const
AUTH0_USER_DATA_KEY_USERID
=
'user_id'
;
const
AUTH0_USER_DATA_KEY_USERID_KEY
=
'identifier'
;
const
AUTH0_USER_DATA_KEY_NICKNAME_KEY
=
'nickname'
;
const
AUTH0_USER_DATA_KEY_NAME_KEY
=
'realname'
;
const
AUTH0_USER_DATA_KEY_EMAIL_KEY
=
'email'
;
const
AUTH0_USER_DATA_KEY_PICTURE_KEY
=
'profilepicture'
;
const
AUTH0_URI_AUTHORIZE
=
'/authorize'
;
const
AUTH0_URI_ACCESS_TOKEN
=
'/oauth/token'
;
const
AUTH0_URI_INFO
=
'/userinfo'
;
const
AUTH0_URI_AUTHORIZE_KEY
=
'authorization_url'
;
const
AUTH0_URI_ACCESS_TOKEN_KEY
=
'access_token_url'
;
const
AUTH0_URI_INFO_KEY
=
'infos_url'
;
const
AUTH0_URI_AUDIENCE_KEY
=
'audience'
;
/**
* {@inheritdoc}
*/
protected
$paths
=
array
(
'identifier'
=>
'user_id'
,
'nickname'
=>
'nickname'
,
'realname'
=>
'name'
,
'email'
=>
'email'
,
'profilepicture'
=>
'picture'
,
)
;
protected
$paths
=
[
self
::
AUTH0_USER_DATA_KEY_USERID_KEY
=>
self
::
AUTH0_USER_DATA_KEY_USERID
,
self
::
AUTH0_USER_DATA_KEY_NICKNAME_KEY
=>
self
::
AUTH0_USER_DATA_KEY_NICKNAME
,
self
::
AUTH0_USER_DATA_KEY_NAME_KEY
=>
self
::
AUTH0_USER_DATA_KEY_NAME
,
self
::
AUTH0_USER_DATA_KEY_EMAIL_KEY
=>
self
::
AUTH0_USER_DATA_KEY_EMAIL
,
self
::
AUTH0_USER_DATA_KEY_PICTURE_KEY
=>
self
::
AUTH0_USER_DATA_KEY_PICTURE
,
]
;
/**
* {@inheritdoc}
*/
public
function
getAuthorizationUrl
(
$redirectUri
,
array
$extraParameters
=
array
()
)
public
function
getAuthorizationUrl
(
$redirectUri
,
array
$extraParameters
=
[]
)
{
return
parent
::
getAuthorizationUrl
(
$redirectUri
,
array_merge
(
array
(
return
parent
::
getAuthorizationUrl
(
$redirectUri
,
array_merge
(
[
'audience'
=>
$this
->
options
[
'audience'
],
)
,
$extraParameters
));
]
,
$extraParameters
));
}
/**
...
...
@@ -38,24 +60,24 @@ class Auth0ResourceOwner extends GenericOAuth2ResourceOwner
{
parent
::
configureOptions
(
$resolver
);
$resolver
->
setDefaults
(
array
(
'authorization_url'
=>
'{base_url}/authorize'
,
'access_token_url'
=>
'{base_url}/oauth/token'
,
'infos_url'
=>
'{base_url}/userinfo'
,
'audience'
=>
'{base_url}/userinfo'
,
)
);
$resolver
->
setDefaults
(
[
self
::
AUTH0_URI_AUTHORIZE_KEY
=>
'{base_url}'
.
self
::
AUTH0_URI_AUTHORIZE
,
self
::
AUTH0_URI_ACCESS_TOKEN_KEY
=>
'{base_url}'
.
self
::
AUTH0_URI_ACCESS_TOKEN
,
self
::
AUTH0_URI_INFO_KEY
=>
'{base_url}'
.
self
::
AUTH0_URI_INFO
,
self
::
AUTH0_URI_AUDIENCE_KEY
=>
'{base_url}'
.
self
::
AUTH0_URI_INFO
,
]
);
$resolver
->
setRequired
(
array
(
$resolver
->
setRequired
(
[
'base_url'
,
)
);
]
);
$normalizer
=
static
function
(
Options
$options
,
$value
)
{
return
str_replace
(
'{base_url}'
,
$options
[
'base_url'
],
$value
);
};
$resolver
->
setNormalizer
(
'authorization_url'
,
$normalizer
);
$resolver
->
setNormalizer
(
'access_token_url'
,
$normalizer
);
$resolver
->
setNormalizer
(
'infos_url'
,
$normalizer
);
$resolver
->
setNormalizer
(
'audience'
,
$normalizer
);
$resolver
->
setNormalizer
(
self
::
AUTH0_URI_AUTHORIZE_KEY
,
$normalizer
);
$resolver
->
setNormalizer
(
self
::
AUTH0_URI_ACCESS_TOKEN_KEY
,
$normalizer
);
$resolver
->
setNormalizer
(
self
::
AUTH0_URI_INFO_KEY
,
$normalizer
);
$resolver
->
setNormalizer
(
self
::
AUTH0_URI_AUDIENCE_KEY
,
$normalizer
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment