blob: caa3a6beed3a678426a1f5eed93f8003d22134b7 [file] [log] [blame]
Jan Tattermusch189fcf82015-12-02 13:41:12 -08001#region Copyright notice and license
2
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003// Copyright 2015 gRPC authors.
Jan Tattermusch189fcf82015-12-02 13:41:12 -08004//
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
Jan Tattermusch189fcf82015-12-02 13:41:12 -08008//
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009// http://www.apache.org/licenses/LICENSE-2.0
Jan Tattermusch189fcf82015-12-02 13:41:12 -080010//
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
Jan Tattermusch189fcf82015-12-02 13:41:12 -080016
17#endregion
18
19using System;
20using System.Collections.Generic;
21using System.Threading.Tasks;
22
23using Grpc.Core.Internal;
24using Grpc.Core.Utils;
25
26namespace Grpc.Core
27{
28 /// <summary>
29 /// Asynchronous authentication interceptor for <see cref="CallCredentials"/>.
30 /// </summary>
31 /// <param name="context">The interceptor context.</param>
32 /// <param name="metadata">Metadata to populate with entries that will be added to outgoing call's headers.</param>
33 /// <returns></returns>
34 public delegate Task AsyncAuthInterceptor(AuthInterceptorContext context, Metadata metadata);
35
36 /// <summary>
37 /// Context for an RPC being intercepted by <see cref="AsyncAuthInterceptor"/>.
38 /// </summary>
39 public class AuthInterceptorContext
40 {
41 readonly string serviceUrl;
42 readonly string methodName;
43
44 /// <summary>
45 /// Initializes a new instance of <c>AuthInterceptorContext</c>.
46 /// </summary>
47 public AuthInterceptorContext(string serviceUrl, string methodName)
48 {
Jan Tattermusch7a3ee6a2016-02-18 10:36:02 -080049 this.serviceUrl = GrpcPreconditions.CheckNotNull(serviceUrl);
50 this.methodName = GrpcPreconditions.CheckNotNull(methodName);
Jan Tattermusch189fcf82015-12-02 13:41:12 -080051 }
52
53 /// <summary>
54 /// The fully qualified service URL for the RPC being called.
55 /// </summary>
56 public string ServiceUrl
57 {
58 get { return serviceUrl; }
59 }
60
61 /// <summary>
62 /// The method name of the RPC being called.
63 /// </summary>
64 public string MethodName
65 {
66 get { return methodName; }
67 }
68 }
69}