Building really fast applications (Tobias Nyholm)
…like to do whenever I start a new project and when I download new dependency, I like play a game and it's called do you need this? So basically do you need security, if you're on a private network? Do you need forms…
Filtering Related Collections
…for more complex control, hiding fields
based on the user, adding custom fields based on the user, validating data...
again... based on who is logged in and even controlling database queries based
on security. That... was awesome!
In an upcoming tutorial, we'll talk about…
A "Normalizer Aware" Normalizer
…most importantly, it fixes our issue!
Next, let's add the proper security logic to our class and then investigate
another superpower of normalizers: the ability to add completely custom fields.
We'll add a strange... but potentially useful boolean field to User called isMe.
Auto-set the Owner: Entity Listener
… To find the
currently-authenticated user, add an __construct() method, type-hint the
Security service and then press Alt + Enter and select "Initialize fields" to
create that property and set it.
Next, inside the method, start by seeing if the owner was already set: if…
Testing, Updating Roles & Refreshing Data
…the test
environment, in order for Symfony's security system to "notice" that a user's
roles were updated in the database, that user needs to log back in. It's a quirk
of the security system and hopefully one we'll fix soon. Heck…
Resetting the Database Between Tests
…
Next, I want to make one more improvement to our test suite before we get back
to talking about API Platform security. I want to create a base test class with
some helper methods that will enable us to move fast and write clean code…
Base Test Class full of Goodies
…We need to get the service out of
the container that's responsible for encoding passwords. We can get that with
self::$container->get('security.password_encoder'). We also could have used
UserPasswordEncoderInterface::class as the service id - that's the type-hint
we use…
Relating Resources
…is no different than setting any other field. Later, once we have a real
security system, we'll start locking things down so that I can't create a
CheeseListing and say that someone else owns it.
Anyways, to make owner part of our API…
User API Resource
…eventually store the encoded password, which
is not something that an API client will set directly. But... we're going to
worry about all of that in our security tutorial. For now, because password is a
required field in the database, let's temporarily make…
Microservices Gone Wrong
…let's say you have a bug in production. How would
you replicate that in a local environment? If you're dealing with a monolith,
maybe depending upon your security requirements, you clone the database? Or if
you're actually doing things well and GDPR…
When Testing Makes No Sense
… Okay. 6 to 7
hands. So, actually, can you raise your hands up? Who tests everything? How much
security testing do we do? Performance testing? Visual regression testing? That
all is testing, right?
So, why I decided to do this talk was people came to…
Building Apps for Immutable Servers
…Okay? That's a simple one. It's more or less easier, but it can have some
issues. Let's say that you want to apply some security updates. It can be more
tricky. I usually prefer a multistep build process. This is my preference…
Building Global Web Apps with Multi-region Hosting
…data from headers, which, you know,
it's not the best idea in terms of security or taking user content and like just
dumping it into the session and serializing it, like you want to be really
careful when you do things like that. Um…
How Static PHP Analyzer Changed the way I Look at Code
…bugs so that trying really to analyze php on multiple levels of php code you
have bugs, you have even vulnerabilities. So they have kind of security checks
as well. You have those code smells. It's the things I want to talk about
today…
Going crazy with Varnish: Caching pages of logged in users
…for example, it could
be the groups of a user, because Symfony security has this concept of groups
already. This can be implemented quite transparently: the reverse proxy does
the job and the application doesn't really need to know about it that much. The…
Knowing your State Machines
…surprise: I love the Workflow Component. I use the Workflow component
all over the place. If I have... the Symfony Security components have the
concept of voters, which are basically: if someone wants to watch, view an
advert, I got to make sure that advert…
Back to the Basics (Symfony local Web Server)
…use symfony security:check, which is nice because it does not
connect to the API. So it's, everything happens locally. So it clones a GitHub
repository but then everything happens locally. So that's a nice way to not
depend on security.symfony.com…
Autocomplete JavaScript
…until now, if we've wanted to add a class attribute, we've done it from inside
of our Twig template. For example, open security/register.html.twig. For the form
start tag, we're passing an attr variable with a class key. Or, for…
Redirecting on Success & the User Provider
…that info is loaded from the session and we're
logged in. Cool!
Look back at your security.yaml file. Remember this user provider thing that was
setup for us?
This is a class that helps with the process of loading the user info from…
x
1000+