Right now I am using laravel to fetch okta app information from the DB. I pull these rows out and the credentials differ since there are 2 different okta apps. i.e the client_secret and redirect URI's are different for each app.
Right now I pull the 2 rows out and loop through and assign credentials in the loop but the issue is that I do not know how to differentiate the apps and assign them different credentials while looping.
Boot method in service provider where I assign credentials
public function boot(OktaApp $oktaApp, Repository $repository)
{
$oktaApps = $oktaApp
->where('name', 'oktaApp1')
->orWhere('name', 'oktaApp2')
->get()->toArray();
foreach ($oktaApps as $app) {
//How do I assign creds dynamically based on app name?
$repository['services.oktaApp1'] = [
'client_id' => $app['client_id'],
'client_secret' => $app['client_secret'],
'redirect' => $app['redirect_uri'],
'base_url' => $app['base_url'],
];
}
}
If I die and dump the results from $oktaApps
array:2 [▼
0 => array:6 [▼
"id" => 1
"name" => "oktaApp1"
"client_id" => "......removed for security....."
"client_secret" => "......removed for security....."
"redirect_uri" => "http://localhost:8000/login/oktaApp1/callback"
"base_url" => "......removed for security....."
]
1 => array:6 [▼
"id" => 2
"name" => "oktaApp2"
"client_id" => "......removed for security....."
"client_secret" => "......removed for security....."
"redirect_uri" => "http://localhost:8000/login/oktaApp2/callback"
"base_url" => "......removed for security....."
]
]
How I am manually assigning the values as of right now (working but hard coded)
$repository['services.oktaApp1'] = [
'client_id' => $app[0]['client_id'],
'client_secret' => $app[0]['client_secret'],
'redirect' => $app[0]['redirect_uri'],
'base_url' => $app[0]['base_url'],
];
$repository['services.oktaApp2'] = [
'client_id' => $app[1]['client_id'],
'client_secret' => $app[1]['client_secret'],
'redirect' => $app[1]['redirect_uri'],
'base_url' => $app[1]['base_url'],
];