@extends('layouts.admin') @section('title', 'API Key & Keamanan Integrasi') @section('content')

API Key & Integrasi REST API

Kelola kunci otorisasi untuk aplikasi mobile Android/iOS dan integrasi eksternal secara aman.

@if(session('success'))

Berhasil!

{{ session('success') }}

@endif

Total Kunci API

{{ $totalKeys }}

Terdaftar di database

Kunci Aktif

{{ $activeKeys }}

Siap menerima traffic request

Proteksi REST API

X-API-KEY Wajib

Middleware: api.key

Daftar API Key Terdaftar

Gunakan header X-API-KEY pada setiap request
@forelse($apiKeys as $item) @empty @endforelse
Nama Aplikasi / Klien Kunci Otorisasi (API Key) Tipe Klien Rate Limit Terakhir Digunakan Status Aksi
{{ $item->nama }} @if($item->keterangan) {{ $item->keterangan }} @endif
{{ $item->key }}
@if($item->client_type === 'mobile_app') Mobile App @elseif($item->client_type === 'web_client') Web Client @else Integrasi Sistem @endif {{ $item->rate_limit_per_minute }} req / menit @if($item->last_used_at) {{ $item->last_used_at->diffForHumans() }} {{ $item->last_used_at->format('d/m/Y H:i') }} @else Belum pernah @endif {{ $item->status_aktif ? 'Aktif' : 'Non-Aktif' }}
@csrf
@csrf
@csrf @method('DELETE')

Belum ada API Key

Klik tombol "Buat API Key Baru" untuk membuat kunci otorisasi pertama.

Panduan Penggunaan REST API

Sertakan header otorisasi pada setiap request HTTP

JSON REST API
# 1. Contoh Request Login Pegawai Mobile:
curl -X POST http://localhost:8000/api/mobile/login \
  -H "X-API-KEY: {{ $apiKeys->first()->key ?? $masterEnvKey }}" \
  -H "Content-Type: application/json" \
  -d '{"login": "NIP-2022-042", "password": "password123"}'

1. Header X-API-KEY

Wajib disertakan untuk semua pemanggilan endpoint /api/mobile/*.

2. Token Sesi Pegawai

Setelah login, gunakan Bearer <token> untuk endpoint absen & profil.

3. Single Device Lock

Tiap pegawai otomatis terikat dengan UUID perangkat smartphone terdaftar.

@push('scripts') @endpush @endsection