mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-24 21:05:03 +02:00
Added proper OAuth authentication for digikey and other providers
This commit is contained in:
parent
a95ba1acc4
commit
c203de082e
13 changed files with 876 additions and 19 deletions
|
@ -30,4 +30,5 @@ return [
|
|||
Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
|
||||
Symfony\UX\Translator\UxTranslatorBundle::class => ['all' => true],
|
||||
Jbtronics\DompdfFontLoaderBundle\DompdfFontLoaderBundle::class => ['all' => true],
|
||||
KnpU\OAuth2ClientBundle\KnpUOAuth2ClientBundle::class => ['all' => true],
|
||||
];
|
||||
|
|
|
@ -2,16 +2,4 @@ framework:
|
|||
http_client:
|
||||
default_options:
|
||||
headers:
|
||||
'User-Agent': 'Part-DB'
|
||||
|
||||
|
||||
scoped_clients:
|
||||
digikey.client:
|
||||
base_uri: 'https://sandbox-api.digikey.com'
|
||||
auth_bearer: '%env(PROVIDER_DIGIKEY_TOKEN)%'
|
||||
headers:
|
||||
X-DIGIKEY-Client-Id: '%env(PROVIDER_DIGIKEY_CLIENT_ID)%'
|
||||
X-DIGIKEY-Locale-Site: 'DE'
|
||||
X-DIGIKEY-Locale-Language: 'de'
|
||||
X-DIGIKEY-Locale-Currency: '%partdb.default_currency%'
|
||||
X-DIGIKEY-Customer-Id: 0
|
||||
'User-Agent': 'Part-DB'
|
18
config/packages/knpu_oauth2_client.yaml
Normal file
18
config/packages/knpu_oauth2_client.yaml
Normal file
|
@ -0,0 +1,18 @@
|
|||
knpu_oauth2_client:
|
||||
clients:
|
||||
# configure your clients as described here: https://github.com/knpuniversity/oauth2-client-bundle#configuration
|
||||
|
||||
ip_digikey_oauth:
|
||||
type: generic
|
||||
provider_class: '\League\OAuth2\Client\Provider\GenericProvider'
|
||||
|
||||
client_id: '%env(PROVIDER_DIGIKEY_CLIENT_ID)%'
|
||||
client_secret: '%env(PROVIDER_DIGIKEY_SECRET)%'
|
||||
|
||||
redirect_route: 'oauth_client_check'
|
||||
redirect_params: {name: 'ip_digikey_oauth'}
|
||||
|
||||
provider_options:
|
||||
urlAuthorize: 'https://sandbox-api.digikey.com/v1/oauth2/authorize'
|
||||
urlAccessToken: 'https://sandbox-api.digikey.com/v1/oauth2/token'
|
||||
urlResourceOwnerDetails: ''
|
|
@ -16,6 +16,9 @@ nelmio_security:
|
|||
# Whitelist the domain of the SAML IDP, so we can redirect to it during the SAML login process
|
||||
- '%env(string:key:host:url:SAML_IDP_SINGLE_SIGN_ON_SERVICE)%'
|
||||
|
||||
# Whitelist the info provider APIs
|
||||
- 'digikey.com'
|
||||
|
||||
# forces Microsoft's XSS-Protection with
|
||||
# its block mode
|
||||
xss_protection:
|
||||
|
|
|
@ -248,6 +248,11 @@ services:
|
|||
arguments:
|
||||
$api_key: '%env(PROVIDER_ELEMENT14_KEY)%'
|
||||
|
||||
App\Services\InfoProviderSystem\Providers\DigikeyProvider:
|
||||
arguments:
|
||||
$clientId: '%env(PROVIDER_DIGIKEY_CLIENT_ID)%'
|
||||
$currency: '%partdb.default_currency%'
|
||||
|
||||
App\Services\InfoProviderSystem\Providers\TMEClient:
|
||||
arguments:
|
||||
$secret: '%env(PROVIDER_TME_SECRET)%'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue