定制 garlic/auth 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

garlic/auth

Composer 安装命令:

composer require garlic/auth

包简介

JWT token authorization for Garlic services

README 文档

README

JWT token authorization bundle

Installation

1. Run:

$ composer require garlic/auth

2. Add to .env.dist (.env):

# Required
JWT_PUBLIC_KEY_PATH='config/jwt/public.pem' 

# Optional
JWT_PRIVATE_KEY_PATH=''
JWT_KEY_PASS_PHRASE='passPhrase'
JWT_TOKEN_TTL='3600'
JWT_USER_IDENTITY_FIELD='email'
JWT_USER_CLASS='Garlic\Auth\Security\User'

# User auth settings
USER_ADMIN_USERNAME=admin
USER_ADMIN_PASSWORD=securePassword
USER_SERVICE_NAME=users

3. Add Security configuration (change packages/security.yml):

security:
    providers:
        jwt_provider:
            lexik_jwt:
                class: Garlic\Auth\Security\User
    firewalls:
        main:
            pattern:   ^/
            stateless: true
            anonymous: true
            guard:
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator

4. Add Lexik jwt bundle configuration (change lexik_jwt_authentication.yml):

lexik_jwt_authentication:
    private_key_path: '%kernel.project_dir%/%env(JWT_PRIVATE_KEY_PATH)%'
    public_key_path:  '%kernel.project_dir%/%env(JWT_PUBLIC_KEY_PATH)%'
    pass_phrase:      '%env(JWT_PASSPHRASE)%'
    token_ttl:        '%env(JWT_TOKEN_TTL)%'
    user_identity_field: email
    encoder:
        service: lexik_jwt_authentication.encoder.lcobucci
        crypto_engine:  openssl
        signature_algorithm: RS384
    token_extractors:
        authorization_header:
            enabled: true
            prefix:  ''
            name:    Authorization

Using

1. Make JWT token from the authorization service

2. Add JWT token to to request headers:

Example:

Authorization: Body.Of.Token

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固