php


Header can not set - SlimFramework


I have the same problem again.
Old post here
I have a angular app and SlimFramework for api connect.
Local it works fine but when i publish to my Website come the error that my Header no set.
But the info on the API testing tool says it's allowed from * IP.
Can someone help me?
Here a valid token: Basic TyOSZcfBwMC6DR9kbAWeMnPmhF4ohZu2n9LccQEyt6uXNt8PTT
Thx
$app = new \Slim\App(["settings" => $config]);
$container = $app->getContainer();
$app->options('/{routes:.+}', function ($request, $response, $args) {
return $response;
});
$app->add(function ($req, $res, $next) {
$response = $next($req, $res);
return $response
->withHeader('Access-Control-Allow-Origin', '*')
->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization')
->withHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, DELETE, PUT');
});
$container['logger'] = function($c) {
$logger = new \Monolog\Logger('my_logger');
$file_handler = new \Monolog\Handler\StreamHandler("../../logs/app.log");
$logger->pushHandler($file_handler);
return $logger;
};
$app->get('/token', function ($request, $response){
$db = new DbOperation();
if (!$request->hasHeader('Authorization')) {
return $response->withJson([
"success"=> false,
"message" => "Header not set.",
"textcode"=> "MSG2"
], 401);
}
$token = $request->getHeader('Authorization');
if($db->checkToken($token[0])){
$user = $db->userInfo($token[0]);
if($db->checkActivate($user['auth_user'])){
if($db->checkExpired($user['auth_user'])){
return $response->withJson([
"success"=> false,
"message" => "The validity of the login has expired. If you have any questions, please contact the administrator..",
"textcode"=> "MSG6"
], 401);
} else {
return $response->withJson(["success"=> true], 200);
}
} else {
return $response->withJson([
"success"=> false,
"message" => "This account has not yet been activated.",
"textcode"=> "MSG8"
], 401);
}
} else {
return $response->withJson([
"success"=> false,
"message"=>'Invalid token',
"textcode"=> "MSG1"
], 403);
}
});
Your basic auth credentials do not decode into anything meaningful. PHP tends to silently ignore Authorization headers which it thinks are malformed. Try with something like Basic dGVzdDp0ZXN0 which decodes into test:test.
Workaround for this has however been added to Slim starting from version 3.5.0. Upgrading your Slim installation might also help.

Related Links

Notification service is not working
how to give pagination to the database table in php
I have tons of UInt8 data that is a picture. How do I create an image from this?
Google push.webhookUrlUnauthorized Error
how to access database on windows server 2012 r2 from local machine using xampp?
VirtueMart 3.0.x Payment Plugin won't get configs
Soap call failed
Drupal Custom registration form save
Dropzone.js not submitting files
How do you obtain the user's ip address for the google reCAPTCHA request? PHP Laravel 5
Horizontal scale menu in wordpress
how can I use multiple attributes in params condition in Yii Framework
Php multidimensional array get value from arrays with different keys
array 2d Multidimensional and insert distance on arraymultidemensional array
Using the Canvas API to determine if an account belongs to a student or not [closed]
Losing Session when get request header is too long

Categories

HOME
google-chrome
openshift
windows-8.1
opencv-python
add-on
nsview
adobe
celery
liferay-7
dependencies
sentry
angular-meteor
telegraf
stimulsoft
squid
synthesis
vmware-workstation
vertica
varnish-vcl
wsf
adminlte
qa
software-packaging
background-color
history.js
react-bootstrap-table
iwebbrowser2
sales
ibm-connections
windowsiot
riotjs
om-next
spring-rabbitmq
grails-2.5
dreamfactory
des
testlink
forms-authentication
macports
identify
iscroll
rdp
robust
git-tfs
type-inference
vesta
common-table-expression
absolute
ssi
aws-kinesis-firehose
redisson
scala-collections
business-rules
kendo-treeview
openerp-6
jpda
wininet
right-to-left
odp.net-managed
exists
perceptron
android-studio-import
apple
shoes
gflags
signed
igor
webmethod
aho-corasick
accessory
nachos
sqlbindparameter
miglayout
nosql-aggregation
cloo
xsd2code
ax
insertion
microformats
flv
notin
daap
jdom
nsfont
algol68
boost-foreach
space-partitioning
uipasteboard
multiple-users
ixmldomdocument
projectpier
autobench
stretchblt

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App