Nextcloud PHP API (stable18)

AuthPublicShareController extends PublicShareController

Base controller for interactive public shares

It will verify if the user is properly authenticated to the share. If not the user will be redirected to an authentication page.

Use this for a controller that is to be called directly by a user. So the normal public share page for files/calendars etc.

Tags
since
14.0.0

Table of Contents

$appName  : string
app name
$request  : IRequest
current request
$session  : ISession
$urlGenerator  : IURLGenerator
$responders  : array
$token  : string
__construct()  : mixed
constructor of the controller
authenticate()  : mixed
buildResponse()  : Response
Serializes and formats a response
getAuthenticationRedirect()  : RedirectResponse
getResponderByHTTPHeader()  : string
Parses an HTTP accept header and returns the supported responder type
getToken()  : string
Get the token for this request
isAuthenticated()  : bool
Check if a share is authenticated or not
isValidToken()  : bool
Is the provided token a valid token
setToken()  : mixed
Middleware set the token for the request
shareNotFound()  : mixed
Function called if the share is not found.
showAuthenticate()  : TemplateResponse
showShare()  : TemplateResponse
Default landing page
authFailed()  : mixed
Function called after failed authentication
authSucceeded()  : mixed
Function called after successfull authentication
getPasswordHash()  : string
Get a hash of the password for this share
isPasswordProtected()  : bool
Is a share with this token password protected
registerResponder()  : mixed
Registers a formatter for a type
showAuthFailed()  : TemplateResponse
The template to show when authentication failed
verifyPassword()  : bool
Verify the password
getRedirect()  : RedirectResponse
getRoute()  : string

Properties

$appName

app name

protected string $appName
Tags
since
7.0.0

$responders

private array $responders
Tags
since
7.0.0

Methods

authenticate()

public final authenticate([string $password = '' ]) : mixed
Parameters
$password : string = ''
Tags
UseSession
PublicPage
BruteForceProtection

(action=publicLinkAuth)

Authenticate the share

since
14.0.0
Return values
mixed

buildResponse()

Serializes and formats a response

public buildResponse(mixed $response[, string $format = 'json' ]) : Response
Parameters
$response : mixed

the value that was returned from a controller and is not a Response instance

$format : string = 'json'

the format for which a formatter has been registered

Tags
throws
DomainException

if format does not match a registered formatter

since
7.0.0
Return values
Response

getResponderByHTTPHeader()

Parses an HTTP accept header and returns the supported responder type

public getResponderByHTTPHeader(string $acceptHeader[, string $default = 'json' ]) : string
Parameters
$acceptHeader : string
$default : string = 'json'
Tags
since
7.0.0
since
9.1.0

Added default parameter

Return values
string

the responder type

getToken()

Get the token for this request

public final getToken() : string
Tags
since
14.0.0
Return values
string

isAuthenticated()

Check if a share is authenticated or not

public final isAuthenticated() : bool
Tags
since
14.0.0
Return values
bool

isValidToken()

Is the provided token a valid token

public abstract isValidToken() : bool

This function is already called from the middleware directly after setting the token.

Tags
since
14.0.0
Return values
bool

setToken()

Middleware set the token for the request

public final setToken(string $token) : mixed
Parameters
$token : string
Tags
since
14.0.0
Return values
mixed

shareNotFound()

Function called if the share is not found.

public shareNotFound() : mixed

You can use this to do some logging for example

Tags
since
14.0.0
Return values
mixed

authFailed()

Function called after failed authentication

protected authFailed() : mixed

You can use this to do some logging for example

Tags
since
14.0.0
Return values
mixed

authSucceeded()

Function called after successfull authentication

protected authSucceeded() : mixed

You can use this to do some logging for example

Tags
since
14.0.0
Return values
mixed

getPasswordHash()

Get a hash of the password for this share

protected abstract getPasswordHash() : string

To ensure access is blocked when the password to a share is changed we store a hash of the password for this token.

Tags
since
14.0.0
Return values
string

isPasswordProtected()

Is a share with this token password protected

protected abstract isPasswordProtected() : bool
Tags
since
14.0.0
Return values
bool

registerResponder()

Registers a formatter for a type

protected registerResponder(string $format, Closure $responder) : mixed
Parameters
$format : string
$responder : Closure
Tags
since
7.0.0
Return values
mixed

verifyPassword()

Verify the password

protected abstract verifyPassword(string $password) : bool
Parameters
$password : string
Tags
since
14.0.0
Return values
bool

getRoute()

private getRoute(string $function) : string
Parameters
$function : string
Tags
since
14.0.0
Return values
string

Search results