OAUTH SUPPORT
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use support\Request;
|
||||
|
||||
class Listen
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
#id=ca657d42-4821-418e-b1d3-36fa246868ff
|
||||
#key=gto_w2bjzeqkh7kfk3k2og7vpzkanwnq3e2jegsntenuzc2upolo7qda
|
||||
#https://git.laysense.com/login/oauth/authorize?client_id=ca657d42-4821-418e-b1d3-36fa246868ff&redirect_uri=https://auth.laysense.cn/listen&response_type=code&scope=openid&state=a261cb03-618a-44e2-ab76-099585dbc4c9
|
||||
print_r($request);
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
public function view(Request $request)
|
||||
{
|
||||
return view('index/view', ['name' => 'webman']);
|
||||
}
|
||||
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Db;
|
||||
use Firebase\JWT\JWT;
|
||||
use Firebase\JWT\Key;
|
||||
|
||||
class OAuth
|
||||
{
|
||||
public function authorize(Request $request)
|
||||
{
|
||||
$appid=$request->get('client_id','null');
|
||||
if($appid=='null'){
|
||||
return view('404');
|
||||
}
|
||||
$appquery= Db::table('App')->where('oauthid', $appid);
|
||||
if($appquery->doesntExist()){
|
||||
return view('404');
|
||||
}
|
||||
$app=$appquery->first();
|
||||
$provider= Db::table('Provider')->where('ID', $app->provider)->first();
|
||||
$redirect=$request->get('redirect_uri','null');
|
||||
if($redirect=='null'){
|
||||
$redirect=$app->redirect;
|
||||
}
|
||||
return redirect($redirect.'?code=123456&state='.$request->get('state',''));
|
||||
#return view('auth', ['app'=>$app,'provider'=>$provider]);
|
||||
}
|
||||
|
||||
public function configfile(Request $request)
|
||||
{
|
||||
|
||||
return json([
|
||||
"issuer" => 'https://'.getenv('weburl').'/',
|
||||
"authorization_endpoint" => 'https://'.getenv('weburl').'/auth/oauth/authorize',
|
||||
"token_endpoint" => 'https://'.getenv('weburl').'/auth/oauth/token',
|
||||
"userinfo_endpoint" => 'https://'.getenv('weburl').'/auth/oauth/userinfo',
|
||||
"response_types_supported" => ["code"],
|
||||
"subject_types_supported" => ["public"],
|
||||
"id_token_signing_alg_values_supported" => ["RS256"],
|
||||
"scopes_supported" => ["openid", "profile", "email", "phone"],
|
||||
"token_endpoint_auth_methods_supported" => ["client_secret_basic"],
|
||||
"claims_supported" => ["sub", "iss", "name", "email", "phone"],
|
||||
"code_challenge_methods_supported" => ["plain", "S256"],
|
||||
"grant_types_supported" => ["authorization_code", "refresh_token"],
|
||||
]);
|
||||
}
|
||||
|
||||
public function token(Request $request)
|
||||
{
|
||||
$key = 'b662c3012510ef3105e557b7b1db0805fb012911';
|
||||
$payload = [
|
||||
'iss' => 'https://auth.laysense.cn/',
|
||||
'aud' => 'laysensegit',
|
||||
'sub' => 'ywnsya',
|
||||
'iat' => time(),
|
||||
'nbf' => time()+7200,
|
||||
'exp' => time()+7200,
|
||||
'LaysenseRole' => 'Member',
|
||||
];
|
||||
$jwt = JWT::encode($payload, $key, 'HS256');
|
||||
|
||||
return json([
|
||||
"access_token" => 'x48KsWYMGBNU3RVSs2vBkjFKTZQZF5vTMiMmyTUiZ0dvXTuodZzWUXIAt2CllbGKHob_ALaE',
|
||||
"id_token" => $jwt,
|
||||
"token_type" => 'Bearer',
|
||||
"expires_in" => 7200,
|
||||
"scope"=>"openid profile email photo"
|
||||
])->withHeaders([
|
||||
'Cache-Control' => 'no-store',
|
||||
'Pragma' => 'no-cache',
|
||||
]);
|
||||
|
||||
}
|
||||
public function userinfo(Request $request)
|
||||
{
|
||||
return json([
|
||||
"sub" => 'ywnsya',
|
||||
"name" => 'LaySense',
|
||||
"email" => 'ywnsya@126.com',
|
||||
"phone" => '18018526850',
|
||||
"LaysenseRole" => 'Member',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleware;
|
||||
|
||||
use Webman\MiddlewareInterface;
|
||||
use Webman\Http\Response;
|
||||
use Webman\Http\Request;
|
||||
|
||||
|
||||
class Listen implements MiddlewareInterface
|
||||
{
|
||||
public function process(Request $request, callable $next): Response
|
||||
{
|
||||
print_r($request);
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
<link rel="stylesheet" href="https://static.laysense.cn/data/file/cdn/preline.css">
|
||||
</head>
|
||||
|
||||
<body class="flex h-full items-center py-16 dark:bg-neutral-800" background="https://bing.img.run/1920x1080.php">
|
||||
<body class="flex h-full items-center py-16 dark:bg-neutral-800" background="https://bing.img.run/1920x1080.php" style="background-size: 100% 100%;">
|
||||
<!-- ========== MAIN CONTENT ========== -->
|
||||
<main id="content" class="w-full max-w-md mx-auto p-6">
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" class="h-full">
|
||||
<head>
|
||||
<!-- Required Meta Tags Always Come First -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="description" content="Laysense Auth">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<title>Laysense Auth</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="https://static.laysense.cn/data/file/_4335ce.png?1709117691655">
|
||||
|
||||
<!-- Font -->
|
||||
|
||||
<!-- Theme Check and Update -->
|
||||
<script>
|
||||
const html = document.querySelector('html');
|
||||
const isLightOrAuto = localStorage.getItem('hs_theme') === 'light' || (localStorage.getItem('hs_theme') === 'auto' && !window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
const isDarkOrAuto = localStorage.getItem('hs_theme') === 'dark' || (localStorage.getItem('hs_theme') === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
|
||||
if (isLightOrAuto && html.classList.contains('dark')) html.classList.remove('dark');
|
||||
else if (isDarkOrAuto && html.classList.contains('light')) html.classList.remove('light');
|
||||
else if (isDarkOrAuto && !html.classList.contains('dark')) html.classList.add('dark');
|
||||
else if (isLightOrAuto && !html.classList.contains('light')) html.classList.add('light');
|
||||
</script>
|
||||
|
||||
<!-- CSS HS -->
|
||||
<link rel="stylesheet" href="https://static.laysense.cn/data/file/cdn/preline.css">
|
||||
</head>
|
||||
|
||||
<body class="flex h-full items-center py-16 dark:bg-neutral-800" background="https://bing.img.run/1920x1080.php" style="background-size: 100% 100%;">
|
||||
<!-- ========== MAIN CONTENT ========== -->
|
||||
<main id="content" class="w-full max-w-md mx-auto p-6">
|
||||
|
||||
<div class="mt-7 border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-900 dark:border-neutral-700" style="background: rgba(255, 255, 255, 0.6);-webkit-backdrop-filter: blur(10px);backdrop-filter: blur(10px);">
|
||||
<div class="p-4 sm:p-7">
|
||||
<div class="text-center">
|
||||
<h1 class="block text-2xl font-bold text-gray-800 dark:text-white" ><img src="https://static.laysense.cn/data/file/laysenseW.png" style="height:30px;" />应用不支持当前的登陆方式</h1>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-neutral-400">
|
||||
抱歉,该应用注册表内拒绝了这种认证方式,您可以选择
|
||||
<a class="text-blue-600 decoration-2 hover:underline focus:outline-none focus:underline font-medium dark:text-blue-500" href="https://laysense.cn/" target="_blank">
|
||||
前往来笙
|
||||
</a>
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mt-3 flex justify-center items-center text-center divide-x divide-gray-300 dark:divide-neutral-700">
|
||||
©上海来笙信息科技有限公司 2024 </p>
|
||||
|
||||
</main>
|
||||
<!-- ========== END MAIN CONTENT ========== -->
|
||||
|
||||
<!-- JS Implementing Plugins -->
|
||||
|
||||
<!-- JS PLUGINS -->
|
||||
<!-- Required plugins -->
|
||||
<script src="https://static.laysense.cn/data/file/cdn/preline.js"></script>
|
||||
|
||||
<!-- JS THIRD PARTY PLUGINS -->
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user