famelo/oauth

此包的最新版本(dev-master)没有可用的许可证信息。

在此处添加描述

安装: 49

依赖关系: 0

建议: 0

安全性: 0

星标: 0

关注者: 2

分支: 1

开放问题: 0

类型:typo3-flow-package

dev-master 2015-04-01 23:28 UTC

This package is auto-updated.

Last update: 2024-09-05 18:20:57 UTC


README

本包帮助您设置基于常见OAuth提供者的登录,例如dropbox、github等。

使用方法

1. 添加OAuth服务

Famelo:
  Oauth:
    Services:
      Dropbox:
        Key: ...
        Secret: ...
        Logo: resource://Famelo.Oauth/Public/Media/Icons/Dropbox.png

      GitHub:
        Key: ...
        Secret: ...
        Scopes:
          - user
        Logo: resource://Famelo.Oauth/Public/Media/Icons/GitHub.png

      Harvest:
        Key: ...
        Secret: ...
        Logo: resource://Famelo.Oauth/Public/Media/Icons/Harvest.png

2. 配置MissingPartyHandler

Famelo:
  Oauth:
    missingPartyHandler:
        className: '\Famelo\Oauth\Security\MissingPartyHandler\AutoCreatePartyHandler'
        options:
          uri: '/'

3. 配置身份验证

TYPO3:
  Flow:
    security:
      enable: true
      authentication:
        providers:
          OAuthProvider:
            provider: 'Famelo\Oauth\Security\Authentication\OAuthAuthenticationProvider'
            tokenClass: 'Famelo\Oauth\Security\Authentication\Token\OAuth'
            entryPoint: WebRedirect
            entryPointOptions:
              uri: login
            providerOptions:
              partyClassName: \My\Package\Domain\Model\User
              roles:
                - My.Package:Usergroup

4. 包含Routes.yaml

-
  name: 'Oauth'
  uriPattern: '<OauthSubroutes>'
  defaults:
    '@format': 'html'
  subRoutes:
    OauthSubroutes:
      package: Famelo.Oauth

5. 创建用户模型

<?php

/**
 * @Flow\Entity
 */
class User extends \TYPO3\Party\Domain\Model\AbstractParty {

    use OAuthParty;

    /**
     * Returns the accounts of this party
     *
     * @param \Doctrine\Common\Collections\Collection $accounts
     */
    public function setAccounts(\Doctrine\Common\Collections\Collection $accounts) {
        $this->accounts = $accounts;
    }

    /**
     * This method receives the service information about a user.
     * Use this to fill your party with available information
     */
    public function fillFromService($source) {
        // $this->setUsername($source->getUsername());
        // $this->setEmail($source->getEmail());
    }

}