File tree Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -2,3 +2,70 @@ ApiKey Bundle
22=============
33
44Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.
5+
6+
7+ ## Installation
8+
9+ Requires composer, install as follows
10+
11+ ``` sh
12+ composer require uecode/api-key-bundle dev-master
13+ ```
14+
15+ #### Enable Bundle
16+
17+ Place in your ` AppKernel.php ` to enable the bundle
18+
19+ ``` php
20+ <?php
21+ // app/AppKernel.php
22+
23+ public function registerBundles()
24+ {
25+ $bundles = array(
26+ // ...
27+ new Uecode\Bundle\ApiKeyBundle\UecodeApiKeyBundle(),
28+ );
29+ }
30+ ```
31+ #### Entities
32+
33+ Assuming you already have a ` User ` class that extends the ` FOSUserBundle ` 's base user model,
34+ change that extend, so its extending ` Uecode\Bundle\ApiKeyBundle\Model\ApiKeyUser `
35+
36+ Then update your schema.
37+
38+ #### Set up security
39+
40+ In your security, change your provider to the service ` uecode.api_key.provider.user_provider `
41+
42+ ``` yml
43+ security :
44+ providers :
45+ db :
46+ id : uecode.api_key.provider.user_provider
47+
48+ # Or
49+
50+ providers :
51+ chain_provider :
52+ chain :
53+ providers : [db, memory]
54+ memory : # .....
55+ db :
56+ id : uecode.api_key.provider.user_provider
57+ ` ` `
58+
59+ After adding that, you can now add ` api_key: true`, and `stateless: true` to any of your firewalls.
60+
61+ For Example :
62+
63+ ` ` ` yml
64+ security:
65+ firewalls:
66+ auth:
67+ pattern: ^/api/*
68+ api_key: true
69+ stateless: true
70+
71+ ` ` `
You can’t perform that action at this time.
0 commit comments