1 | <?php |
||
34 | class AuthController extends AbstractController |
||
35 | { |
||
36 | /** |
||
37 | * Try to validate the user from the request and return a jwt authentication result then. |
||
38 | * |
||
39 | * @param Request $request The request. |
||
40 | * |
||
41 | * @return JsonResponse |
||
42 | * |
||
43 | * @throws \RuntimeException For invalid user classes. |
||
44 | * |
||
45 | * @ApiDoc( |
||
46 | * section="auth", |
||
47 | * statusCodes = { |
||
48 | * 200 = "When everything worked out ok", |
||
49 | * 401 = "When the request was unauthorized." |
||
50 | * }, |
||
51 | * parameters = { |
||
52 | * { |
||
53 | * "name": "ttl", |
||
54 | * "dataType" = "string", |
||
55 | * "format" = "\d+", |
||
56 | * "description" = "The amount of seconds the token shall be valid or -1 for unlimited (default: 3600).", |
||
57 | * "required" = false |
||
58 | * }, |
||
59 | * { |
||
60 | * "name": "username", |
||
61 | * "dataType" = "string", |
||
62 | * "description" = "The username.", |
||
63 | * "required" = true |
||
64 | * }, |
||
65 | * { |
||
66 | * "name": "password", |
||
67 | * "dataType" = "string", |
||
68 | * "description" = "The pssword.", |
||
69 | * "required" = true |
||
70 | * } |
||
71 | * } |
||
72 | * ) |
||
73 | * @ApiDescription( |
||
74 | * response={ |
||
75 | * "status" = { |
||
76 | * "dataType" = "choice", |
||
77 | * "description" = "OK or unauthorized", |
||
78 | * "format" = "['OK', 'unauthorized']", |
||
79 | * }, |
||
80 | * "token" = { |
||
81 | * "dataType" = "string", |
||
82 | * "description" = "The JWT (only if status ok).", |
||
83 | * }, |
||
84 | * "acl" = { |
||
85 | * "actualType" = "collection", |
||
86 | * "subType" = "string", |
||
87 | * "description" = "The roles of the authenticated user.", |
||
88 | * }, |
||
89 | * "username" = { |
||
90 | * "actualType" = "string", |
||
91 | * "description" = "The username of the authenticated user.", |
||
92 | * }, |
||
93 | * }, |
||
94 | * ) |
||
95 | */ |
||
96 | public function checkAuthAction(Request $request) |
||
123 | |||
124 | /** |
||
125 | * Determine the life time for the token. |
||
126 | * |
||
127 | * This examines the GET parameters if a field "ttl" has been set. |
||
128 | * If not, it examines the JSON post data for a field named ttl. |
||
129 | * |
||
130 | * @param Request $request The request. |
||
131 | * |
||
132 | * @return int|null |
||
133 | */ |
||
134 | private function determineLifeTime(Request $request) |
||
151 | |||
152 | /** |
||
153 | * Return the value if it is different than -1, null otherwise. |
||
154 | * |
||
155 | * @param int $lifetime The life time. |
||
156 | * |
||
157 | * @return null|int |
||
158 | */ |
||
159 | private function revertToNullOnMinusOne($lifetime) |
||
167 | } |
||
168 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.