Index()
28 | {
29 | ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
30 |
31 | Session.Clear();
32 | Session.Abandon();
33 | Request.GetOwinContext().Authentication.SignOut("Cookies");
34 |
35 | //Intialize DiscoverPolicy
36 | DiscoveryPolicy dpolicy = new DiscoveryPolicy();
37 | dpolicy.RequireHttps = true;
38 | dpolicy.ValidateIssuerName = true;
39 |
40 |
41 | //Assign the Sandbox Discovery url for the Apps' Dev clientid and clientsecret that you use
42 | //Or
43 | //Assign the Production Discovery url for the Apps' Production clientid and clientsecret that you use
44 |
45 | string discoveryUrl = ConfigurationManager.AppSettings["DiscoveryUrl"];
46 |
47 | if (discoveryUrl != null && AppController.clientid != null && AppController.clientsecret != null)
48 | {
49 | discoveryClient = new DiscoveryClient(discoveryUrl);
50 | }
51 | else
52 | {
53 | Exception ex= new Exception("Discovery Url missing!");
54 | throw ex;
55 | }
56 | doc = await discoveryClient.GetAsync();
57 |
58 | if (doc.StatusCode == HttpStatusCode.OK)
59 | {
60 | //Authorize endpoint
61 | AppController.authorizeUrl = doc.AuthorizeEndpoint;
62 |
63 | //Token endpoint
64 | AppController.tokenEndpoint = doc.TokenEndpoint;
65 |
66 | //Token Revocation enpoint
67 | AppController.revocationEndpoint = doc.RevocationEndpoint;
68 |
69 | //UserInfo endpoint
70 | AppController.userinfoEndpoint = doc.UserInfoEndpoint;
71 |
72 | //Issuer endpoint
73 | AppController.issuerEndpoint = doc.Issuer;
74 |
75 | //JWKS Keys
76 | AppController.keys = doc.KeySet.Keys;
77 | }
78 |
79 | //Get mod and exponent value
80 | foreach (var key in AppController.keys)
81 | {
82 | if (key.N != null)
83 | {
84 | //Mod
85 | AppController.mod = key.N;
86 | }
87 | if (key.E != null)
88 | {
89 | //Exponent
90 | AppController.expo = key.E;
91 | }
92 | }
93 |
94 |
95 |
96 | return View();
97 | }
98 |
99 |
100 |
101 | public ActionResult MyAction(string submitButton)
102 | {
103 | switch (submitButton)
104 | {
105 | case "C2QB":
106 | // delegate sending to C2QB Action
107 | return (C2QB());
108 | case "GetAppNow":
109 | // call another action to GetAppNow
110 | return (GetAppNow());
111 | case "SIWI":
112 | // call another action to SIWI
113 | return (SIWI());
114 | default:
115 | // If they've submitted the form without a submitButton,
116 | // just return the view again.
117 | return (View());
118 | }
119 | }
120 |
121 | private ActionResult C2QB()
122 | {
123 | scope = OidcScopes.Accounting.GetStringValue() + " " + OidcScopes.Payment.GetStringValue();
124 | authorizeUrl = GetAuthorizeUrl(scope);
125 | // perform the redirect here.
126 | return Redirect(authorizeUrl);
127 | }
128 |
129 | private ActionResult GetAppNow()
130 | {
131 | scope = OidcScopes.Accounting.GetStringValue() + " " + OidcScopes.Payment.GetStringValue() + " " + OidcScopes.OpenId.GetStringValue() + " " + OidcScopes.Address.GetStringValue()
132 | + " " + OidcScopes.Email.GetStringValue() + " " + OidcScopes.Phone.GetStringValue()
133 | + " " + OidcScopes.Profile.GetStringValue();
134 | authorizeUrl = GetAuthorizeUrl(scope);
135 | // perform the redirect here.
136 | return Redirect(authorizeUrl);
137 | }
138 |
139 | private ActionResult SIWI()
140 | {
141 | scope = OidcScopes.OpenId.GetStringValue() + " " + OidcScopes.Address.GetStringValue()
142 | + " " + OidcScopes.Email.GetStringValue() + " " + OidcScopes.Phone.GetStringValue()
143 | + " " + OidcScopes.Profile.GetStringValue();
144 | authorizeUrl = GetAuthorizeUrl(scope);
145 | // perform the redirect here.
146 | return Redirect(authorizeUrl);
147 | }
148 |
149 |
150 |
151 |
152 | private void SetTempState(string state)
153 | {
154 | var tempId = new ClaimsIdentity("TempState");
155 | tempId.AddClaim(new Claim("state", state));
156 |
157 | Request.GetOwinContext().Authentication.SignIn(tempId);
158 | }
159 |
160 | private string GetAuthorizeUrl(string scope)
161 | {
162 | var state = Guid.NewGuid().ToString("N");
163 |
164 | SetTempState(state);
165 |
166 | //Make Authorization request
167 | var request = new AuthorizeRequest(AppController.authorizeUrl);
168 |
169 | string url = request.CreateAuthorizeUrl(
170 | clientId: AppController.clientid,
171 | responseType: OidcConstants.AuthorizeResponse.Code,
172 | scope: scope,
173 | redirectUri: AppController.redirectUrl,
174 | state: state);
175 |
176 | return url;
177 | }
178 |
179 |
180 | }
181 | }
--------------------------------------------------------------------------------
/MvcCodeFlowClientManual/Global.asax:
--------------------------------------------------------------------------------
1 | <%@ Application Codebehind="Global.asax.cs" Inherits="MvcCodeFlowClientManual.MvcApplication" Language="C#" %>
2 |
--------------------------------------------------------------------------------
/MvcCodeFlowClientManual/Global.asax.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Mvc;
2 | using System.Web.Optimization;
3 | using System.Web.Routing;
4 |
5 | namespace MvcCodeFlowClientManual
6 | {
7 | public class MvcApplication : System.Web.HttpApplication
8 | {
9 | protected void Application_Start()
10 | {
11 | AreaRegistration.RegisterAllAreas();
12 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
13 | RouteConfig.RegisterRoutes(RouteTable.Routes);
14 | BundleConfig.RegisterBundles(BundleTable.Bundles);
15 | }
16 |
17 | void Application_EndRequest(object sender, System.EventArgs e)
18 | {
19 | // If the user is not authorised to see this page or access this function, send them to the error page.
20 | if (Response.StatusCode == 401)
21 | {
22 | Response.ClearContent();
23 | Response.RedirectToRoute("ErrorHandler", (RouteTable.Routes["ErrorHandler"] as Route).Defaults);
24 | }
25 | }
26 |
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/MvcCodeFlowClientManual/MVC Manual Code Flow Client.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | 44312
6 | 600
7 | True
8 | False
9 | False
10 |
11 | False
12 | 600
13 | ShowAllFiles
14 |
15 |
16 |
17 |
18 |
19 | Debug|Any CPU
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | CurrentPage
28 | True
29 | False
30 | False
31 | False
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | True
41 | True
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/MvcCodeFlowClientManual/MVC Manual Code Flow Client.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVC Manual Code Flow Client", "MVC Manual Code Flow Client.csproj", "{C67DB8BB-6083-436D-9748-4BDD9EC8C0EB}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {C67DB8BB-6083-436D-9748-4BDD9EC8C0EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {C67DB8BB-6083-436D-9748-4BDD9EC8C0EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {C67DB8BB-6083-436D-9748-4BDD9EC8C0EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {C67DB8BB-6083-436D-9748-4BDD9EC8C0EB}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/MvcCodeFlowClientManual/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("MvcCodeFlowClientManual")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("MvcCodeFlowClientManual")]
12 | [assembly: AssemblyCopyright("Copyright © 2014")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("c955b986-8715-42e1-9f26-c75248466268")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Revision and Build Numbers
32 | // by using the '*' as shown below:
33 | [assembly: AssemblyVersion("1.0.0.0")]
34 | [assembly: AssemblyFileVersion("1.0.0.0")]
35 |
--------------------------------------------------------------------------------
/MvcCodeFlowClientManual/Scripts/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | Popper.js
4 |
5 |
6 | A library used to position poppers in web applications.
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | ## Wut? Poppers?
24 |
25 | A popper is an element on the screen which "pops out" from the natural flow of your application.
26 | Common examples of poppers are tooltips, popovers and drop-downs.
27 |
28 |
29 | ## So, yet another tooltip library?
30 |
31 | Well, basically, **no**.
32 | Popper.js is a **positioning engine**, its purpose is to calculate the position of an element
33 | to make it possible to position it near a given reference element.
34 |
35 | The engine is completely modular and most of its features are implemented as **modifiers**
36 | (similar to middlewares or plugins).
37 | The whole code base is written in ES2015 and its features are automatically tested on real browsers thanks to [SauceLabs](https://saucelabs.com/) and [TravisCI](https://travis-ci.org/).
38 |
39 | Popper.js has zero dependencies. No jQuery, no LoDash, nothing.
40 | It's used by big companies like [Twitter in Bootstrap v4](https://getbootstrap.com/), [Microsoft in WebClipper](https://github.com/OneNoteDev/WebClipper) and [Atlassian in AtlasKit](https://aui-cdn.atlassian.com/atlaskit/registry/).
41 |
42 | ### Popper.js
43 |
44 | This is the engine, the library that computes and, optionally, applies the styles to
45 | the poppers.
46 |
47 | Some of the key points are:
48 |
49 | - Position elements keeping them in their original DOM context (doesn't mess with your DOM!);
50 | - Allows to export the computed informations to integrate with React and other view libraries;
51 | - Supports Shadow DOM elements;
52 | - Completely customizable thanks to the modifiers based structure;
53 |
54 | Visit our [project page](https://fezvrasta.github.io/popper.js) to see a lot of examples of what you can do with Popper.js!
55 |
56 | Find [the documentation here](/docs/_includes/popper-documentation.md).
57 |
58 |
59 | ### Tooltip.js
60 |
61 | Since lots of users just need a simple way to integrate powerful tooltips in their projects,
62 | we created **Tooltip.js**.
63 | It's a small library that makes it easy to automatically create tooltips using as engine Popper.js.
64 | Its API is almost identical to the famous tooltip system of Bootstrap, in this way it will be
65 | easy to integrate it in your projects.
66 | The tooltips generated by Tooltip.js are accessible thanks to the `aria` tags.
67 |
68 | Find [the documentation here](/docs/_includes/tooltip-documentation.md).
69 |
70 |
71 | ## Installation
72 | Popper.js is available on the following package managers and CDNs:
73 |
74 | | Source | |
75 | |:-------|:---------------------------------------------------------------------------------|
76 | | npm | `npm install popper.js --save` |
77 | | yarn | `yarn add popper.js` |
78 | | NuGet | `PM> Install-Package popper.js` |
79 | | Bower | `bower install popper.js --save` |
80 | | unpkg | [`https://unpkg.com/popper.js`](https://unpkg.com/popper.js) |
81 | | cdnjs | [`https://cdnjs.com/libraries/popper.js`](https://cdnjs.com/libraries/popper.js) |
82 |
83 | Tooltip.js as well:
84 |
85 | | Source | |
86 | |:-------|:---------------------------------------------------------------------------------|
87 | | npm | `npm install tooltip.js --save` |
88 | | yarn | `yarn add tooltip.js` |
89 | | Bower* | `bower install tooltip.js=https://unpkg.com/tooltip.js --save` |
90 | | unpkg | [`https://unpkg.com/tooltip.js`](https://unpkg.com/tooltip.js) |
91 | | cdnjs | [`https://cdnjs.com/libraries/popper.js`](https://cdnjs.com/libraries/popper.js) |
92 |
93 | \*: Bower isn't officially supported, it can be used to install Tooltip.js only trough the unpkg.com CDN. This method has the limitation of not being able to define a specific version of the library. Bower and Popper.js suggests to use npm or Yarn for your projects.
94 | For more info, [read the related issue](https://github.com/FezVrasta/popper.js/issues/390).
95 |
96 | ### Dist targets
97 |
98 | Popper.js is currently shipped with 3 targets in mind: UMD, ESM and ESNext.
99 |
100 | - UMD - Universal Module Definition: AMD, RequireJS and globals;
101 | - ESM - ES Modules: For webpack/Rollup or browser supporting the spec;
102 | - ESNext: Available in `dist/`, can be used with webpack and `babel-preset-env`;
103 |
104 | Make sure to use the right one for your needs. If you want to import it with a `