归档
This commit is contained in:
59
includes/auth/appmaster.php
Normal file
59
includes/auth/appmaster.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace auth;
|
||||
|
||||
class appmaster
|
||||
{
|
||||
/**
|
||||
* 注册应用
|
||||
* @param $appid
|
||||
* @param $apppwd
|
||||
* @param $url
|
||||
* @param $type
|
||||
* @param $scope
|
||||
* @param $userid
|
||||
* @param $name
|
||||
* @param $home
|
||||
* @param $present
|
||||
* @return array|false|mixed|string
|
||||
*/
|
||||
public function reg($appid,$apppwd,$url,$type=null,$scope=null,$userid,$name,$home,$present){
|
||||
global $authsql;
|
||||
return $authsql->insert('oauth_clients',[
|
||||
'client_id'=>$appid,
|
||||
'client_secret'=>$apppwd,
|
||||
'redirect_uri'=>$url,
|
||||
'grant_types'=>$type,
|
||||
'scope'=>$scope,
|
||||
'user_id'=>$userid,
|
||||
'name'=>$name,
|
||||
'home'=>$home,
|
||||
'present'=>$present,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除应用
|
||||
* @param $id
|
||||
* @return false|int
|
||||
*/
|
||||
public function del($id){
|
||||
global $authsql;
|
||||
return $authsql->delete('oauth_clients',[
|
||||
'id'=>$id
|
||||
]);
|
||||
}
|
||||
|
||||
public function edit($appid,$name,$home,$domain,$present){
|
||||
global $authsql;
|
||||
return $authsql->update('oauth_clients',[
|
||||
'name'=>$name,
|
||||
'home'=>$home,
|
||||
"redirect_uri"=>$domain,
|
||||
"present"=>$present
|
||||
],[
|
||||
"client_id"=>$appid
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
46
includes/auth/oauthapps.php
Normal file
46
includes/auth/oauthapps.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace auth;
|
||||
|
||||
class oauthapps
|
||||
{
|
||||
/**
|
||||
* 获取某个一行用的全部信息(给授权页用的)
|
||||
* @param $client_id
|
||||
* @return false|mixed
|
||||
*/
|
||||
public function info($client_id){
|
||||
global $authsql;
|
||||
return $authsql->get('oauth_clients',"*",[
|
||||
"client_id"=>$client_id
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用列表
|
||||
* @return string
|
||||
*/
|
||||
public function lists(){
|
||||
global $authsql;
|
||||
$info=$authsql->select('oauth_clients',"*");
|
||||
$infonum=count($info);
|
||||
$appinfo='';
|
||||
for ($i=0;$i<$infonum;$i++){
|
||||
$appinfo=$appinfo.'<tr><td>
|
||||
<input type="checkbox" /></td>
|
||||
<td>'.$info[$i]['id'].'</td>
|
||||
<td>'.$info[$i]['name'].'</td>
|
||||
<td>'.$info[$i]['client_id'].'</td>
|
||||
<td>'.$info[$i]['client_secret'].'</td>
|
||||
<td>'.$info[$i]['redirect_uri'].'</td>
|
||||
<td>
|
||||
<div class="am-btn-toolbar">
|
||||
<div class="am-btn-group am-btn-group-xs">
|
||||
<a href="/oauth2/auth.php?response_type=code&client_id='.$info[$i]['client_id'].'&redirect_uri='.urlencode('http://'.$info[$i]['redirect_uri'].'/index.php?type=submit').'&scope=base&state=123" target="_blank" class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 前往授权页</a>
|
||||
<a href="./appedit.html?client_id='.$info[$i]['client_id'].'" class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 编辑</a>
|
||||
<a href="./appsubmit.html?m=del&id='.$info[$i]['id'].'" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"><span class="am-icon-pencil-square-o"></span> 删除</a>';
|
||||
$appinfo=$appinfo.'</div></div></td></tr>';
|
||||
}
|
||||
return $appinfo;
|
||||
}
|
||||
}
|
||||
93
includes/auth/scope.php
Normal file
93
includes/auth/scope.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace auth;
|
||||
|
||||
class scope
|
||||
{
|
||||
/**
|
||||
* 显示权限信息
|
||||
* @param $scope
|
||||
* @return mixed
|
||||
*/
|
||||
public function see($scope){
|
||||
global $authsql;
|
||||
$scopes=$authsql->select("oauth_scopes",'*',[
|
||||
"scope"=>$scope
|
||||
]);
|
||||
return $scopes[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限列表
|
||||
* @return string
|
||||
*/
|
||||
public function authlist(){
|
||||
global $authsql;
|
||||
$info=$authsql->select("oauth_scopes",'*');
|
||||
$infonum=count($info);
|
||||
$appinfo='';
|
||||
for ($i=0;$i<$infonum;$i++){
|
||||
$appinfo=$appinfo.'<tr><td>
|
||||
<input type="checkbox" /></td>
|
||||
<td>'.$info[$i]['id'].'</td>
|
||||
<td>'.$info[$i]['scope'].'</td>
|
||||
<td>'.$info[$i]['name'].'</td>
|
||||
<td>'.$this->def($info[$i]['is_default']).'</td>
|
||||
<td>
|
||||
<div class="am-btn-toolbar">
|
||||
<div class="am-btn-group am-btn-group-xs">
|
||||
<a href="./scopenew.html?m=edit&scope='.$info[$i]['scope'].'" class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 编辑</a>';
|
||||
$appinfo=$appinfo.'</div></div></td></tr>
|
||||
';
|
||||
}
|
||||
return $appinfo;
|
||||
}
|
||||
private function def($v){
|
||||
if($v==1){
|
||||
return '是';
|
||||
}else{
|
||||
return "否";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限注册
|
||||
* @param $scope
|
||||
* @param $name
|
||||
* @param $def
|
||||
* @return array|false|mixed|string
|
||||
*/
|
||||
public function reg($scope,$name,$def=0){
|
||||
global $authsql;
|
||||
return $authsql->insert("oauth_scopes",[
|
||||
"scope"=>$scope,
|
||||
"is_default"=>$def,
|
||||
"name"=>$name
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 引用更新
|
||||
* @param $scope
|
||||
* @param $name
|
||||
* @param $def
|
||||
* @return false|int
|
||||
*/
|
||||
public function edit($scope,$name,$def){
|
||||
global $authsql;
|
||||
if (!empty($def)){
|
||||
return $authsql->update("oauth_scopes",[
|
||||
"is_default"=>$def,
|
||||
"name"=>$name
|
||||
],[
|
||||
"scope"=>$scope
|
||||
]);
|
||||
}else{
|
||||
return $authsql->update("oauth_scopes",[
|
||||
"name"=>$name
|
||||
],[
|
||||
"scope"=>$scope
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user