initial
This commit is contained in:
+19
-16
@@ -26,6 +26,7 @@
|
||||
|
||||
<cfset this.defaultdatasource = this.datasource/>
|
||||
<cfset request.DS = "#this.datasource#">
|
||||
<cfset request.language="">
|
||||
<!--- кажется, нужно инициализировать датасорцы в псевдоконструкторе - onRequest не получается --->
|
||||
<!--- <cfset this.datasources["#this.datasource#"]=getDS("#this.datasource#","ds_#this.datasource#")/> --->
|
||||
|
||||
@@ -127,20 +128,20 @@
|
||||
Вообще не следует ничего блокировать на время сетевого взаимодействия
|
||||
Нижеследующая, на первый взгляд, странная конструкция ровно для этого придумана
|
||||
--->
|
||||
<cfoutput>onRequest:check for cert started #(getTickCount()-request.startTickCount)#</cfoutput>
|
||||
<!--- <cfoutput>onRequest:check for cert started #(getTickCount()-request.startTickCount)#</cfoutput> --->
|
||||
<cfset var idpCertificateExists = false/>
|
||||
<cflock scope="application" type="readonly" timeout=1>
|
||||
<cfset request.APP_NAME=this.Name/>
|
||||
<cfset idpCertificateExists = structKeyExists(application,"idpCertificate")/>
|
||||
</cflock>
|
||||
<cfif NOT idpCertificateExists>
|
||||
Obtain IDP Certificate (onRequest)
|
||||
<!--- Obtain IDP Certificate (onRequest) --->
|
||||
<cfset var idpCertificate = getIdpCertificate(this.idpCertUrl) />
|
||||
<cflock scope="application" type="exclusive" timeout=1>
|
||||
<cfset application.idpCertificate = idpCertificate/>
|
||||
</cflock>
|
||||
</cfif>
|
||||
<cfoutput>onRequest:check for cert finished #(getTickCount()-request.startTickCount)#</cfoutput>
|
||||
<!--- <cfoutput>onRequest:check for cert finished #(getTickCount()-request.startTickCount)#</cfoutput> --->
|
||||
|
||||
|
||||
<cfset this.redirect_uri = "https://#CGI.SERVER_NAME#/#CGI.SCRIPT_NAME#" />
|
||||
@@ -152,24 +153,26 @@
|
||||
|
||||
<!--- SSO --->
|
||||
<cflock scope="session" type="exclusive" timeout="3">
|
||||
<!--- --->
|
||||
<!---
|
||||
<cfdump var=#session#/>
|
||||
<cfoutput>#(getTickCount()-request.startTickCount)#</cfoutput>
|
||||
<cfoutput>#(getTickCount()-request.startTickCount)#</cfoutput>--->
|
||||
<!---
|
||||
Это первая проба, с сессией
|
||||
Когда протухнет сессия, мы можем пойти к IDP и повторно аутентифицироваться. Поскольку у нас сохраняются куки IDP, его сессия, возможно, будет жива. Если мы обновляли сессию IDP в другом приложении SSO, по всей видимости, она будет продолжаться. Если мы видим, что сессия IDP состарилась и хочет протухнуть, мы можем ее освежить и получить новый access token (который мы пока не используем - мы пользуемся ответом IDP) Наверное, правильно обходиться для этих целей вообще без сессии *** --->
|
||||
<!---
|
||||
сделать логаут
|
||||
сделать отображение ошибки IDP?
|
||||
+сделать получение сертификата
|
||||
сделать рефреш
|
||||
проверить sso
|
||||
? сделать рефреш
|
||||
? сделать логаут
|
||||
? сделать отображение ошибки IDP
|
||||
+ сделать получение сертификата
|
||||
|
||||
--->
|
||||
<cfif structKeyExists(session, "auth")>
|
||||
<cfset request.auth = structCopy(session.auth)/>
|
||||
<!--- тут нужно сделать проверку и рефреш токена --->
|
||||
сессия есть
|
||||
<!--- сессия есть --->
|
||||
<cfelse>
|
||||
сессии нет
|
||||
<!--- сессии нет --->
|
||||
<cfset session.auth_state=createGUID().toString()/>
|
||||
|
||||
<cfscript>
|
||||
@@ -183,9 +186,9 @@
|
||||
может быть, KeyCloak так защищается от циклических редиректов
|
||||
Не очень понятно, как предотвратить повторный запрос (можно, конечно, использовать сессию, но странно)
|
||||
*/
|
||||
writeOutput(getTickCount()-request.startTickCount);
|
||||
//writeOutput(getTickCount()-request.startTickCount);
|
||||
if(structKeyExists(url, "code")) { //обрабатываем редирект от IDP *** наличие поля code в URL введет нас в заблуждение, но эvar = data, label =то только без валидной сессии
|
||||
dump(var = url.code, label = "URL.code");
|
||||
//dump(var = url.code, label = "URL.code");
|
||||
// Request access token from idp with the
|
||||
// authorization code that we got via the URL
|
||||
//aFormFields = [];
|
||||
@@ -196,13 +199,13 @@
|
||||
resp = idp.makeAccessTokenRequest(url.code/*, aFormFields*/);
|
||||
writeOutput("idp.makeAccessTokenRequest Done");
|
||||
writeOutput(getTickCount()-request.startTickCount);
|
||||
dump(resp);
|
||||
//dump(resp);
|
||||
data = deserializeJson(resp.content);
|
||||
//writedump(data);
|
||||
// Print full response from idp
|
||||
dump(var = data, label = "makeAccessTokenRequest - Response from idp");
|
||||
//dump(var = data, label = "makeAccessTokenRequest - Response from idp");
|
||||
|
||||
echo('<a href="./index.cfm?refresh=#data.refresh_token#">Refresh token #data.refresh_token#</a>');
|
||||
//echo('<a href="./index.cfm?refresh=#data.refresh_token#">Refresh token #data.refresh_token#</a>');
|
||||
|
||||
session.auth.expires_in = data.expires_in;
|
||||
session.auth.refresh_expires_in = data.refresh_expires_in;
|
||||
|
||||
Reference in New Issue
Block a user