You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @stevebauman exist Any way for implement JWT with LdapRecord-Laravel ?
We have been reading the documentation, but we haven't found anything that shows us how to implement JWT with
Until now we only need the user to be active in the active directory and that would be the only condition to generate a VALID TOKEN.
example code:
$credentials = [
'samAccountName' => $request->samAccountName,
'password' => $request->password,
];
try {
$ldapAuthService = new LdapAuthService($request);
if ($ldapAuthService->authenticate($request)) {
$conn = CustomHelpers::connectToHana(); // we are using sap hana
if ($conn) {
$sql = "SELECT * FROM \"DBGENERIC\".\"USERS\" WHERE \"samAccountName\" = ?";
$stmt = odbc_prepare($conn, $sql);
if ($stmt) {
if (odbc_execute($stmt, [$request->samAccountName])) {
$userData = odbc_fetch_array($stmt);
odbc_close($conn);
$infoUser = new User($userData);
}
}
odbc_close($conn);
}
}
}
$token = JWTAuth::fromUser($infoUser);
Our UserModel.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable implements JWTSubject
{
use Notifiable;
use HasFactory;
use HasApiTokens;
protected $primaryKey = 'ID';
protected $table = 'USERS'; //our table in SAP HANA
public $incrementing = false;
protected $fillable = ['samAccountName'];
public function getJWTIdentifier()
{
return $this->getKey();
}
public function getJWTCustomClaims()
{
return [];
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi @stevebauman exist Any way for implement JWT with LdapRecord-Laravel ?
We have been reading the documentation, but we haven't found anything that shows us how to implement JWT with
Until now we only need the user to be active in the active directory and that would be the only condition to generate a VALID TOKEN.
example code:
Our UserModel.php
Beta Was this translation helpful? Give feedback.
All reactions