EnvCheckMiddleware

Extends \OCA\Gallery\Middleware\CheckMiddleware

Checks that we have a valid token linked to a valid resource and that the user is authorised to access it

Once all checks have been passed, the environment is ready to use

package

OCA\Gallery\Middleware

Methods

__construct

__construct( $appName, \OCP\IRequest $request, \OCP\IURLGenerator $urlGenerator, \OCP\ILogger $logger) 
inherited

Arguments

$appName

$request

\OCP\IRequest

$urlGenerator

\OCP\IURLGenerator

$logger

\OCP\ILogger

If a CheckException is being caught, clients who sent an ajax requests get a JSON error response while the others are redirected to an error page

afterException( $controller,  $methodName, \Exception $exception) 
inherited
inheritDoc

Arguments

$controller

$methodName

$exception

\Exception

Authenticate link item with the given password or with the session if no password was given.

authenticate(\OCP\Share\IShare $share, string $password) : boolean
Throws
\OCA\Gallery\Middleware\CheckException

Arguments

$share

\OCP\Share\IShare

$password

string

Response

boolean

true if authorized, an exception is raised otherwise

Checks that we have a valid token linked to a valid resource and that the user is authorised to access it

beforeController( $controller,  $methodName) 

Inspects the controller method annotations and if PublicPage is found it checks that we have a token and an optional password giving access to a valid resource. Once that's done, the environment is setup so that our services can find the resources they need.

The checks are not performed on "guest" pages and the environment is not setup. Typical guest pages are anonymous error ages

inheritDoc

Arguments

$controller

$methodName

Checks if a password is required or if the one supplied is working

checkAuthorisation(\OCP\Share\IShare $share, string|null $password) 
Throws
\OCA\Gallery\Middleware\CheckException

Arguments

$share

\OCP\Share\IShare

$password

string|null

optional password

Makes sure an item type was set for that token

checkItemType(\OCP\Share\IShare $share) 
Throws
\OCA\Gallery\Middleware\CheckException

Arguments

$share

\OCP\Share\IShare

Validates the given password

checkPassword(\OCP\Share\IShare $share, string $password) 
fixme

@LukasReschke says: Migrate old hashes to new hash format Due to the fact that there is no reasonable functionality to update the password of an existing share no migration is yet performed there. The only possibility is to update the existing share which will result in a new share ID and is a major hack.

In the future the migration should be performed once there is a proper method to update the share's password. (for example $share->updatePassword($password)

link

https://github.com/owncloud/core/issues/10671

Throws
\OCA\Gallery\Middleware\CheckException

Arguments

$share

\OCP\Share\IShare

$password

string

Makes sure the user is already properly authenticated when a password is required and none was provided

checkSession(\OCP\Share\IShare $share) 
Throws
\OCA\Gallery\Middleware\CheckException

Arguments

$share

\OCP\Share\IShare

Makes sure that the token contains all the information that we need

checkShareIsValid(\OCP\Share\IShare $share, string $token) 
Throws
\OCA\Gallery\Middleware\CheckException

Arguments

$share

\OCP\Share\IShare

$token

string

Decides which type of response to send

computeResponse(string $message, integer $code) : \OCP\AppFramework\Http\JSONResponse|\OCP\AppFramework\Http\RedirectResponse|\OCP\AppFramework\Http\TemplateResponse
inherited

Arguments

$message

string

$code

integer

Response

\OCP\AppFramework\Http\JSONResponse|\OCP\AppFramework\Http\RedirectResponse|\OCP\AppFramework\Http\TemplateResponse

Validates a token to make sure its linked to a valid resource

getShare(string $token) : \OCP\Share\IShare

Uses Share 2.0

fixme

setIncognitoMode in 8.1 https://github.com/owncloud/core/pull/12912

Throws
\OCA\Gallery\Middleware\CheckException

Arguments

$token

string

Response

\OCP\Share\IShare

Redirects the client to an error page

redirectToErrorPage(string $message, integer $code) : \OCP\AppFramework\Http\RedirectResponse
inherited

Arguments

$message

string

$code

integer

Response

\OCP\AppFramework\Http\RedirectResponse

Shows an authentication form

sendHtml401() : \OCP\AppFramework\Http\TemplateResponse
inherited

Response

\OCP\AppFramework\Http\TemplateResponse

Redirects the client to an error page or shows an authentication form

sendHtmlResponse(string $message, integer $code) : \OCP\AppFramework\Http\RedirectResponse|\OCP\AppFramework\Http\TemplateResponse
inherited

Arguments

$message

string

$code

integer

Response

\OCP\AppFramework\Http\RedirectResponse|\OCP\AppFramework\Http\TemplateResponse

Returns a JSON response to the client

sendJsonResponse(string $message, integer $code) : \OCP\AppFramework\Http\JSONResponse
inherited

Arguments

$message

string

$code

integer

Response

\OCP\AppFramework\Http\JSONResponse

Checks that we have a token and an optional password giving access to a valid resource. Sets the token based environment after that

validateAndSetTokenBasedEnv() 
Throws
\OCA\Gallery\Middleware\CheckException

Properties

hasher

hasher : \OCP\Security\IHasher
var

Type(s)

\OCP\Security\IHasher

session

session : \OCP\ISession
var

Type(s)

\OCP\ISession

environment

environment : \OCA\Gallery\Environment\Environment

reflector

reflector : \OCP\AppFramework\Utility\IControllerMethodReflector
var

Type(s)

\OCP\AppFramework\Utility\IControllerMethodReflector

shareManager

shareManager : \OCP\Share\IManager
var

Type(s)

\OCP\Share\IManager

appName

appName : string
inherited
var

Type(s)

string

request

request : \OCP\IRequest
inherited
var

Type(s)

\OCP\IRequest

urlGenerator

urlGenerator : \OCP\IURLGenerator
inherited
var

Type(s)

\OCP\IURLGenerator

logger

logger : \OCP\ILogger
inherited
var

Type(s)

\OCP\ILogger