Skip to content

Instantly share code, notes, and snippets.

View MehGokalp's full-sized avatar
🌏
Trying to find a solution

Mehmet Gökalp MehGokalp

🌏
Trying to find a solution
View GitHub Profile
@danvbe
danvbe / 1-Explanations.md
Last active April 21, 2023 15:39
A way to integrate FosUserBundle and HWIOAuthBundle

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.
@andelf
andelf / smtp_login_auth.go
Created March 8, 2013 18:40
golang net/smtp SMTP AUTH LOGIN Auth Handler
// MIT license (c) andelf 2013
import (
"net/smtp"
"errors"
)
type loginAuth struct {
username, password string

All code is in JavaScript, but the technique discussed is applicable to many languages.

50% of "else" statements are unnecessary. Not only that, they also increase bugs and decrease readability and maintainability. A coding technique to counter this is "guard clauses". Using them has the following benefits:

  • Thinking in terms of guard clauses instead of if/else puts you in a frame of mind where you are more likely to catch bugs.
  • This pattern increases code readability (and thus maintainability)
  • It Keeps Code Left, which again increases readability
@technetium
technetium / .Propagating-awareness-via-ManyToOne-associations.md
Created April 14, 2016 07:47
Propagating awareness via ManyToOne associations

Propagating awareness via ManyToOne associations

Introduction

Michaël Perrin has written an article about using annotation and filters improve security.

With a more complex model, for example an order that contains products, you want also to filter on the associations of the filtered entity.

<?php
namespace GuzzleDynamicRequests;
require __DIR__ . '/vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;
// Do not extend IteratorIterator, because it cashes the return values somehow!
@mirkorap
mirkorap / symfony4-fos-oauth-server-bundle.md
Last active February 22, 2024 14:51
Basic examples how to implement a REST API with Symfony 4 + FOSRestBundle + FOSUserBundle + FOSOauthServerBundle with all oauth2 code flow