Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
1db3d29e
Commit
1db3d29e
authored
2 years ago
by
Marcus Eibrink-Lunzenauer
Committed by
Jan-Hendrik Willms
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused files, fixes #1485
Closes #1485 Merge request
studip/studip!975
parent
0f4e94db
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/oauth2.php
+0
-105
0 additions, 105 deletions
public/oauth2.php
with
0 additions
and
105 deletions
public/oauth2.php
deleted
100644 → 0
+
0
−
105
View file @
0f4e94db
<?php
use
DI\ContainerBuilder
;
use
Slim\Factory\AppFactory
;
use
Psr\Http\Message\ResponseInterface
as
Response
;
use
Psr\Http\Message\ServerRequestInterface
as
Request
;
use
League\OAuth2\Server\AuthorizationServer
;
use
Studip\OAuth2\AccessTokenRepository
;
use
Studip\OAuth2\AuthCodeRepository
;
use
Studip\OAuth2\ClientRepository
;
use
Studip\OAuth2\ScopeRepository
;
use
Studip\OAuth2\UserEntity
;
require
'../lib/bootstrap.php'
;
require
'../composer/autoload.php'
;
function
addRoutes
(
\Slim\App
$app
,
AuthorizationServer
$server
)
:
void
{
$app
->
get
(
'/authorize'
,
function
(
Request
$request
,
Response
$response
)
use
(
$server
)
{
try
{
// Validate the HTTP request and return an AuthorizationRequest object.
$authRequest
=
$server
->
validateAuthorizationRequest
(
$request
);
// The auth request object can be serialized and saved into a user's session.
// You will probably want to redirect the user at this point to a login endpoint.
$_SESSION
[
'oauth2_auth_request'
]
=
serialize
(
$authRequest
);
var_dump
(
$_SESSION
[
'oauth2_auth_request'
]);
exit
;
// Once the user has logged in set the user on the AuthorizationRequest
$authRequest
->
setUser
(
new
UserEntity
());
// an instance of UserEntityInterface
// At this point you should redirect the user to an authorization page.
// This form will ask the user to approve the client and the scopes requested.
// Once the user has approved or denied the client update the status
// (true = approved, false = denied)
$authRequest
->
setAuthorizationApproved
(
true
);
// Return the HTTP redirect response
return
$server
->
completeAuthorizationRequest
(
$authRequest
,
$response
);
}
catch
(
OAuthServerException
$exception
)
{
// All instances of OAuthServerException can be formatted into a HTTP response
return
$exception
->
generateHttpResponse
(
$response
);
}
catch
(
\Exception
$exception
)
{
// Unknown exception
$body
=
new
Stream
(
fopen
(
'php://temp'
,
'r+'
));
$body
->
write
(
$exception
->
getMessage
());
return
$response
->
withStatus
(
500
)
->
withBody
(
$body
);
}
});
}
$clientRepository
=
new
ClientRepository
();
// instance of ClientRepositoryInterface
$scopeRepository
=
new
ScopeRepository
();
// instance of ScopeRepositoryInterface
$accessTokenRepository
=
new
AccessTokenRepository
();
// instance of AccessTokenRepositoryInterface
$authCodeRepository
=
new
AuthCodeRepository
();
// instance of AuthCodeRepositoryInterface
$refreshTokenRepository
=
new
RefreshTokenRepository
();
// instance of RefreshTokenRepositoryInterface
$privateKey
=
'file://path/to/private.key'
;
//$privateKey = new CryptKey('file://path/to/private.key', 'passphrase'); // if private key has a pass phrase
$encryptionKey
=
'lxZFUEsBCJ2Yb14IF2ygAHI5N4+ZAUXXaSeeJm6+twsUmIen'
;
// generate using base64_encode(random_bytes(32))
// Setup the authorization server
$server
=
new
\League\OAuth2\Server\AuthorizationServer
(
$clientRepository
,
$accessTokenRepository
,
$scopeRepository
,
$privateKey
,
$encryptionKey
);
page_open
([
'sess'
=>
'Seminar_Session'
,
'auth'
=>
'Seminar_Default_Auth'
,
'perm'
=>
'Seminar_Perm'
,
'user'
=>
'Seminar_User'
,
]);
// Set base url for URLHelper class
URLHelper
::
setBaseUrl
(
$GLOBALS
[
'CANONICAL_RELATIVE_PATH_STUDIP'
]);
$containerBuilder
=
new
ContainerBuilder
();
$container
=
$containerBuilder
->
build
();
AppFactory
::
setContainer
(
$container
);
$app
=
AppFactory
::
create
();
$container
->
set
(
\Slim\App
::
class
,
$app
);
$app
->
setBasePath
(
'/oauth2.php'
);
$app
->
addRoutingMiddleware
();
addRoutes
(
$app
,
$server
);
$displayErrors
=
false
;
if
(
defined
(
'\\Studip\\ENV'
))
{
$displayErrors
=
constant
(
'\\Studip\\ENV'
)
===
'development'
;
}
$logError
=
true
;
$logErrorDetails
=
true
;
$errorMiddleware
=
$app
->
addErrorMiddleware
(
$displayErrors
,
$logError
,
$logErrorDetails
);
$app
->
run
();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment