1000 search results

Decorating the Core State Provider

…Shazam! We're green! So let's go set that value for real. This is easy enough: add a private Security argument... and make sure you first arg has a comma. Then this is true if $this->security->getUser() equals $treasure->getOwner(). And... then... the…

4:47
Entities, DTO's & The "Central" Object

…item, that central object is that single item. And that's really important. It's used in various places, like the security attribute: when we use is_granted, the object variable will be that "central" object. For example, if we make a Patch() request, that…

6:24
The Secrets Vault

…I'll say CHANGEME. You can't see me type that... only because Symfony hides it for security reasons. Since this is the first secret we've created, Symfony automatically created the secrets vault behind the scenes... which is literally a set of files that…

5:46
kernel.response Event & Request Format

…ones, like ResponseListener. Let's open that one up. I'll hit Shift+Shift to open ResponseListener.php: get the one from http-kernel/, not security. It says: ResponseListener fixes the Response headers based on the Request. Let's... find out what that means. Inside…

6:36
Upgrade to Symfony 3.4

…I keep responsible version constraints in composer.json, ahem, no dev-master or * versions, this is pretty safe and also means I get bug fixes, security fixes and new features. And... hello Symfony 3.4! The best part? Ah, you guys already know it: thanks…

8:56
Backport the API Platform 2.5 Test Tools

…overriding the first... so let's remove the extra one. Anyways, for our first test, I want to make sure this security is working. Add public function testCreateCheeseListing(). And inside, make sure this all isn't an elaborate dream with $this->assertEquals(42, 42). Ok…

5:01
Api Tests & Assertions

…Guzzle. Let's do this! Make a request with $client->request(): make a POST request to /api/cheeses. How nice is that? We're going to focus our tests mostly on asserting security stuff. Because we haven't logged in, this request will not be…

6:51
Login Success & the Session

…cheat for now. Find your terminal and run: php bin/console security:encode This is a fun utility where you can give it a plain-text password - I'll use foo - and it will give us back an encoded version of that password. Copy that…

4:28
API Debugging with the Profiler

…the request headers, request content - which is really important when you're sending JSON - and all the goodies that you expect - cache, performance, security, Doctrine, etc. In addition to the little web debug toolbar AJAX tracker we just saw, there are a few other ways…

3:17
Leverage the power of Symfony components within ApiPlatform

…and things like this. In these tools are also available the security. So when you think about an API, you don't really think about security and you don't have to care about it because we did all the work. We prepared this for…

27:45
Changing PHP

…So, one afternoon, in an office somewhere, uh, we were having a security scan, um, and certain requests were hanging on certain conditions. Um, and basically it boiled down to the fact that the text protocol of Memcached cannot really handle new lines in the…

34:14
Multiple Pages / Entries

…and... refresh! Bah: require is not defined Boo! My bad - I forgot to use the new built file. Open templates/bundles/FOSUserBundle/Security/login.html.twig. Point the script tag to build/login.js: And now... it works! When I type a really long username…

4:38
Quick! Create a DragonTreasure DTO

…ApiPlatform/, let's also delete AdminGroupsContextBuilder. This was a complex way to make fields readable or writable by our admin... but we're going to solve that with ApiProperty security. Also get rid of the custom normalizer... which added a field and an extra group…

9:51
Custom Authenticator authenticate() Method

…new Passport(). By the way, if you're new to the custom authenticator system and want to learn more, check out our Symfony 5 Security tutorial where we talk all about this. I'll go through the basics now, but the details live there. Before…

8:21
Hunting Down the Final Deprecations

…the list says: SessionInterface aliases are deprecated, use $requestStack->getSession() instead. It's being referenced by the LoginFormAuthenticator service. Let's go check that out! Open src/Security/LoginFormAuthenticator.php. Ahh. I'm autowiring the SessionInterface service. In Symfony 6, that service no longer exists…

9:32
QR Data & Scanning with an Authenticator App

…this isTotpAuthenticationEnabled() method returned true. Second, the security "token" - that internal thing that wraps your User object when you log in - well, it matches one of the tokens in our configuration. Specifically, we get the UsernamePasswordToken when we log in via the form_login mechanism…

4:35
Activating 2FA

…and hit tab to get the use statement on top: For the most part, I've been using IS_AUTHENTICATED_REMEMBERED for security... so that you just need to be logged in... even if it’s via a "remember me" cookie. But I'm using…

5:34
Rendering the QR Code

…after the user enables two-factor authentication, let's render a template with an image to this URL. Return $this->render('security/enable2fa.html.twig'). Copy the template name, head into templates/security, and create that: enable2fa.html.twig. I'll paste in a basic…

6:13
2 Factor Authentication & Authentication Tokens

…Step 4 is to configure the firewall. This part we do need to do. Start by copying the two_factor stuff. Then open up config/packages/security.yaml. This new config can live anywhere under our main firewall. I'll paste it after form_login…

8:33
When Existing Tests Break & Exceptions in __construct()

…over $initialDinosaurs as $dinosaurs and say, this->addDinosaur($dinosaur). That was the mistake that other programmer made: I'm using addDinosaur() instead of just setting the $dinosaurs property directly because that method contains the security checks. So... that should be it! Let's try phpspec…

7:20