Skip to content

permitio/springboot-authorization-example-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎵 Spring Boot Music Player with Permit.io Authorization

A modern, responsive web-based music player built with Spring Boot and featuring fine-grained authorization using Permit.io.

✨ Features

  • Music Management: Browse songs, create playlists, queue management
  • Authorization: Fine-grained permissions using Permit.io
  • Multi-User Support: Switch between users with different access levels
  • Modern UI: Dark theme with responsive design
  • Real-time Permissions: Dynamic permission checks for all actions

🚀 Quick Start

Prerequisites

  • Java 17 or higher
  • Maven 3.6 or higher
  • Permit.io account (free at app.permit.io)

Setup

  1. Clone the repository

    git clone <repository-url>
    cd springboot-music-player
  2. Configure Permit.io

    • Create a free account at app.permit.io
    • Get your API key from the dashboard
    • Update src/main/resources/application.properties:
      permit.api.key=YOUR_PERMIT_API_KEY_HERE
  3. Run the application

    ./run.sh

    Or manually:

    mvn spring-boot:run
  4. Access the application Open your browser and navigate to: http://localhost:8080

🔐 Permission Model

The application uses Permit.io to enforce the following permissions:

Resources

  • playlist: Public and private playlists
  • song: Individual songs

Actions

  • view-public: View public playlists
  • view-private: View private playlists
  • add-to-playlist: Add songs to playlists
  • delete: Remove songs from playlists
  • play: Play songs
  • add-to-queue: Add songs to playback queue

🏗️ Architecture

Backend

  • Spring Boot: REST API with authorization enforcement
  • Permit.io SDK: Real-time permission checks
  • In-memory storage: Simple data layer for demo purposes

Frontend

  • Thymeleaf + Bootstrap: Responsive UI
  • jQuery: AJAX calls with permission-aware error handling

🛠️ Development

Project Structure

src/
├── main/
│   ├── java/com/example/musicplayer/
│   │   ├── MusicPlayerApplication.java
│   │   ├── controller/          # REST endpoints with authorization
│   │   ├── model/              # Data models
│   │   └── config/             # Permit.io configuration
│   └── resources/
│       ├── static/             # CSS and JavaScript
│       ├── templates/          # Thymeleaf templates
│       └── application.properties

API Endpoints

  • GET /api/songs - List all songs
  • GET /api/songs/{id}/play - Get song playback URL (requires permission)
  • GET /api/playlists/{id} - Get playlist (requires view permission)
  • POST /api/playlists/{id}/songs - Add song to playlist (requires permission)
  • DELETE /api/playlists/{id}/songs/{songId} - Remove song (requires permission)

📝 License

This project is open source and available under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published