Spring Boot OAuth2和Azure AD

时间:2018-10-03 17:30:26

标签: azure spring-boot

我正在尝试使用连接到Azure AD作为授权服务器的Spring Boot Oauth2配置ResourceServer,所以这是我的application.yml文件:

security:
  oauth2:
    client:
      clientId: xxx
      clientSecret: xxx
    resource:
      security.oauth2.resource.jwk.key-set-uri: https://login.microsoftonline.com/common/discovery/keys
logging:
  level:
    org.springframework.security: debug

但是当我尝试启动我的应用程序时,我得到了:

原因:缺少tokenInfoUri和userInfoUri,并且没有JWT验证程序密钥

但是在Azure AD中,我没有tokenInfoUri,而userInfoUri是:https://graph.microsoft.com/oidc/userinfo,但是我认为它不能帮助客户端凭据流(我的情况)

1 个答案:

答案 0 :(得分:1)

似乎您在SELECT tl.id, tl.name, AVG(pr.rating) AS rating FROM post_rating AS pr LEFT JOIN theList AS tl ON tl.id = pr.postid GROUP BY tl.id, tl.name 的{​​{1}}文件中有错字:

<?php 
$pdo = new PDO('mysql:host=localhost;dbname=myDB', 'root', 'root');
$select = 'SELECT tl.id, 
                  tl.name, 
                  AVG(pr.rating) AS rating ';

$from = ' FROM post_rating AS pr ';
$where = ' WHERE 1 = 1 ';
$join = ' LEFT JOIN theList AS tl ON tl.id = pr.postid ';
$opts = isset($_POST['filterOpts'])? $_POST['filterOpts'] : array('');
if (in_array("pub", $opts)){
    $where .= " AND pub = 1";
}
if (in_array("bar", $opts)){
    $where .= " AND bar = 1";
}
if (in_array("restaurant", $opts)){
    $where .= " AND restaurant = 1";
}
if (in_array("club", $opts)){
    $where .= " AND club = 1";
}

$group = ' GROUP BY tl.id, tl.name ';

$sql = $select . $from . $join . $where . $group;
$statement = $pdo->prepare($sql);
$statement->execute();
$results = $statement->fetchAll(PDO::FETCH_ASSOC);
$json = json_encode($results);
echo($json);
?>