generator-aspnet-oauth 8.0.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +48 -49
- package/generators/app/index.js +118 -118
- package/generators/app/templates/AuthenticationDefaults.cs +48 -48
- package/generators/app/templates/AuthenticationExtensions.cs +74 -74
- package/generators/app/templates/AuthenticationHandler.cs +89 -89
- package/generators/app/templates/AuthenticationOptions.cs +34 -34
- package/generators/app/templates/Project.csproj +24 -24
- package/package.json +43 -40
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015 aspnet-contrib
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 aspnet-contrib
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,49 +1,48 @@
|
|
|
1
|
-
# generator-aspnet-oauth
|
|
2
|
-
|
|
3
|
-
[](https://github.com/aspnet-contrib/generator-aspnet-oauth/actions?query=workflow%3Abuild+branch%3Adev+event%3Apush)
|
|
4
|
-
|
|
5
|
-
> [Yeoman](http://yeoman.io) generator
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
MIT
|
|
1
|
+
# generator-aspnet-oauth
|
|
2
|
+
|
|
3
|
+
[](https://github.com/aspnet-contrib/generator-aspnet-oauth/actions?query=workflow%3Abuild+branch%3Adev+event%3Apush)
|
|
4
|
+
|
|
5
|
+
> [Yeoman](http://yeoman.io) generator
|
|
6
|
+
|
|
7
|
+
## Getting Started
|
|
8
|
+
|
|
9
|
+
### What is Yeoman?
|
|
10
|
+
|
|
11
|
+
Trick question. It's not a thing. It's this guy:
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
Basically, he wears a top hat, lives in your computer, and waits for you to tell him what kind of application you wish to create.
|
|
16
|
+
|
|
17
|
+
Not every new computer comes with a Yeoman pre-installed. He lives in the [npm](https://npmjs.org) package repository. You only have to ask for him once, then he packs up and moves into your hard drive. *Make sure you clean up, he likes new and shiny things.*
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g yo
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Yeoman Generators
|
|
24
|
+
|
|
25
|
+
Yeoman travels light. He didn't pack any generators when he moved in. You can think of a generator like a plug-in. You get to choose what type of application you wish to create, such as a Backbone application or even a Chrome extension.
|
|
26
|
+
|
|
27
|
+
To install generator-aspnet-oauth from npm, run:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g generator-aspnet-oauth
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Finally, initiate the generator:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
yo aspnet-oauth
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Getting To Know Yeoman
|
|
40
|
+
|
|
41
|
+
Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced.
|
|
42
|
+
|
|
43
|
+
If you'd like to get to know Yeoman better and meet some of his friends, [Grunt](http://gruntjs.com) and [Bower](http://bower.io), check out the complete [Getting Started Guide](https://github.com/yeoman/yeoman/wiki/Getting-Started).
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
MIT
|
package/generators/app/index.js
CHANGED
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const fetch = require('cross-fetch');
|
|
3
|
-
const Generator = require('yeoman-generator');
|
|
4
|
-
const queryString = require('query-string');
|
|
5
|
-
const yosay = require('yosay');
|
|
6
|
-
|
|
7
|
-
module.exports = class extends Generator {
|
|
8
|
-
|
|
9
|
-
initializing() {
|
|
10
|
-
this.templateData = {};
|
|
11
|
-
this.log(yosay('Welcome to the classy ASP.NET OAuth Provider generator!'));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async prompting() {
|
|
15
|
-
const prompts = [{
|
|
16
|
-
type: 'input',
|
|
17
|
-
name: 'name',
|
|
18
|
-
message: 'What is the name of the provider you want to create?',
|
|
19
|
-
store: true
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
type: 'input',
|
|
23
|
-
name: 'authorname',
|
|
24
|
-
message: 'What is your name?',
|
|
25
|
-
store: true
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
type: 'input',
|
|
29
|
-
name: 'authorizationendpoint',
|
|
30
|
-
message: 'What is the Authorization Endpoint for this service?',
|
|
31
|
-
store: true
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
type: 'input',
|
|
35
|
-
name: 'tokenendpoint',
|
|
36
|
-
message: 'What is the Token Endpoint for this service?',
|
|
37
|
-
store: true
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
type: 'input',
|
|
41
|
-
name: 'userinformationendpoint',
|
|
42
|
-
message: 'What is the User Information Endpoint for this service?',
|
|
43
|
-
store: true
|
|
44
|
-
}];
|
|
45
|
-
|
|
46
|
-
const answers = await this.prompt(prompts);
|
|
47
|
-
|
|
48
|
-
this.templateData.name = answers.name;
|
|
49
|
-
this.templateData.authorname = answers.authorname;
|
|
50
|
-
this.templateData.authorizationendpoint = answers.authorizationendpoint;
|
|
51
|
-
this.templateData.tokenendpoint = answers.tokenendpoint;
|
|
52
|
-
this.templateData.userinformationendpoint = answers.userinformationendpoint;
|
|
53
|
-
|
|
54
|
-
this.templateData.currentVersion = await this.getCurrentVersion();
|
|
55
|
-
|
|
56
|
-
this.name = answers.name;
|
|
57
|
-
this.applicationName = 'AspNet.Security.OAuth.' + answers.name;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
writing() {
|
|
61
|
-
this.fs.copyTpl(this.templatePath('Project.csproj'), this.applicationName + '/' + this.applicationName + '.csproj', this.templateData)
|
|
62
|
-
this.fs.copyTpl(this.templatePath('AuthenticationDefaults.cs'), this.applicationName + '/' + this.name + 'AuthenticationDefaults.cs', this.templateData)
|
|
63
|
-
this.fs.copyTpl(this.templatePath('AuthenticationExtensions.cs'), this.applicationName + '/' + this.name + 'AuthenticationExtensions.cs', this.templateData)
|
|
64
|
-
this.fs.copyTpl(this.templatePath('AuthenticationHandler.cs'), this.applicationName + '/' + this.name + 'AuthenticationHandler.cs', this.templateData)
|
|
65
|
-
this.fs.copyTpl(this.templatePath('AuthenticationOptions.cs'), this.applicationName + '/' + this.name + 'AuthenticationOptions.cs', this.templateData)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async getCurrentVersion() {
|
|
69
|
-
|
|
70
|
-
let response = await fetch('https://api.nuget.org/v3/index.json');
|
|
71
|
-
|
|
72
|
-
if (!response.ok) {
|
|
73
|
-
throw new Error(`Failed to query NuGet service index. HTTP status code: ${response.status}.`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const serviceIndex = await response.json();
|
|
77
|
-
const baseAddress = serviceIndex.resources.find(resource => resource['@type'] === 'SearchQueryService/3.5.0')['@id'];
|
|
78
|
-
|
|
79
|
-
if (!baseAddress) {
|
|
80
|
-
throw new Error('Failed to determine the base address for the NuGet search query service.');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const query = queryString.stringify({
|
|
84
|
-
prerelease: false,
|
|
85
|
-
q: 'PackageId:AspNet.Security.OAuth.GitHub',
|
|
86
|
-
semVerLevel: '2.0.0',
|
|
87
|
-
take: 1
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const searchUrl = `${baseAddress}?${query}`;
|
|
91
|
-
response = await fetch(searchUrl);
|
|
92
|
-
|
|
93
|
-
if (!response.ok) {
|
|
94
|
-
throw new Error(`Failed to search for NuGet package from '${searchUrl}'. HTTP status code: ${response.status}.`);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const searchResult = await response.json();
|
|
98
|
-
|
|
99
|
-
let latestVersion = null;
|
|
100
|
-
|
|
101
|
-
if (searchResult.data && searchResult.data.length > 0) {
|
|
102
|
-
latestVersion = searchResult.data[0].version;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (!latestVersion) {
|
|
106
|
-
throw new Error('Failed to determine the latest version of the OAuth providers.');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const dot = '.';
|
|
110
|
-
const versionParts = latestVersion.split(dot);
|
|
111
|
-
|
|
112
|
-
// Increment the build number by one for the release that
|
|
113
|
-
// would be the first one including this new provider.
|
|
114
|
-
versionParts[2] = parseInt(versionParts[2], 10) + 1;
|
|
115
|
-
|
|
116
|
-
return versionParts.join(dot);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
const fetch = require('cross-fetch');
|
|
3
|
+
const Generator = require('yeoman-generator');
|
|
4
|
+
const queryString = require('query-string');
|
|
5
|
+
const yosay = require('yosay');
|
|
6
|
+
|
|
7
|
+
module.exports = class extends Generator {
|
|
8
|
+
|
|
9
|
+
initializing() {
|
|
10
|
+
this.templateData = {};
|
|
11
|
+
this.log(yosay('Welcome to the classy ASP.NET OAuth Provider generator!'));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async prompting() {
|
|
15
|
+
const prompts = [{
|
|
16
|
+
type: 'input',
|
|
17
|
+
name: 'name',
|
|
18
|
+
message: 'What is the name of the provider you want to create?',
|
|
19
|
+
store: true
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'input',
|
|
23
|
+
name: 'authorname',
|
|
24
|
+
message: 'What is your name?',
|
|
25
|
+
store: true
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'input',
|
|
29
|
+
name: 'authorizationendpoint',
|
|
30
|
+
message: 'What is the Authorization Endpoint for this service?',
|
|
31
|
+
store: true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: 'input',
|
|
35
|
+
name: 'tokenendpoint',
|
|
36
|
+
message: 'What is the Token Endpoint for this service?',
|
|
37
|
+
store: true
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: 'input',
|
|
41
|
+
name: 'userinformationendpoint',
|
|
42
|
+
message: 'What is the User Information Endpoint for this service?',
|
|
43
|
+
store: true
|
|
44
|
+
}];
|
|
45
|
+
|
|
46
|
+
const answers = await this.prompt(prompts);
|
|
47
|
+
|
|
48
|
+
this.templateData.name = answers.name;
|
|
49
|
+
this.templateData.authorname = answers.authorname;
|
|
50
|
+
this.templateData.authorizationendpoint = answers.authorizationendpoint;
|
|
51
|
+
this.templateData.tokenendpoint = answers.tokenendpoint;
|
|
52
|
+
this.templateData.userinformationendpoint = answers.userinformationendpoint;
|
|
53
|
+
|
|
54
|
+
this.templateData.currentVersion = await this.getCurrentVersion();
|
|
55
|
+
|
|
56
|
+
this.name = answers.name;
|
|
57
|
+
this.applicationName = 'AspNet.Security.OAuth.' + answers.name;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
writing() {
|
|
61
|
+
this.fs.copyTpl(this.templatePath('Project.csproj'), this.applicationName + '/' + this.applicationName + '.csproj', this.templateData)
|
|
62
|
+
this.fs.copyTpl(this.templatePath('AuthenticationDefaults.cs'), this.applicationName + '/' + this.name + 'AuthenticationDefaults.cs', this.templateData)
|
|
63
|
+
this.fs.copyTpl(this.templatePath('AuthenticationExtensions.cs'), this.applicationName + '/' + this.name + 'AuthenticationExtensions.cs', this.templateData)
|
|
64
|
+
this.fs.copyTpl(this.templatePath('AuthenticationHandler.cs'), this.applicationName + '/' + this.name + 'AuthenticationHandler.cs', this.templateData)
|
|
65
|
+
this.fs.copyTpl(this.templatePath('AuthenticationOptions.cs'), this.applicationName + '/' + this.name + 'AuthenticationOptions.cs', this.templateData)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async getCurrentVersion() {
|
|
69
|
+
|
|
70
|
+
let response = await fetch('https://api.nuget.org/v3/index.json');
|
|
71
|
+
|
|
72
|
+
if (!response.ok) {
|
|
73
|
+
throw new Error(`Failed to query NuGet service index. HTTP status code: ${response.status}.`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const serviceIndex = await response.json();
|
|
77
|
+
const baseAddress = serviceIndex.resources.find(resource => resource['@type'] === 'SearchQueryService/3.5.0')['@id'];
|
|
78
|
+
|
|
79
|
+
if (!baseAddress) {
|
|
80
|
+
throw new Error('Failed to determine the base address for the NuGet search query service.');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const query = queryString.stringify({
|
|
84
|
+
prerelease: false,
|
|
85
|
+
q: 'PackageId:AspNet.Security.OAuth.GitHub',
|
|
86
|
+
semVerLevel: '2.0.0',
|
|
87
|
+
take: 1
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const searchUrl = `${baseAddress}?${query}`;
|
|
91
|
+
response = await fetch(searchUrl);
|
|
92
|
+
|
|
93
|
+
if (!response.ok) {
|
|
94
|
+
throw new Error(`Failed to search for NuGet package from '${searchUrl}'. HTTP status code: ${response.status}.`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const searchResult = await response.json();
|
|
98
|
+
|
|
99
|
+
let latestVersion = null;
|
|
100
|
+
|
|
101
|
+
if (searchResult.data && searchResult.data.length > 0) {
|
|
102
|
+
latestVersion = searchResult.data[0].version;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!latestVersion) {
|
|
106
|
+
throw new Error('Failed to determine the latest version of the OAuth providers.');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const dot = '.';
|
|
110
|
+
const versionParts = latestVersion.split(dot);
|
|
111
|
+
|
|
112
|
+
// Increment the build number by one for the release that
|
|
113
|
+
// would be the first one including this new provider.
|
|
114
|
+
versionParts[2] = parseInt(versionParts[2], 10) + 1;
|
|
115
|
+
|
|
116
|
+
return versionParts.join(dot);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
|
3
|
-
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
|
|
4
|
-
* for more information concerning the license and the contributors participating to this project.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
namespace AspNet.Security.OAuth.<%= name %>;
|
|
8
|
-
|
|
9
|
-
/// <summary>
|
|
10
|
-
/// Default values used by the <%= name %> authentication provider.
|
|
11
|
-
/// </summary>
|
|
12
|
-
public static class <%= name %>AuthenticationDefaults
|
|
13
|
-
{
|
|
14
|
-
/// <summary>
|
|
15
|
-
/// Default value for <see cref="AuthenticationScheme.Name"/>.
|
|
16
|
-
/// </summary>
|
|
17
|
-
public const string AuthenticationScheme = "<%= name %>";
|
|
18
|
-
|
|
19
|
-
/// <summary>
|
|
20
|
-
/// Default value for <see cref="AuthenticationScheme.DisplayName"/>.
|
|
21
|
-
/// </summary>
|
|
22
|
-
public static readonly string DisplayName = "<%= name %>";
|
|
23
|
-
|
|
24
|
-
/// <summary>
|
|
25
|
-
/// Default value for <see cref="AuthenticationSchemeOptions.ClaimsIssuer"/>.
|
|
26
|
-
/// </summary>
|
|
27
|
-
public static readonly string Issuer = "<%= name %>";
|
|
28
|
-
|
|
29
|
-
/// <summary>
|
|
30
|
-
/// Default value for <see cref="RemoteAuthenticationOptions.CallbackPath"/>.
|
|
31
|
-
/// </summary>
|
|
32
|
-
public static readonly string CallbackPath = "/signin-<%= name.toLowerCase() %>";
|
|
33
|
-
|
|
34
|
-
/// <summary>
|
|
35
|
-
/// Default value for <see cref="OAuthOptions.AuthorizationEndpoint"/>.
|
|
36
|
-
/// </summary>
|
|
37
|
-
public static readonly string AuthorizationEndpoint = "<%= authorizationendpoint %>";
|
|
38
|
-
|
|
39
|
-
/// <summary>
|
|
40
|
-
/// Default value for <see cref="OAuthOptions.TokenEndpoint"/>.
|
|
41
|
-
/// </summary>
|
|
42
|
-
public static readonly string TokenEndpoint = "<%= tokenendpoint %>";
|
|
43
|
-
|
|
44
|
-
/// <summary>
|
|
45
|
-
/// Default value for <see cref="OAuthOptions.UserInformationEndpoint"/>.
|
|
46
|
-
/// </summary>
|
|
47
|
-
public static readonly string UserInformationEndpoint = "<%= userinformationendpoint %>";
|
|
48
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
|
3
|
+
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
|
|
4
|
+
* for more information concerning the license and the contributors participating to this project.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
namespace AspNet.Security.OAuth.<%= name %>;
|
|
8
|
+
|
|
9
|
+
/// <summary>
|
|
10
|
+
/// Default values used by the <%= name %> authentication provider.
|
|
11
|
+
/// </summary>
|
|
12
|
+
public static class <%= name %>AuthenticationDefaults
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
/// Default value for <see cref="AuthenticationScheme.Name"/>.
|
|
16
|
+
/// </summary>
|
|
17
|
+
public const string AuthenticationScheme = "<%= name %>";
|
|
18
|
+
|
|
19
|
+
/// <summary>
|
|
20
|
+
/// Default value for <see cref="AuthenticationScheme.DisplayName"/>.
|
|
21
|
+
/// </summary>
|
|
22
|
+
public static readonly string DisplayName = "<%= name %>";
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
/// Default value for <see cref="AuthenticationSchemeOptions.ClaimsIssuer"/>.
|
|
26
|
+
/// </summary>
|
|
27
|
+
public static readonly string Issuer = "<%= name %>";
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
/// Default value for <see cref="RemoteAuthenticationOptions.CallbackPath"/>.
|
|
31
|
+
/// </summary>
|
|
32
|
+
public static readonly string CallbackPath = "/signin-<%= name.toLowerCase() %>";
|
|
33
|
+
|
|
34
|
+
/// <summary>
|
|
35
|
+
/// Default value for <see cref="OAuthOptions.AuthorizationEndpoint"/>.
|
|
36
|
+
/// </summary>
|
|
37
|
+
public static readonly string AuthorizationEndpoint = "<%= authorizationendpoint %>";
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
/// Default value for <see cref="OAuthOptions.TokenEndpoint"/>.
|
|
41
|
+
/// </summary>
|
|
42
|
+
public static readonly string TokenEndpoint = "<%= tokenendpoint %>";
|
|
43
|
+
|
|
44
|
+
/// <summary>
|
|
45
|
+
/// Default value for <see cref="OAuthOptions.UserInformationEndpoint"/>.
|
|
46
|
+
/// </summary>
|
|
47
|
+
public static readonly string UserInformationEndpoint = "<%= userinformationendpoint %>";
|
|
48
|
+
}
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
|
3
|
-
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
|
|
4
|
-
* for more information concerning the license and the contributors participating to this project.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
using AspNet.Security.OAuth.<%= name %>;
|
|
8
|
-
|
|
9
|
-
namespace Microsoft.Extensions.DependencyInjection;
|
|
10
|
-
|
|
11
|
-
/// <summary>
|
|
12
|
-
/// Extension methods to add <%= name %> authentication capabilities to an HTTP application pipeline.
|
|
13
|
-
/// </summary>
|
|
14
|
-
public static class <%= name %>AuthenticationExtensions
|
|
15
|
-
{
|
|
16
|
-
/// <summary>
|
|
17
|
-
/// Adds <see cref="<%= name %>AuthenticationHandler"/> to the specified
|
|
18
|
-
/// <see cref="AuthenticationBuilder"/>, which enables <%= name %> authentication capabilities.
|
|
19
|
-
/// </summary>
|
|
20
|
-
/// <param name="builder">The authentication builder.</param>
|
|
21
|
-
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
|
|
22
|
-
public static AuthenticationBuilder Add<%= name %>([NotNull] this AuthenticationBuilder builder)
|
|
23
|
-
{
|
|
24
|
-
return builder.Add<%= name %>(<%= name %>AuthenticationDefaults.AuthenticationScheme, options => { });
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/// <summary>
|
|
28
|
-
/// Adds <see cref="<%= name %>AuthenticationHandler"/> to the specified
|
|
29
|
-
/// <see cref="AuthenticationBuilder"/>, which enables <%= name %> authentication capabilities.
|
|
30
|
-
/// </summary>
|
|
31
|
-
/// <param name="builder">The authentication builder.</param>
|
|
32
|
-
/// <param name="configuration">The delegate used to configure the <%= name %> options.</param>
|
|
33
|
-
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
|
|
34
|
-
public static AuthenticationBuilder Add<%= name %>(
|
|
35
|
-
[NotNull] this AuthenticationBuilder builder,
|
|
36
|
-
[NotNull] Action<<%= name %>AuthenticationOptions> configuration)
|
|
37
|
-
{
|
|
38
|
-
return builder.Add<%= name %>(<%= name %>AuthenticationDefaults.AuthenticationScheme, configuration);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/// <summary>
|
|
42
|
-
/// Adds <see cref="<%= name %>AuthenticationHandler"/> to the specified
|
|
43
|
-
/// <see cref="AuthenticationBuilder"/>, which enables <%= name %> authentication capabilities.
|
|
44
|
-
/// </summary>
|
|
45
|
-
/// <param name="builder">The authentication builder.</param>
|
|
46
|
-
/// <param name="scheme">The authentication scheme associated with this instance.</param>
|
|
47
|
-
/// <param name="configuration">The delegate used to configure the <%= name %> options.</param>
|
|
48
|
-
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
|
|
49
|
-
public static AuthenticationBuilder Add<%= name %>(
|
|
50
|
-
[NotNull] this AuthenticationBuilder builder,
|
|
51
|
-
[NotNull] string scheme,
|
|
52
|
-
[NotNull] Action<<%= name %>AuthenticationOptions> configuration)
|
|
53
|
-
{
|
|
54
|
-
return builder.Add<%= name %>(scheme, <%= name %>AuthenticationDefaults.DisplayName, configuration);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/// <summary>
|
|
58
|
-
/// Adds <see cref="<%= name %>AuthenticationHandler"/> to the specified
|
|
59
|
-
/// <see cref="AuthenticationBuilder"/>, which enables <%= name %> authentication capabilities.
|
|
60
|
-
/// </summary>
|
|
61
|
-
/// <param name="builder">The authentication builder.</param>
|
|
62
|
-
/// <param name="scheme">The authentication scheme associated with this instance.</param>
|
|
63
|
-
/// <param name="caption">The optional display name associated with this instance.</param>
|
|
64
|
-
/// <param name="configuration">The delegate used to configure the <%= name %> options.</param>
|
|
65
|
-
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
|
|
66
|
-
public static AuthenticationBuilder Add<%= name %>(
|
|
67
|
-
[NotNull] this AuthenticationBuilder builder,
|
|
68
|
-
[NotNull] string scheme,
|
|
69
|
-
[CanBeNull] string caption,
|
|
70
|
-
[NotNull] Action<<%= name %>AuthenticationOptions> configuration)
|
|
71
|
-
{
|
|
72
|
-
return builder.AddOAuth<<%= name %>AuthenticationOptions, <%= name %>AuthenticationHandler>(scheme, caption, configuration);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
|
3
|
+
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
|
|
4
|
+
* for more information concerning the license and the contributors participating to this project.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
using AspNet.Security.OAuth.<%= name %>;
|
|
8
|
+
|
|
9
|
+
namespace Microsoft.Extensions.DependencyInjection;
|
|
10
|
+
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// Extension methods to add <%= name %> authentication capabilities to an HTTP application pipeline.
|
|
13
|
+
/// </summary>
|
|
14
|
+
public static class <%= name %>AuthenticationExtensions
|
|
15
|
+
{
|
|
16
|
+
/// <summary>
|
|
17
|
+
/// Adds <see cref="<%= name %>AuthenticationHandler"/> to the specified
|
|
18
|
+
/// <see cref="AuthenticationBuilder"/>, which enables <%= name %> authentication capabilities.
|
|
19
|
+
/// </summary>
|
|
20
|
+
/// <param name="builder">The authentication builder.</param>
|
|
21
|
+
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
|
|
22
|
+
public static AuthenticationBuilder Add<%= name %>([NotNull] this AuthenticationBuilder builder)
|
|
23
|
+
{
|
|
24
|
+
return builder.Add<%= name %>(<%= name %>AuthenticationDefaults.AuthenticationScheme, options => { });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// <summary>
|
|
28
|
+
/// Adds <see cref="<%= name %>AuthenticationHandler"/> to the specified
|
|
29
|
+
/// <see cref="AuthenticationBuilder"/>, which enables <%= name %> authentication capabilities.
|
|
30
|
+
/// </summary>
|
|
31
|
+
/// <param name="builder">The authentication builder.</param>
|
|
32
|
+
/// <param name="configuration">The delegate used to configure the <%= name %> options.</param>
|
|
33
|
+
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
|
|
34
|
+
public static AuthenticationBuilder Add<%= name %>(
|
|
35
|
+
[NotNull] this AuthenticationBuilder builder,
|
|
36
|
+
[NotNull] Action<<%= name %>AuthenticationOptions> configuration)
|
|
37
|
+
{
|
|
38
|
+
return builder.Add<%= name %>(<%= name %>AuthenticationDefaults.AuthenticationScheme, configuration);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// <summary>
|
|
42
|
+
/// Adds <see cref="<%= name %>AuthenticationHandler"/> to the specified
|
|
43
|
+
/// <see cref="AuthenticationBuilder"/>, which enables <%= name %> authentication capabilities.
|
|
44
|
+
/// </summary>
|
|
45
|
+
/// <param name="builder">The authentication builder.</param>
|
|
46
|
+
/// <param name="scheme">The authentication scheme associated with this instance.</param>
|
|
47
|
+
/// <param name="configuration">The delegate used to configure the <%= name %> options.</param>
|
|
48
|
+
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
|
|
49
|
+
public static AuthenticationBuilder Add<%= name %>(
|
|
50
|
+
[NotNull] this AuthenticationBuilder builder,
|
|
51
|
+
[NotNull] string scheme,
|
|
52
|
+
[NotNull] Action<<%= name %>AuthenticationOptions> configuration)
|
|
53
|
+
{
|
|
54
|
+
return builder.Add<%= name %>(scheme, <%= name %>AuthenticationDefaults.DisplayName, configuration);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/// <summary>
|
|
58
|
+
/// Adds <see cref="<%= name %>AuthenticationHandler"/> to the specified
|
|
59
|
+
/// <see cref="AuthenticationBuilder"/>, which enables <%= name %> authentication capabilities.
|
|
60
|
+
/// </summary>
|
|
61
|
+
/// <param name="builder">The authentication builder.</param>
|
|
62
|
+
/// <param name="scheme">The authentication scheme associated with this instance.</param>
|
|
63
|
+
/// <param name="caption">The optional display name associated with this instance.</param>
|
|
64
|
+
/// <param name="configuration">The delegate used to configure the <%= name %> options.</param>
|
|
65
|
+
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
|
|
66
|
+
public static AuthenticationBuilder Add<%= name %>(
|
|
67
|
+
[NotNull] this AuthenticationBuilder builder,
|
|
68
|
+
[NotNull] string scheme,
|
|
69
|
+
[CanBeNull] string caption,
|
|
70
|
+
[NotNull] Action<<%= name %>AuthenticationOptions> configuration)
|
|
71
|
+
{
|
|
72
|
+
return builder.AddOAuth<<%= name %>AuthenticationOptions, <%= name %>AuthenticationHandler>(scheme, caption, configuration);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
|
3
|
-
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
|
|
4
|
-
* for more information concerning the license and the contributors participating to this project.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
using System.Net.Http;
|
|
8
|
-
using System.Net.Http.Headers;
|
|
9
|
-
using System.Security.Claims;
|
|
10
|
-
using System.Text.Encodings.Web;
|
|
11
|
-
using System.Text.Json;
|
|
12
|
-
using Microsoft.AspNetCore.WebUtilities;
|
|
13
|
-
using Microsoft.Extensions.Logging;
|
|
14
|
-
using Microsoft.Extensions.Options;
|
|
15
|
-
|
|
16
|
-
namespace AspNet.Security.OAuth.<%= name %>;
|
|
17
|
-
|
|
18
|
-
/// <summary>
|
|
19
|
-
/// Defines a handler for authentication using <%= name %>.
|
|
20
|
-
/// </summary>
|
|
21
|
-
public partial class <%= name %>AuthenticationHandler : OAuthHandler<<%= name %>AuthenticationOptions>
|
|
22
|
-
{
|
|
23
|
-
/// <summary>
|
|
24
|
-
/// Initializes a new instance of the <see cref="<%= name %>AuthenticationHandler"/> class.
|
|
25
|
-
/// </summary>
|
|
26
|
-
/// <param name="options">The authentication options.</param>
|
|
27
|
-
/// <param name="logger">The logger to use.</param>
|
|
28
|
-
/// <param name="encoder">The URL encoder to use.</param>
|
|
29
|
-
public <%= name %>AuthenticationHandler(
|
|
30
|
-
[NotNull] IOptionsMonitor<<%= name %>AuthenticationOptions> options,
|
|
31
|
-
[NotNull] ILoggerFactory logger,
|
|
32
|
-
[NotNull] UrlEncoder encoder)
|
|
33
|
-
: base(options, logger, encoder)
|
|
34
|
-
{
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/// <inheritdoc />
|
|
38
|
-
protected override async Task<AuthenticationTicket> CreateTicketAsync(
|
|
39
|
-
[NotNull] ClaimsIdentity identity,
|
|
40
|
-
[NotNull] AuthenticationProperties properties,
|
|
41
|
-
[NotNull] OAuthTokenResponse tokens)
|
|
42
|
-
{
|
|
43
|
-
var endpoint = Options.UserInformationEndpoint;
|
|
44
|
-
|
|
45
|
-
// TODO Append any additional query string parameters required
|
|
46
|
-
////endpoint = QueryHelpers.AddQueryString(endpoint, "token", tokens.AccessToken);
|
|
47
|
-
|
|
48
|
-
using var request = new HttpRequestMessage(HttpMethod.Get, endpoint);
|
|
49
|
-
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
|
50
|
-
|
|
51
|
-
// TODO Add any HTTP request headers required
|
|
52
|
-
////request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", tokens.AccessToken);
|
|
53
|
-
|
|
54
|
-
using var response = await Backchannel.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, Context.RequestAborted);
|
|
55
|
-
if (!response.IsSuccessStatusCode)
|
|
56
|
-
{
|
|
57
|
-
await Log.UserProfileErrorAsync(Logger, response, Context.RequestAborted);
|
|
58
|
-
throw new HttpRequestException("An error occurred while retrieving the user profile from <%= name %>.");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
using var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
|
|
62
|
-
|
|
63
|
-
var principal = new ClaimsPrincipal(identity);
|
|
64
|
-
var context = new OAuthCreatingTicketContext(principal, properties, Context, Scheme, Options, Backchannel, tokens, payload.RootElement);
|
|
65
|
-
context.RunClaimActions();
|
|
66
|
-
|
|
67
|
-
await Events.CreatingTicket(context);
|
|
68
|
-
return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
private static partial class Log
|
|
72
|
-
{
|
|
73
|
-
internal static async Task UserProfileErrorAsync(ILogger logger, HttpResponseMessage response, CancellationToken cancellationToken)
|
|
74
|
-
{
|
|
75
|
-
UserProfileError(
|
|
76
|
-
logger,
|
|
77
|
-
response.StatusCode,
|
|
78
|
-
response.Headers.ToString(),
|
|
79
|
-
await response.Content.ReadAsStringAsync(cancellationToken));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
[LoggerMessage(1, LogLevel.Error, "An error occurred while retrieving the user profile: the remote server returned a {Status} response with the following payload: {Headers} {Body}.")]
|
|
83
|
-
private static partial void UserProfileError(
|
|
84
|
-
ILogger logger,
|
|
85
|
-
System.Net.HttpStatusCode status,
|
|
86
|
-
string headers,
|
|
87
|
-
string body);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
|
3
|
+
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
|
|
4
|
+
* for more information concerning the license and the contributors participating to this project.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
using System.Net.Http;
|
|
8
|
+
using System.Net.Http.Headers;
|
|
9
|
+
using System.Security.Claims;
|
|
10
|
+
using System.Text.Encodings.Web;
|
|
11
|
+
using System.Text.Json;
|
|
12
|
+
using Microsoft.AspNetCore.WebUtilities;
|
|
13
|
+
using Microsoft.Extensions.Logging;
|
|
14
|
+
using Microsoft.Extensions.Options;
|
|
15
|
+
|
|
16
|
+
namespace AspNet.Security.OAuth.<%= name %>;
|
|
17
|
+
|
|
18
|
+
/// <summary>
|
|
19
|
+
/// Defines a handler for authentication using <%= name %>.
|
|
20
|
+
/// </summary>
|
|
21
|
+
public partial class <%= name %>AuthenticationHandler : OAuthHandler<<%= name %>AuthenticationOptions>
|
|
22
|
+
{
|
|
23
|
+
/// <summary>
|
|
24
|
+
/// Initializes a new instance of the <see cref="<%= name %>AuthenticationHandler"/> class.
|
|
25
|
+
/// </summary>
|
|
26
|
+
/// <param name="options">The authentication options.</param>
|
|
27
|
+
/// <param name="logger">The logger to use.</param>
|
|
28
|
+
/// <param name="encoder">The URL encoder to use.</param>
|
|
29
|
+
public <%= name %>AuthenticationHandler(
|
|
30
|
+
[NotNull] IOptionsMonitor<<%= name %>AuthenticationOptions> options,
|
|
31
|
+
[NotNull] ILoggerFactory logger,
|
|
32
|
+
[NotNull] UrlEncoder encoder)
|
|
33
|
+
: base(options, logger, encoder)
|
|
34
|
+
{
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/// <inheritdoc />
|
|
38
|
+
protected override async Task<AuthenticationTicket> CreateTicketAsync(
|
|
39
|
+
[NotNull] ClaimsIdentity identity,
|
|
40
|
+
[NotNull] AuthenticationProperties properties,
|
|
41
|
+
[NotNull] OAuthTokenResponse tokens)
|
|
42
|
+
{
|
|
43
|
+
var endpoint = Options.UserInformationEndpoint;
|
|
44
|
+
|
|
45
|
+
// TODO Append any additional query string parameters required
|
|
46
|
+
////endpoint = QueryHelpers.AddQueryString(endpoint, "token", tokens.AccessToken);
|
|
47
|
+
|
|
48
|
+
using var request = new HttpRequestMessage(HttpMethod.Get, endpoint);
|
|
49
|
+
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
|
50
|
+
|
|
51
|
+
// TODO Add any HTTP request headers required
|
|
52
|
+
////request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", tokens.AccessToken);
|
|
53
|
+
|
|
54
|
+
using var response = await Backchannel.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, Context.RequestAborted);
|
|
55
|
+
if (!response.IsSuccessStatusCode)
|
|
56
|
+
{
|
|
57
|
+
await Log.UserProfileErrorAsync(Logger, response, Context.RequestAborted);
|
|
58
|
+
throw new HttpRequestException("An error occurred while retrieving the user profile from <%= name %>.");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
using var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
|
|
62
|
+
|
|
63
|
+
var principal = new ClaimsPrincipal(identity);
|
|
64
|
+
var context = new OAuthCreatingTicketContext(principal, properties, Context, Scheme, Options, Backchannel, tokens, payload.RootElement);
|
|
65
|
+
context.RunClaimActions();
|
|
66
|
+
|
|
67
|
+
await Events.CreatingTicket(context);
|
|
68
|
+
return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private static partial class Log
|
|
72
|
+
{
|
|
73
|
+
internal static async Task UserProfileErrorAsync(ILogger logger, HttpResponseMessage response, CancellationToken cancellationToken)
|
|
74
|
+
{
|
|
75
|
+
UserProfileError(
|
|
76
|
+
logger,
|
|
77
|
+
response.StatusCode,
|
|
78
|
+
response.Headers.ToString(),
|
|
79
|
+
await response.Content.ReadAsStringAsync(cancellationToken));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
[LoggerMessage(1, LogLevel.Error, "An error occurred while retrieving the user profile: the remote server returned a {Status} response with the following payload: {Headers} {Body}.")]
|
|
83
|
+
private static partial void UserProfileError(
|
|
84
|
+
ILogger logger,
|
|
85
|
+
System.Net.HttpStatusCode status,
|
|
86
|
+
string headers,
|
|
87
|
+
string body);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
|
3
|
-
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
|
|
4
|
-
* for more information concerning the license and the contributors participating to this project.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
using System.Security.Claims;
|
|
8
|
-
|
|
9
|
-
namespace AspNet.Security.OAuth.<%= name %>;
|
|
10
|
-
|
|
11
|
-
/// <summary>
|
|
12
|
-
/// Defines a set of options used by <see cref="<%= name %>AuthenticationHandler"/>.
|
|
13
|
-
/// </summary>
|
|
14
|
-
public class <%= name %>AuthenticationOptions : OAuthOptions
|
|
15
|
-
{
|
|
16
|
-
/// <summary>
|
|
17
|
-
/// Initializes a new instance of the <see cref="<%= name %>AuthenticationOptions"/> class.
|
|
18
|
-
/// </summary>
|
|
19
|
-
public <%= name %>AuthenticationOptions()
|
|
20
|
-
{
|
|
21
|
-
ClaimsIssuer = <%= name %>AuthenticationDefaults.Issuer;
|
|
22
|
-
CallbackPath = <%= name %>AuthenticationDefaults.CallbackPath;
|
|
23
|
-
|
|
24
|
-
AuthorizationEndpoint = <%= name %>AuthenticationDefaults.AuthorizationEndpoint;
|
|
25
|
-
TokenEndpoint = <%= name %>AuthenticationDefaults.TokenEndpoint;
|
|
26
|
-
UserInformationEndpoint = <%= name %>AuthenticationDefaults.UserInformationEndpoint;
|
|
27
|
-
|
|
28
|
-
// TODO Add any required scopes
|
|
29
|
-
// Scope.Add("?");
|
|
30
|
-
|
|
31
|
-
// TODO Map any claims
|
|
32
|
-
// ClaimActions.MapJsonKey(ClaimTypes.Email, "?");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
|
3
|
+
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
|
|
4
|
+
* for more information concerning the license and the contributors participating to this project.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
using System.Security.Claims;
|
|
8
|
+
|
|
9
|
+
namespace AspNet.Security.OAuth.<%= name %>;
|
|
10
|
+
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// Defines a set of options used by <see cref="<%= name %>AuthenticationHandler"/>.
|
|
13
|
+
/// </summary>
|
|
14
|
+
public class <%= name %>AuthenticationOptions : OAuthOptions
|
|
15
|
+
{
|
|
16
|
+
/// <summary>
|
|
17
|
+
/// Initializes a new instance of the <see cref="<%= name %>AuthenticationOptions"/> class.
|
|
18
|
+
/// </summary>
|
|
19
|
+
public <%= name %>AuthenticationOptions()
|
|
20
|
+
{
|
|
21
|
+
ClaimsIssuer = <%= name %>AuthenticationDefaults.Issuer;
|
|
22
|
+
CallbackPath = <%= name %>AuthenticationDefaults.CallbackPath;
|
|
23
|
+
|
|
24
|
+
AuthorizationEndpoint = <%= name %>AuthenticationDefaults.AuthorizationEndpoint;
|
|
25
|
+
TokenEndpoint = <%= name %>AuthenticationDefaults.TokenEndpoint;
|
|
26
|
+
UserInformationEndpoint = <%= name %>AuthenticationDefaults.UserInformationEndpoint;
|
|
27
|
+
|
|
28
|
+
// TODO Add any required scopes
|
|
29
|
+
// Scope.Add("?");
|
|
30
|
+
|
|
31
|
+
// TODO Map any claims
|
|
32
|
+
// ClaimActions.MapJsonKey(ClaimTypes.Email, "?");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
<Project Sdk="Microsoft.NET.Sdk">
|
|
2
|
-
|
|
3
|
-
<PropertyGroup>
|
|
4
|
-
<PackageValidationBaselineVersion><%= currentVersion %></PackageValidationBaselineVersion>
|
|
5
|
-
<TargetFrameworks>$(DefaultNetCoreTargetFramework)</TargetFrameworks>
|
|
6
|
-
</PropertyGroup>
|
|
7
|
-
|
|
8
|
-
<!-- This property group is required until the new provider is first published to NuGet.org -->
|
|
9
|
-
<PropertyGroup>
|
|
10
|
-
<DisablePackageBaselineValidation>true</DisablePackageBaselineValidation>
|
|
11
|
-
</PropertyGroup>
|
|
12
|
-
|
|
13
|
-
<PropertyGroup>
|
|
14
|
-
<Description>ASP.NET Core security provider enabling <%= name %> authentication.</Description>
|
|
15
|
-
<Authors><%= authorname %></Authors>
|
|
16
|
-
<PackageTags><%= name.toLowerCase() %>;aspnetcore;authentication;oauth;security</PackageTags>
|
|
17
|
-
</PropertyGroup>
|
|
18
|
-
|
|
19
|
-
<ItemGroup>
|
|
20
|
-
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
|
21
|
-
<PackageReference Include="JetBrains.Annotations" PrivateAssets="All" />
|
|
22
|
-
</ItemGroup>
|
|
23
|
-
|
|
24
|
-
</Project>
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
2
|
+
|
|
3
|
+
<PropertyGroup>
|
|
4
|
+
<PackageValidationBaselineVersion><%= currentVersion %></PackageValidationBaselineVersion>
|
|
5
|
+
<TargetFrameworks>$(DefaultNetCoreTargetFramework)</TargetFrameworks>
|
|
6
|
+
</PropertyGroup>
|
|
7
|
+
|
|
8
|
+
<!-- This property group is required until the new provider is first published to NuGet.org -->
|
|
9
|
+
<PropertyGroup>
|
|
10
|
+
<DisablePackageBaselineValidation>true</DisablePackageBaselineValidation>
|
|
11
|
+
</PropertyGroup>
|
|
12
|
+
|
|
13
|
+
<PropertyGroup>
|
|
14
|
+
<Description>ASP.NET Core security provider enabling <%= name %> authentication.</Description>
|
|
15
|
+
<Authors><%= authorname %></Authors>
|
|
16
|
+
<PackageTags><%= name.toLowerCase() %>;aspnetcore;authentication;oauth;security</PackageTags>
|
|
17
|
+
</PropertyGroup>
|
|
18
|
+
|
|
19
|
+
<ItemGroup>
|
|
20
|
+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
|
21
|
+
<PackageReference Include="JetBrains.Annotations" PrivateAssets="All" />
|
|
22
|
+
</ItemGroup>
|
|
23
|
+
|
|
24
|
+
</Project>
|
package/package.json
CHANGED
|
@@ -1,40 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "generator-aspnet-oauth",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Yeoman generator for OAuth Providers for ASP.NET Core",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"main": "app/index.js",
|
|
7
|
-
"repository":
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
},
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "generator-aspnet-oauth",
|
|
3
|
+
"version": "9.0.1",
|
|
4
|
+
"description": "Yeoman generator for OAuth Providers for ASP.NET Core",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "app/index.js",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/aspnet-contrib/generator-aspnet-oauth.git"
|
|
10
|
+
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=22"
|
|
13
|
+
},
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Jerrie Pelser",
|
|
16
|
+
"email": "jerrie@jerriepelser.com",
|
|
17
|
+
"url": "https://github.com/jerriep"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "mocha"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"generators"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [
|
|
26
|
+
"yeoman-generator",
|
|
27
|
+
"ASP.NET",
|
|
28
|
+
"aspnet",
|
|
29
|
+
"oauth"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"cross-fetch": "^4.1.0",
|
|
33
|
+
"query-string": "^7.1.1",
|
|
34
|
+
"yosay": "^2.0.2",
|
|
35
|
+
"yeoman-generator": "^5.7.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"glob": "^11.0.1",
|
|
39
|
+
"mocha": "^11.1.0",
|
|
40
|
+
"yeoman-assert": "^3.1.1",
|
|
41
|
+
"yeoman-test": "^6.3.0"
|
|
42
|
+
}
|
|
43
|
+
}
|