// Copyright 2020-2026 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package buf.alpha.registry.v1alpha1;

import "buf/alpha/registry/v1alpha1/user.proto";

// AuthnService supplies authentication helpers.
service AuthnService {
  // GetCurrentUser gets information associated with the current user.
  //
  // The user's ID is retrieved from the request's authentication header.
  rpc GetCurrentUser(GetCurrentUserRequest) returns (GetCurrentUserResponse) {
    option idempotency_level = NO_SIDE_EFFECTS;
  }
  // GetCurrentUserSubject gets the currently logged in users subject.
  //
  // The user's ID is retrieved from the request's authentication header.
  rpc GetCurrentUserSubject(GetCurrentUserSubjectRequest) returns (GetCurrentUserSubjectResponse) {
    option idempotency_level = NO_SIDE_EFFECTS;
  }
}

message GetCurrentUserRequest {}

message GetCurrentUserResponse {
  buf.alpha.registry.v1alpha1.User user = 1;
}

message GetCurrentUserSubjectRequest {}

message GetCurrentUserSubjectResponse {
  // The user's subject for mapping to user in identity provider.
  // Note: we do not want to make it part of the User response as
  // it contains potentially sensitive information and the User
  // response is shared with other users.
  string subject = 1;
}
