承接 cosmonova-rnd/auth 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cosmonova-rnd/auth

Composer 安装命令:

composer require cosmonova-rnd/auth

包简介

Simple OAuth 2 library for Symfony projects

README 文档

README

At this time, library allow to auth using JWT with OAuth2 Authorization Code flow.

Installation

Install package using composer

composer req cosmonova-rnd/auth

Basic configuration

  1. Enable session handler in your application
framework:
    session:
        handler_id: ~
  1. Configure DB connection, then add new entity manager auth to your application config
doctrine:
    orm:
        entity_managers:
            auth:
                connection: default ## may be your custom connection
                default_repository_class: 'CosmonovaRnD\Auth\Repository\UserRepository'
                mappings:
                    Auth:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/vendor/cosmonova-rnd/auth/src/Entity'
                        prefix: 'CosmonovaRnD\Auth\Entity'
                        alias: Auth
  1. Configure encoder and provider in security section
security:
    encoders:
        CosmonovaRnD\Auth\Entity\User:
            algorithm: plaintext
    providers:
        auth_provider:
            id: CosmonovaRnD\Auth\Security\UserProvider

Configuration of authentication through OAuth2 service (authorization_code flow)

  1. Configure your main firewall to use package provider and set login form config like bellow
security:
    firewalls:
        main:
            ### If you want to use OAuth2 Access Code authentication flow
            provider: auth_provider
            anonymous: ~
            logout: ~
            form_login:
                login_path: auth
                check_path: auth            
  1. Add access control rules
access_control:
    - { path: ^/auth, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/, roles: IS_AUTHENTICATED_FULLY }

Configuration for checking authentication using JSON Web Token

In this case we use Authorization: Bearer <MY JWT> header

  1. Configure any provider (such like a memory)
security:
    providers:
        in_memory: { memory: ~ }
  1. Then add to your main firewall this provider and guard authenticator
security:
    firewalls:
        main:
            provider: in_memory
            guard:
                authenticators:
                    - CosmonovaRnD\Auth\Security\Authenticator\JwtAuthenticator
            stateless: true
  1. Also configure your access rules if needed
access_control:
    - { path: ^/, roles: IS_AUTHENTICATED_FULLY }

@ Cosmonova | Research & Development

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固