1
- # Authentication
1
+ # Message
2
+
3
+ This package contains various PSR-7 tools which might be useful in an HTTP workflow:
4
+
5
+ * Authentication method implementations
6
+ * Various Stream encoding tools
7
+ * Message decorators
8
+ * Message factory implementations for Guzzle PSR-7 and Diactoros
9
+ * Cookie implementation
10
+
11
+ ## Authentication
2
12
3
13
The Authentication component allows you to to implement authentication methods which can simply update the request
4
14
with authentication detail (for example by adding an ` Authorization ` header).
5
15
This is useful when you have to send multiple requests to the same endpoint. Using an authentication implementation,
6
16
these details can be separated from the actual requests.
7
17
8
18
9
- ## Installation
19
+ ### Installation
10
20
11
21
```
12
22
$ composer require php-http/message
13
23
```
14
24
15
25
16
- ## Authentication methods
26
+ ### Authentication methods
17
27
18
28
Method | Parameters | Behavior
19
29
---------------- | ------------------------------------------------- | --------
@@ -28,15 +38,15 @@ Matching | An authentication instance and a matcher callback | Behavior
28
38
[ 2 ] : http://www.xml.com/pub/a/2003/12/17/dive.html
29
39
30
40
31
- ## Integration with HTTPlug
41
+ ### Integration with HTTPlug
32
42
33
43
Normally requests must be authenticated "by hand" which is not really convenient.
34
44
35
45
If you use HTTPlug, you can integrate this component into the client using the
36
46
[ authentication plugin] ( /httplug/plugins/authentication ) .
37
47
38
48
39
- ## Examples
49
+ ### Examples
40
50
41
51
General usage looks like the following:
42
52
@@ -48,7 +58,7 @@ $authentication->authenticate($request);
48
58
```
49
59
50
60
51
- ### Basic Auth
61
+ #### Basic Auth
52
62
53
63
``` php
54
64
use Http\Message\Authentication\BasicAuth;
@@ -57,7 +67,7 @@ $authentication = new BasicAuth('username', 'password');
57
67
```
58
68
59
69
60
- ### Bearer
70
+ #### Bearer
61
71
62
72
``` php
63
73
use Http\Message\Authentication\Bearer;
@@ -66,7 +76,7 @@ $authentication = new Bearer('token');
66
76
```
67
77
68
78
69
- ### WSSE
79
+ #### WSSE
70
80
71
81
``` php
72
82
use Http\Message\Authentication\Wsse;
@@ -75,7 +85,7 @@ $authentication = new Wsse('username', 'password');
75
85
```
76
86
77
87
78
- ### Query Params
88
+ #### Query Params
79
89
80
90
` http://api.example.com/endpoint?access_token=9zh987g86fg87gh978hg9g79 `
81
91
@@ -94,7 +104,7 @@ $authentication = new QueryParams([
94
104
95
105
96
106
97
- ### Chain
107
+ #### Chain
98
108
99
109
The idea behind this authentication method is that in some cases you might need to
100
110
authenticate the request with multiple methods.
@@ -115,7 +125,7 @@ $authentication = new Chain($authenticationChain);
115
125
```
116
126
117
127
118
- ### Matching
128
+ #### Matching
119
129
120
130
With this authentication method you can conditionally add authentication details to your request by passing a callable
121
131
to it. When a request is passed, the callable is called and used as a boolean value in order to decide whether
@@ -152,7 +162,7 @@ $authentication = Matching::createUrlMatcher(new AuthenticationMethod(), '\/api'
152
162
```
153
163
154
164
155
- ## Implement your own
165
+ ### Implement your own
156
166
157
167
Implementing an authentication method is easy: only one method needs to be implemented.
158
168
0 commit comments