@@ -14,15 +14,16 @@ namespace Microsoft.AspNetCore.Authentication
14
14
public static class AuthenticationHttpContextExtensions
15
15
{
16
16
/// <summary>
17
- /// Extension method for authenticate using the <see cref="AuthenticationOptions.DefaultAuthenticateScheme"/> scheme.
17
+ /// Authenticate the current request using the default authentication scheme.
18
+ /// The default authentication scheme can be configured using <see cref="AuthenticationOptions.DefaultAuthenticateScheme"/>.
18
19
/// </summary>
19
20
/// <param name="context">The <see cref="HttpContext"/> context.</param>
20
21
/// <returns>The <see cref="AuthenticateResult"/>.</returns>
21
22
public static Task < AuthenticateResult > AuthenticateAsync ( this HttpContext context ) =>
22
23
context . AuthenticateAsync ( scheme : null ) ;
23
24
24
25
/// <summary>
25
- /// Extension method for authenticate .
26
+ /// Authenticate the current request using the specified scheme .
26
27
/// </summary>
27
28
/// <param name="context">The <see cref="HttpContext"/> context.</param>
28
29
/// <param name="scheme">The name of the authentication scheme.</param>
@@ -31,7 +32,8 @@ public static Task<AuthenticateResult> AuthenticateAsync(this HttpContext contex
31
32
context . RequestServices . GetRequiredService < IAuthenticationService > ( ) . AuthenticateAsync ( context , scheme ) ;
32
33
33
34
/// <summary>
34
- /// Extension method for Challenge.
35
+ /// Challenge the current request using the specified scheme.
36
+ /// An authentication challenge can be issued when an unauthenticated user requests an endpoint that requires authentication.
35
37
/// </summary>
36
38
/// <param name="context">The <see cref="HttpContext"/> context.</param>
37
39
/// <param name="scheme">The name of the authentication scheme.</param>
@@ -40,15 +42,19 @@ public static Task ChallengeAsync(this HttpContext context, string? scheme) =>
40
42
context . ChallengeAsync ( scheme , properties : null ) ;
41
43
42
44
/// <summary>
43
- /// Extension method for authenticate using the <see cref="AuthenticationOptions.DefaultChallengeScheme"/> scheme.
45
+ /// Challenge the current request using the default challenge scheme.
46
+ /// An authentication challenge can be issued when an unauthenticated user requests an endpoint that requires authentication.
47
+ /// The default challenge scheme can be configured using <see cref="AuthenticationOptions.DefaultChallengeScheme"/>.
44
48
/// </summary>
45
49
/// <param name="context">The <see cref="HttpContext"/> context.</param>
46
50
/// <returns>The task.</returns>
47
51
public static Task ChallengeAsync ( this HttpContext context ) =>
48
52
context . ChallengeAsync ( scheme : null , properties : null ) ;
49
53
50
54
/// <summary>
51
- /// Extension method for authenticate using the <see cref="AuthenticationOptions.DefaultChallengeScheme"/> scheme.
55
+ /// Challenge the current request using the default challenge scheme.
56
+ /// An authentication challenge can be issued when an unauthenticated user requests an endpoint that requires authentication.
57
+ /// The default challenge scheme can be configured using <see cref="AuthenticationOptions.DefaultChallengeScheme"/>.
52
58
/// </summary>
53
59
/// <param name="context">The <see cref="HttpContext"/> context.</param>
54
60
/// <param name="properties">The <see cref="AuthenticationProperties"/> properties.</param>
@@ -57,7 +63,8 @@ public static Task ChallengeAsync(this HttpContext context, AuthenticationProper
57
63
context . ChallengeAsync ( scheme : null , properties : properties ) ;
58
64
59
65
/// <summary>
60
- /// Extension method for Challenge.
66
+ /// Challenge the current request using the specified scheme.
67
+ /// An authentication challenge can be issued when an unauthenticated user requests an endpoint that requires authentication.
61
68
/// </summary>
62
69
/// <param name="context">The <see cref="HttpContext"/> context.</param>
63
70
/// <param name="scheme">The name of the authentication scheme.</param>
@@ -67,7 +74,8 @@ public static Task ChallengeAsync(this HttpContext context, string? scheme, Auth
67
74
context . RequestServices . GetRequiredService < IAuthenticationService > ( ) . ChallengeAsync ( context , scheme , properties ) ;
68
75
69
76
/// <summary>
70
- /// Extension method for Forbid.
77
+ /// Forbid the current request using the specified scheme.
78
+ /// Forbid is used when an authenticated user attempts to access a resource they are not permitted to access.
71
79
/// </summary>
72
80
/// <param name="context">The <see cref="HttpContext"/> context.</param>
73
81
/// <param name="scheme">The name of the authentication scheme.</param>
@@ -76,15 +84,19 @@ public static Task ForbidAsync(this HttpContext context, string? scheme) =>
76
84
context . ForbidAsync ( scheme , properties : null ) ;
77
85
78
86
/// <summary>
79
- /// Extension method for Forbid using the <see cref="AuthenticationOptions.DefaultForbidScheme"/> scheme..
87
+ /// Forbid the current request using the default forbid scheme.
88
+ /// Forbid is used when an authenticated user attempts to access a resource they are not permitted to access.
89
+ /// The default forbid scheme can be configured using <see cref="AuthenticationOptions.DefaultForbidScheme"/>.
80
90
/// </summary>
81
91
/// <param name="context">The <see cref="HttpContext"/> context.</param>
82
92
/// <returns>The task.</returns>
83
93
public static Task ForbidAsync ( this HttpContext context ) =>
84
94
context . ForbidAsync ( scheme : null , properties : null ) ;
85
95
86
96
/// <summary>
87
- /// Extension method for Forbid.
97
+ /// Forbid the current request using the default forbid scheme.
98
+ /// Forbid is used when an authenticated user attempts to access a resource they are not permitted to access.
99
+ /// The default forbid scheme can be configured using <see cref="AuthenticationOptions.DefaultForbidScheme"/>.
88
100
/// </summary>
89
101
/// <param name="context">The <see cref="HttpContext"/> context.</param>
90
102
/// <param name="properties">The <see cref="AuthenticationProperties"/> properties.</param>
@@ -93,7 +105,8 @@ public static Task ForbidAsync(this HttpContext context, AuthenticationPropertie
93
105
context . ForbidAsync ( scheme : null , properties : properties ) ;
94
106
95
107
/// <summary>
96
- /// Extension method for Forbid.
108
+ /// Forbid the current request using the specified scheme.
109
+ /// Forbid is used when an authenticated user attempts to access a resource they are not permitted to access.
97
110
/// </summary>
98
111
/// <param name="context">The <see cref="HttpContext"/> context.</param>
99
112
/// <param name="scheme">The name of the authentication scheme.</param>
@@ -103,7 +116,7 @@ public static Task ForbidAsync(this HttpContext context, string? scheme, Authent
103
116
context . RequestServices . GetRequiredService < IAuthenticationService > ( ) . ForbidAsync ( context , scheme , properties ) ;
104
117
105
118
/// <summary>
106
- /// Extension method for SignIn .
119
+ /// Sign in a principal for the specified scheme .
107
120
/// </summary>
108
121
/// <param name="context">The <see cref="HttpContext"/> context.</param>
109
122
/// <param name="scheme">The name of the authentication scheme.</param>
@@ -113,7 +126,8 @@ public static Task SignInAsync(this HttpContext context, string? scheme, ClaimsP
113
126
context . SignInAsync ( scheme , principal , properties : null ) ;
114
127
115
128
/// <summary>
116
- /// Extension method for SignIn using the <see cref="AuthenticationOptions.DefaultSignInScheme"/>.
129
+ /// Sign in a principal for the default authentication scheme.
130
+ /// The default scheme for signing in can be configured using <see cref="AuthenticationOptions.DefaultSignInScheme"/>.
117
131
/// </summary>
118
132
/// <param name="context">The <see cref="HttpContext"/> context.</param>
119
133
/// <param name="principal">The user.</param>
@@ -122,7 +136,8 @@ public static Task SignInAsync(this HttpContext context, ClaimsPrincipal princip
122
136
context . SignInAsync ( scheme : null , principal : principal , properties : null ) ;
123
137
124
138
/// <summary>
125
- /// Extension method for SignIn using the <see cref="AuthenticationOptions.DefaultSignInScheme"/>.
139
+ /// Sign in a principal for the default authentication scheme.
140
+ /// The default scheme for signing in can be configured using <see cref="AuthenticationOptions.DefaultForbidScheme"/>.
126
141
/// </summary>
127
142
/// <param name="context">The <see cref="HttpContext"/> context.</param>
128
143
/// <param name="principal">The user.</param>
@@ -132,7 +147,7 @@ public static Task SignInAsync(this HttpContext context, ClaimsPrincipal princip
132
147
context . SignInAsync ( scheme : null , principal : principal , properties : properties ) ;
133
148
134
149
/// <summary>
135
- /// Extension method for SignIn .
150
+ /// Sign in a principal for the specified scheme .
136
151
/// </summary>
137
152
/// <param name="context">The <see cref="HttpContext"/> context.</param>
138
153
/// <param name="scheme">The name of the authentication scheme.</param>
@@ -143,30 +158,32 @@ public static Task SignInAsync(this HttpContext context, string? scheme, ClaimsP
143
158
context . RequestServices . GetRequiredService < IAuthenticationService > ( ) . SignInAsync ( context , scheme , principal , properties ) ;
144
159
145
160
/// <summary>
146
- /// Extension method for SignOut using the <see cref="AuthenticationOptions.DefaultSignOutScheme"/>.
161
+ /// Sign out a principal for the default authentication scheme.
162
+ /// The default scheme for signing out can be configured using <see cref="AuthenticationOptions.DefaultSignOutScheme"/>.
147
163
/// </summary>
148
164
/// <param name="context">The <see cref="HttpContext"/> context.</param>
149
165
/// <returns>The task.</returns>
150
166
public static Task SignOutAsync ( this HttpContext context ) => context . SignOutAsync ( scheme : null , properties : null ) ;
151
167
152
168
/// <summary>
153
- /// Extension method for SignOut using the <see cref="AuthenticationOptions.DefaultSignOutScheme"/>.
169
+ /// Sign out a principal for the default authentication scheme.
170
+ /// The default scheme for signing out can be configured using <see cref="AuthenticationOptions.DefaultSignOutScheme"/>.
154
171
/// </summary>
155
172
/// <param name="context">The <see cref="HttpContext"/> context.</param>
156
173
/// <param name="properties">The <see cref="AuthenticationProperties"/> properties.</param>
157
174
/// <returns>The task.</returns>
158
175
public static Task SignOutAsync ( this HttpContext context , AuthenticationProperties ? properties ) => context . SignOutAsync ( scheme : null , properties : properties ) ;
159
176
160
177
/// <summary>
161
- /// Extension method for SignOut .
178
+ /// Sign out a principal for the specified scheme .
162
179
/// </summary>
163
180
/// <param name="context">The <see cref="HttpContext"/> context.</param>
164
181
/// <param name="scheme">The name of the authentication scheme.</param>
165
182
/// <returns>The task.</returns>
166
183
public static Task SignOutAsync ( this HttpContext context , string ? scheme ) => context . SignOutAsync ( scheme , properties : null ) ;
167
184
168
185
/// <summary>
169
- /// Extension method for SignOut .
186
+ /// Sign out a principal for the specified scheme .
170
187
/// </summary>
171
188
/// <param name="context">The <see cref="HttpContext"/> context.</param>
172
189
/// <param name="scheme">The name of the authentication scheme.</param>
@@ -176,21 +193,22 @@ public static Task SignOutAsync(this HttpContext context, string? scheme, Authen
176
193
context . RequestServices . GetRequiredService < IAuthenticationService > ( ) . SignOutAsync ( context , scheme , properties ) ;
177
194
178
195
/// <summary>
179
- /// Extension method for getting the value of an authentication token.
196
+ /// Authenticates the request using the specified scheme and returns the value for the token.
180
197
/// </summary>
181
198
/// <param name="context">The <see cref="HttpContext"/> context.</param>
182
199
/// <param name="scheme">The name of the authentication scheme.</param>
183
200
/// <param name="tokenName">The name of the token.</param>
184
- /// <returns>The value of the token.</returns>
201
+ /// <returns>The value of the token if present .</returns>
185
202
public static Task < string ? > GetTokenAsync ( this HttpContext context , string ? scheme , string tokenName ) =>
186
203
context . RequestServices . GetRequiredService < IAuthenticationService > ( ) . GetTokenAsync ( context , scheme , tokenName ) ;
187
204
188
205
/// <summary>
189
- /// Extension method for getting the value of an authentication token.
206
+ /// Authenticates the request using the default authentication scheme and returns the value for the token.
207
+ /// The default authentication scheme can be configured using <see cref="AuthenticationOptions.DefaultAuthenticateScheme"/>.
190
208
/// </summary>
191
209
/// <param name="context">The <see cref="HttpContext"/> context.</param>
192
210
/// <param name="tokenName">The name of the token.</param>
193
- /// <returns>The value of the token.</returns>
211
+ /// <returns>The value of the token if present .</returns>
194
212
public static Task < string ? > GetTokenAsync ( this HttpContext context , string tokenName ) =>
195
213
context . RequestServices . GetRequiredService < IAuthenticationService > ( ) . GetTokenAsync ( context , tokenName ) ;
196
214
}
0 commit comments