Comments (2)
Hi, yes this could be done via auth0. But right now there is no kind of admin interface or sth. like that... Are you working on a fork?
Fyi: there is a hosted version on https://mediathek.apps.bahuma.io/
from meine-mediathek.
I installed your repo locally, made it running. Already I'm digging into the new version (8.0.2) of auth0/auth0-php. But I'm still not sure if the token caching here is handled like in your authentication-method:
public function authenticate(Request $request): PassportInterface
{
$jwt = substr($request->headers->get('Authorization'), 7);
if (!$jwt || $jwt == '') {
throw new CustomUserMessageAuthenticationException('Authorization token missing');
}
try {
$token = $this->auth0->decode($jwt)->toArray();
} catch (InvalidTokenException $e) {
$this->logger->error($e->getMessage());
throw new CustomUserMessageAuthenticationException('Unable to decode access token');
}
if (!$token['sub']) {
throw new CustomUserMessageAuthenticationException('User ID could not be found in token');
}
$user = $this->userRepository->loadUserByIdentifier($token['sub']);
// if user doesn't exist in database create a new one
if ($user === null){
$response = $this->auth0->authentication()->userInfo($jwt);
// $requestBody = json_decode($response->getBody()->__toString(), true);
if (HttpResponse::wasSuccessful($response)) {
$userFromAuth0 = HttpResponse::decodeContent($response);
if (!$userFromAuth0['email_verified']){
throw new CustomUserMessageAuthenticationException('Email not yet verified. Please verify first.');
}
$newUser = new User();
$newUser->setSub($userFromAuth0['sub']);
$newUser->setEmail($userFromAuth0['email']);
$newUser->setRoles($token['permissions']);
$this->em->persist($newUser);
$this->em->flush();
} else {
throw new CustomUserMessageAuthenticationException('User not found');
}
} else {
$newUser = $user;
$newUser->setRoles($token['permissions']);
}
return new SelfValidatingPassport(new UserBadge($token['sub'], function ($userId) use ($newUser) {
return $newUser;
}));
}
from meine-mediathek.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meine-mediathek.