-
Notifications
You must be signed in to change notification settings - Fork 164
Description
I've been working on a custom grant_type to incorporate OTP in the normal user_credentials grant_type. This requires a storageMap property with the same name. The main problem is that the base library (bshaffes/oauth2) only accepts a few fixed values as keys for the storage map:
So this won't work:
'storageMap' => [
'user_credentials' => 'common\models\User',
'user_credentials_otp' => 'common\models\User',
],
'grantTypes' => [
'user_credentials' => [
'class' => 'OAuth2\GrantType\UserCredentials',
],
'user_credentials_otp' => [
'class' => 'common\components\GrantType\UserCredentialsOtp',
],
]
It returns the error:
"unknown storage key "user_credentials_otp", must be one of [access_token, authorization_code, client_credentials, client, refresh_token, user_credentials, user_claims, public_key, jwt_bearer, scope]"
I've forked the library and added a custom storageName property to the grantType configuration. This will allow me to override the storageMap key for a specific grantType.
'storageMap' => [
'user_credentials' => 'common\models\User',
'user_credentials_otp' => 'common\models\User',
],
'grantTypes' => [
'user_credentials' => [
'class' => 'OAuth2\GrantType\UserCredentials',
],
'user_credentials_otp' => [
'class' => 'common\components\GrantType\UserCredentialsOtp',
'storageName' => 'user_credentials'
],
]
Am I the only one having this problem? And would this be something we can add to the library? It's backwards compatible and I think the only way to support this right now.