Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Σταύρος Παπαδάκης
e-epal
Commits
d8fec8b5
Commit
d8fec8b5
authored
Feb 21, 2017
by
Χάρης Παπαδόπουλος
Browse files
registration procedure: WIP
parent
a2ec19ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
drupal/modules/oauthost/src/Authentication/Provider/OAuthOSTConsumer.php
View file @
d8fec8b5
...
...
@@ -183,31 +183,17 @@ class OAuthOSTConsumer implements AuthenticationProviderInterface
$oauth
->
enableDebug
();
$this
->
logger
->
warning
(
"i am here:"
.
"oauthToken="
.
$authToken
.
" state="
.
$_SESSION
[
'state'
]);
if
((
$authToken
==
null
||
!
$authToken
)
&&
!
$_SESSION
[
'state'
])
{
$this
->
logger
->
warning
(
"send request token"
);
$requestToken
=
$oauth
->
getRequestToken
(
$this
->
request_token_url
,
$this
->
callback_url
);
$this
->
logger
->
warning
(
"send request token"
);
$requestToken
=
$oauth
->
getRequestToken
(
$this
->
request_token_url
,
$this
->
callback_url
);
// store auth token
$this
->
logger
->
warning
(
"requestToken="
.
$requestToken
[
'oauth_token_secret'
]);
$_SESSION
[
'secret'
]
=
$requestToken
[
'oauth_token_secret'
];
$_SESSION
[
'state'
]
=
1
;
$this
->
logger
->
warning
(
"requestToken="
.
$requestToken
[
'oauth_token_secret'
]);
$_SESSION
[
'secret'
]
=
$requestToken
[
'oauth_token_secret'
];
$_SESSION
[
'state'
]
=
1
;
// $_SESSION['secret'] = $request_token['oauth_token_secret'];
header
(
'Location: '
.
$this
->
user_authorization_url
.
'?oauth_token='
.
$requestToken
[
'oauth_token'
]);
exit
;
}
else
if
(
$_SESSION
[
'state'
]
==
1
)
{
$oauth
->
setToken
(
$authToken
,
$_SESSION
[
'secret'
]);
$this
->
logger
->
warning
(
"oauthToken="
.
$authToken
.
"***"
.
$_SESSION
[
'secret'
]);
$accessToken
=
$oauth
->
getAccessToken
(
$this
->
access_token_url
,
''
,
$authVerifier
);
$this
->
logger
->
warning
(
"accessToken="
.
$accessToken
[
'oauth_token'
]
.
"***"
.
$accessToken
[
'oauth_token_secret'
]);
$_SESSION
[
'state'
]
=
2
;
$_SESSION
[
'token'
]
=
$accessToken
[
'oauth_token'
];
$_SESSION
[
'secret'
]
=
$accessToken
[
'oauth_token_secret'
];
// $_SESSION['token'] = serialize($access_token);
}
$this
->
logger
->
warning
(
"about to call web service"
);
$oauth
->
setToken
(
$_SESSION
[
'token'
],
$_SESSION
[
'secret'
]);
$oauth
->
fetch
(
$this
->
api_url
);
header
(
'Location: '
.
$this
->
user_authorization_url
.
'?oauth_token='
.
$requestToken
[
'oauth_token'
]);
$this
->
logger
->
warning
(
"redirected to:"
.
$this
->
user_authorization_url
.
'?oauth_token='
.
$requestToken
[
'oauth_token'
]);
exit
;
}
catch
(
OAuthException
$e
)
{
...
...
@@ -221,6 +207,7 @@ class OAuthOSTConsumer implements AuthenticationProviderInterface
// return null;
}
/**
* {@inheritdoc}
*/
...
...
drupal/modules/oauthost/src/Controller/CBController.php
View file @
d8fec8b5
...
...
@@ -9,6 +9,9 @@ use Symfony\Component\HttpFoundation\JsonResponse;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
Drupal\Core\Controller\ControllerBase
;
use
Drupal\Core\Url
;
use
Drupal\oauthost\Authentication\Provider
;
use
OAuth
;
use
OAuthException
;
class
CBController
extends
ControllerBase
{
...
...
@@ -17,6 +20,17 @@ class CBController extends ControllerBase {
protected
$request
;
protected
$logger
;
protected
$consumer_key
=
'tc97t89'
;
protected
$consumer_secret
=
'xr7tgt9AbK3'
;
protected
$request_token_url
=
'https://www1.gsis.gr/gsisapps/gsisdemo/oauth/request_token'
;
protected
$user_authorization_url
=
'https://www1.gsis.gr/gsisapps/gsisdemo/oauth/confirm_access'
;
protected
$access_token_url
=
'https://www1.gsis.gr/gsisapps/gsisdemo/oauth/access_token'
;
protected
$signature_method
=
'PLAINTEXT'
;
protected
$api_url
=
'https://www1.gsis.gr/gsisapps/gsisdemo/gsisdemoservice/resource_one'
;
protected
$callback_url
=
'http://eepal.dev/drupal/oauth/cb'
;
protected
$logout_url
=
'https://www1.gsis.gr/testgsisapps/gsisdemo/logout.htm?logout_token='
;
public
function
__construct
(
EntityTypeManagerInterface
$entityTypeManager
,
QueryFactory
$query_factory
)
{
$this
->
entityTypeManager
=
$entityTypeManager
;
$this
->
query_factory
=
$query_factory
;
...
...
@@ -38,7 +52,58 @@ public function loginCB() {
$this
->
logger
->
notice
(
"authToken="
.
$authToken
.
"***authVerifier="
.
$authVerifier
);
/* $response = new JsonResponse(['hello' => 'world', 'name' => $name, 'authToken' => $authToken, 'accessKey' => $accessKey]);
$response->headers->set('X-AUTH-TOKEN', 'HELLOTOKEN'); */
return
new
RedirectResponse
(
'/dist/#/?auth_token='
.
$authToken
.
'&auth_role=student'
,
302
,[]);
$authenticated
=
$this
->
authenticatePhase2
(
$authToken
,
$authVerifier
);
if
(
$authenticated
)
{
return
new
RedirectResponse
(
'/dist/#/?auth_token='
.
$authToken
.
'&auth_role=student'
,
302
,[]);
}
else
{
return
new
RedirectResponse
(
'/dist/#/'
,
403
,[]);
}
}
public
function
authenticatePhase2
(
$authToken
,
$authVerifier
)
{
try
{
$oauth
=
new
OAuth
(
$this
->
consumer_key
,
$this
->
consumer_secret
,
OAUTH_SIG_METHOD_PLAINTEXT
,
OAUTH_AUTH_TYPE_URI
);
$oauth
->
enableDebug
();
$this
->
logger
->
warning
(
"i am here:"
.
"oauthToken="
.
$authToken
.
" state="
.
$_SESSION
[
'state'
]);
$oauth
->
setToken
(
$authToken
,
$_SESSION
[
'secret'
]);
$this
->
logger
->
warning
(
"oauthToken="
.
$authToken
.
"***"
.
$_SESSION
[
'secret'
]);
$accessToken
=
$oauth
->
getAccessToken
(
$this
->
access_token_url
,
''
,
$authVerifier
);
$this
->
logger
->
warning
(
"accessToken="
.
$accessToken
[
'oauth_token'
]
.
"***"
.
$accessToken
[
'oauth_token_secret'
]);
$_SESSION
[
'state'
]
=
2
;
$_SESSION
[
'token'
]
=
$accessToken
[
'oauth_token'
];
$_SESSION
[
'secret'
]
=
$accessToken
[
'oauth_token_secret'
];
$this
->
logger
->
warning
(
"about to call web service"
);
$oauth
->
setToken
(
$_SESSION
[
'token'
],
$_SESSION
[
'secret'
]);
$oauth
->
fetch
(
$this
->
api_url
);
$this
->
logger
->
warning
(
$oauth
->
getLastResponse
());
$epalUser
=
$this
->
entityTypeManager
()
->
getStorage
(
'epal_users'
)
->
loadByProperties
([
'taxis_userid'
=>
'12345'
]);
if
(
$epalUser
===
null
||
!
$epalUser
)
{
}
return
true
;
}
catch
(
OAuthException
$e
)
{
$this
->
logger
->
warning
(
$e
->
getMessage
());
return
false
;
}
return
false
;
// Check if we found a user.
/* if (!empty($this->user)) {
return $this->user;
} */
// return null;
}
}
source/app.settings.ts
View file @
d8fec8b5
export
class
AppSettings
{
public
static
get
API_ENDPOINT
():
string
{
return
'
http://localhost/drupal
'
;
//
return 'http://eepal.dev/drupal';
//
return 'http://localhost/drupal';
return
'
http://eepal.dev/drupal
'
;
// return 'http://eduslim2.minedu.gov.gr/drupal';
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment