Skip to content

Instantly share code, notes, and snippets.

@Koalabaerchen
Last active August 29, 2015 14:08
Show Gist options
  • Save Koalabaerchen/269931a150570875b3f9 to your computer and use it in GitHub Desktop.
Save Koalabaerchen/269931a150570875b3f9 to your computer and use it in GitHub Desktop.
FOSUserBundle + HWIOAuthBundle + EVE Online SSO
# app/config/config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: hwi_oauth.yml } # this has to be added so we include the oauth yml
# ...
# app/config/hwi_oauth.yml
hwi_oauth:
# configuration of oauth resource owners to use
resource_owners:
eve_sso:
type: oauth2
client_id: SECRET
client_secret: SECRET
access_token_url: https://login.eveonline.com/oauth/token
authorization_url: https://login.eveonline.com/oauth/authorize
infos_url: https://login.eveonline.com/oauth/verify
scope: ""
user_response_class: HWI\Bundle\OAuthBundle\OAuth\Response\PathUserResponse
paths:
identifier: CharacterID
nickname: CharacterName
realname: CharacterName
# name of the firewall the oauth bundle is active in
firewall_name: main
# optional target_path_parameter to provide an explicit return URL
#target_path_parameter: _destination
# use referer as fallback to determine default return URL
#use_referer: true
# optional FOSUserBundle integration
fosub:
# try 30 times to check if a username is available (foo, foo1, foo2 etc)
username_iterations: 30
# mapping between resource owners (see below) and properties
properties:
eve_sso: eveCharacterId
# if you want to use 'connect' and do not use the FOSUB integration, configure these separately
connect: ~
# confirmation: true # should show confirmation page or not
# registration_form_handler: my_registration_form_handler
# registration_form: my_registration_form
# account_connector: my_link_provider # can be the same as your user provider
# optional HTTP Client configuration
http_client:
timeout: 5
verify_peer: true
ignore_errors: true
max_redirects: 5
# allows to switch templating engine for bundle views
#templating_engine: "php"
# app/config/routing.yml
hwi_sso_login:
pattern: /login/check-sso
hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /user/connect
hwi_oauth_login:
resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
prefix: /user/connect
hwi_oauth_connect:
resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"
prefix: /user/connect
# ...
# app/config/security.yml
#...
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
login_path: /user/connect/
check_path: /login/login_check
anonymous: true
oauth:
resource_owners:
eve_sso: "/login/check-sso"
login_path: /user/connect
failure_path: /user/connect
# FOSUB integration
oauth_user_provider:
service: hwi_oauth.user.provider.fosub_bridge
<?php
namespace Acme\UserBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;
/**
* User
*
* @ORM\Table(name="users")
* @ORM\Entity
*/
class User extends BaseUser
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var integer
*
* @ORM\Column(name="eve_character_id", type="integer", nullable=true)
*/
private $eveCharacterId;
public function __construct()
{
parent::__construct();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set eveCharacterId
*
* @param integer $eveCharacterId
* @return User
*/
public function setEveCharacterId($eveCharacterId)
{
$this->eveCharacterId = $eveCharacterId;
return $this;
}
/**
* Get eveCharacterId
*
* @return integer
*/
public function getEveCharacterId()
{
return $this->eveCharacterId;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment