Skip to content

Instantly share code, notes, and snippets.

View yusufbiberoglu's full-sized avatar
🎯
Focusing

Yusuf yusufbiberoglu

🎯
Focusing
View GitHub Profile
<?php
namespace App\Controller;
use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use Symfony\Component\Routing\Annotation\Route;
{% extends 'base.html.twig' %}
{% block title %}Hello HomeController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
security:
encoders:
App\Entity\User:
algorithm: auto
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
# used to reload user from session & other features (e.g. switch_user)
app_user_provider:
entity:
api_platform:
....
swagger:
versions: [3]
api_keys:
apiKey:
name: Authorization
type: header
....
<?php
// src/Swagger/SwaggerDecorator.php
declare(strict_types=1);
namespace App\Swagger;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
final class SwaggerDecorator implements NormalizerInterface
services:
# ...
App\Swagger\SwaggerDecorator:
decorates: 'api_platform.swagger.normalizer.documentation'
arguments: ['@App\Swagger\SwaggerDecorator.inner']
autoconfigure: false
// config/routes/routes.yaml
api_authentication:
path: /authentication
gesdinet_jwt_refresh_token:
path: /token/refresh
controller: gesdinet.jwtrefreshtoken::refresh
security:
encoders:
App\Entity\User:
algorithm: argon2i
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
# used to reload user from session & other features (e.g. switch_user)
app_user_provider:
entity:
gesdinet_jwt_refresh_token:
ttl: 2592000
user_identity_field: email