Skip to content

OpencastAuth

The OpencastAuth authentication system provides an interface for managing authentication and authorization with Opencast services.

export interface OpencastAuth {
getLoggedUserName: () => Promise<string | null>
isAnonymous: () => Promise<boolean>
canRead: () => Promise<boolean>
canWrite: () => Promise<boolean>
auth: (redirectUrl?: string) => Promise<void>
}
getLoggedUserName(): Promise<string | null>

Gets the name of the authenticated user.

Returns: The user name or null if not authenticated.

isAnonymous(): Promise<boolean>

Checks if the current user is anonymous.

Returns: true if the user is anonymous, false otherwise.

canRead(): Promise<boolean>

Checks if the user has read permissions.

Returns: true if they have read permissions, false otherwise.

canWrite(): Promise<boolean>

Checks if the user has write permissions.

Returns: true if they have write permissions, false otherwise.

auth(redirectUrl?: string): Promise<void>

Starts the authentication process.

Parameters:

  • redirectUrl: string (optional) - URL to redirect to after authentication

Default implementation of the Opencast authentication system.

export class OpencastAuthDefaultImpl implements OpencastAuth
constructor(player?: OpencastPaellaPlayer)

Parameters:

  • player: OpencastPaellaPlayer (optional) - Player instance
get player(): OpencastPaellaPlayer | null
set player(player: OpencastPaellaPlayer)

Reference to the Paella Opencast player.

The default implementation:

  • Gets user information from the /info/me.json Opencast endpoint
  • Caches user information to avoid multiple requests
  • Handles authentication errors gracefully
  • Integrates with player logging for debugging

The implementation uses the standard Opencast endpoint:

GET /info/me.json

This endpoint returns information about the current authenticated user, including:

  • Username
  • Roles and permissions
  • Authentication status

Authentication can be configured in the initialization parameters:

const player = new OpencastPaellaPlayer('container', {
opencast: {
auth: new CustomAuthImpl(), // Custom implementation
// or use default implementation (automatic)
}
});
import { OpencastPaellaPlayer, OpencastAuthDefaultImpl } from '@asicupv/paella-opencast-core';
const auth = new OpencastAuthDefaultImpl();
const player = new OpencastPaellaPlayer('player-container', {
opencast: {
auth: auth,
presentationUrl: 'https://opencast.example.com'
}
});