2017-07-13 1 views
2

api paltformを使用して、チュートリアルの後に認証APIを作成してください。 https://api-platform.com/docs/core/jwtapiプラットフォーム:LexikJWTAuthenticationBundleプライベートキーを読み込めませんでした。

私はこのproblemeました: ":\ wamp64 \ WWW \のauth-API \アプリ/../ VAR/JWT/private.pem C":

は、秘密鍵 の読み込みに失敗しました0906A068を:PEM ルーチン:PEM_do_header:悪いパスワードは

のsecurity.yml

security: 
encoders: 
    FOS\UserBundle\Model\UserInterface: bcrypt 


providers: 
    fos_userbundle: 
     id: fos_user.user_provider.username 

firewalls: 
    login: 
     pattern: ^/login 
     stateless: true 
     anonymous: true 
     provider: fos_userbundle 
     form_login: 
      check_path: /login_check 
      username_parameter: _username 
      password_parameter: _password 
      success_handler: lexik_jwt_authentication.handler.authentication_success 
      failure_handler: lexik_jwt_authentication.handler.authentication_failure 
      require_previous_session: false 

    main: 
     pattern: ^/ 
     provider: fos_userbundle 
     stateless: true 
     anonymous: true 
     lexik_jwt: ~ 

    dev: 
     pattern: ^/(_(profiler|wdt)|css|images|js)/ 
     security: false 

access_control: 
    - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } 
    - { path: ^/, roles: IS_AUTHENTICATED_FULLY } 

config.ymlを読みますあなたがパスワードを挿入しassginedあなたparameters.ymlに追加する必要があり

imports: 
- { resource: parameters.yml } 
- { resource: security.yml } 
- { resource: services.yml } 

# Put parameters here that don't need to change on each machine where the 
app is deployed 
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration 
parameters: 
    locale: en 

framework: 
    #esi:    ~ 
    #translator:  { fallbacks: ["%locale%"] } 
    secret:   "%secret%" 
    router: 
     resource: "%kernel.root_dir%/config/routing.yml" 
     strict_requirements: ~ 
    form:   ~ 
    csrf_protection: ~ 
    validation:  { enable_annotations: true } 
    serializer:  { enable_annotations: true } 
    templating: 
     engines: ['twig'] 
    default_locale: "%locale%" 
    trusted_hosts: ~ 
    trusted_proxies: ~ 
    session: 
     # http://symfony.com/doc/current/reference/configuration/framework.html#handler-id 
     handler_id: session.handler.native_file 
     save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%" 
    fragments:  ~ 
    http_method_override: true 
    assets: ~ 
    php_errors: 
     log: true 

# Twig Configuration 
twig: 
    debug:   "%kernel.debug%" 
    strict_variables: "%kernel.debug%" 

# Doctrine Configuration 
doctrine: 
    dbal: 
     driver: pdo_mysql 
     host:  "%database_host%" 
     port:  "%database_port%" 
     dbname: "%database_name%" 
     user:  "%database_user%" 
     password: "%database_password%" 
     charset: UTF8 
    # if using pdo_sqlite as your database driver: 
    # 1. add the path in parameters.yml 
    #  e.g. database_path: "%kernel.root_dir%/data/data.db3" 
    # 2. Uncomment database_path in parameters.yml.dist 
    # 3. Uncomment next line: 
    #  path:  "%database_path%" 

    orm: 
     auto_generate_proxy_classes: "%kernel.debug%" 
     naming_strategy: doctrine.orm.naming_strategy.underscore 
     auto_mapping: true 

# Swiftmailer Configuration 
swiftmailer: 
    transport: "%mailer_transport%" 
    host:  "%mailer_host%" 
    username: "%mailer_user%" 
    password: "%mailer_password%" 
    spool:  { type: memory } 

# Nelmio CORS 
nelmio_cors: 
    defaults: 
     allow_origin: ["%cors_allow_origin%"] 
     allow_methods: ["POST", "PUT", "GET", "DELETE", "OPTIONS"] 
     allow_headers: ["content-type", "authorization"] 
     expose_headers: ["link"] 
     max_age:  3600 
    paths: 
     '^/': ~ 

fos_user: 
    db_driver: orm # other valid values are 'mongodb' and 'couchdb' 
    firewall_name: main 
    user_class: AppBundle\Entity\User 
    from_email: 
     address: [email protected] 
     sender_name: noreplay 

lexik_jwt_authentication: 
    private_key_path: '%jwt_private_key_path%' 
    public_key_path: '%jwt_public_key_path%' 
    pass_phrase:  '%jwt_key_pass_phrase%' 
    token_ttl:  '%jwt_token_ttl%' 

のrouting.yml

api: 
    resource: '.' 
    type:  'api_platform' 

app: 
    resource: '@AppBundle/Action/' 
    type:  'annotation' 

fos_user: 
    resource: "@FOSUserBundle/Resources/config/routing/all.xml" 

login_check: 
    path: /login_check 
+0

parameters.ymlの中にフィールドjwt_key_pass_phraseを挿入しましたか? –

+0

@AlessandroMinoccheriはい私はそれは彼が値を持っていない jwt_key_pass_phrase: '' – Achraf

+0

これを起動したとき:openssl genrsa -out var/jwt/private.pem -aes256 4096 parameters.ymlで完了しましたか? –

答えて

0

あなたがLexikJWTAuthenticatioBundleをインストールすると、あなたのコンソール

$ openssl genrsa -out var/jwt/private.pem -aes256 4096 
$ openssl rsa -pubout -in var/jwt/private.pem -out var/jwt/public.pem 

からこのコマンドを起動する必要があります変数:jwt_key_pass_phrase

Like thi S:

jwt_key_pass_phrase: '' 
0

これは本当に、APIプラットフォームにリンクされていないので、あなたがLexikJWTAuthenticationBundleのドキュメントに直接確認する必要があります。

秘密鍵が間違っている可能性があります。

関連する問題