├── .gitignore
├── Base64UrlDecoder.cs
├── JsonWebToken.cs
├── LICENSE
├── Properties
└── AssemblyInfo.cs
├── README.md
├── SPOAuthExtension.cs
├── SPOAuthFiddlerExt.csproj
├── SPOAuthFiddlerExt.sln
├── SPOAuthRequestControl.Designer.cs
├── SPOAuthRequestControl.cs
├── SPOAuthRequestControl.resx
└── packages.config
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 |
11 | [Dd]ebug/
12 | [Rr]elease/
13 | x64/
14 | build/
15 | [Bb]in/
16 | [Oo]bj/
17 |
18 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
19 | !packages/*/build/
20 |
21 | # MSTest test Results
22 | [Tt]est[Rr]esult*/
23 | [Bb]uild[Ll]og.*
24 |
25 | *_i.c
26 | *_p.c
27 | *.ilk
28 | *.meta
29 | *.obj
30 | *.pch
31 | *.pdb
32 | *.pgc
33 | *.pgd
34 | *.rsp
35 | *.sbr
36 | *.tlb
37 | *.tli
38 | *.tlh
39 | *.tmp
40 | *.tmp_proj
41 | *.log
42 | *.vspscc
43 | *.vssscc
44 | .builds
45 | *.pidb
46 | *.log
47 | *.scc
48 |
49 | # Visual C++ cache files
50 | ipch/
51 | *.aps
52 | *.ncb
53 | *.opensdf
54 | *.sdf
55 | *.cachefile
56 |
57 | # Visual Studio profiler
58 | *.psess
59 | *.vsp
60 | *.vspx
61 |
62 | # Guidance Automation Toolkit
63 | *.gpState
64 |
65 | # ReSharper is a .NET coding add-in
66 | _ReSharper*/
67 | *.[Rr]e[Ss]harper
68 |
69 | # TeamCity is a build add-in
70 | _TeamCity*
71 |
72 | # DotCover is a Code Coverage Tool
73 | *.dotCover
74 |
75 | # NCrunch
76 | *.ncrunch*
77 | .*crunch*.local.xml
78 |
79 | # Installshield output folder
80 | [Ee]xpress/
81 |
82 | # DocProject is a documentation generator add-in
83 | DocProject/buildhelp/
84 | DocProject/Help/*.HxT
85 | DocProject/Help/*.HxC
86 | DocProject/Help/*.hhc
87 | DocProject/Help/*.hhk
88 | DocProject/Help/*.hhp
89 | DocProject/Help/Html2
90 | DocProject/Help/html
91 |
92 | # Click-Once directory
93 | publish/
94 |
95 | # Publish Web Output
96 | *.Publish.xml
97 | *.pubxml
98 |
99 | # NuGet Packages Directory
100 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
101 | packages/
102 |
103 | # Windows Azure Build Output
104 | csx
105 | *.build.csdef
106 |
107 | # Windows Store app package directory
108 | AppPackages/
109 |
110 | # Others
111 | sql/
112 | *.Cache
113 | ClientBin/
114 | [Ss]tyle[Cc]op.*
115 | ~$*
116 | *~
117 | *.dbmdl
118 | *.[Pp]ublish.xml
119 | *.pfx
120 | *.publishsettings
121 |
122 | # RIA/Silverlight projects
123 | Generated_Code/
124 |
125 | # Backup & report files from converting an old project file to a newer
126 | # Visual Studio version. Backup files are not needed, because we have git ;-)
127 | _UpgradeReport_Files/
128 | Backup*/
129 | UpgradeLog*.XML
130 | UpgradeLog*.htm
131 |
132 | # SQL Server files
133 | App_Data/*.mdf
134 | App_Data/*.ldf
135 |
136 | # =========================
137 | # Windows detritus
138 | # =========================
139 |
140 | # Windows image file caches
141 | Thumbs.db
142 | ehthumbs.db
143 |
144 | # Folder config file
145 | Desktop.ini
146 |
147 | # Recycle Bin used on file shares
148 | $RECYCLE.BIN/
149 |
150 | # Mac crap
151 | .DS_Store
152 |
--------------------------------------------------------------------------------
/Base64UrlDecoder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Text;
4 |
5 | namespace SPOAuthFiddlerExt
6 | {
7 | public class Base64UrlDecoder
8 | {
9 | ///
10 | /// URL decodes a string.
11 | ///
12 | /// The string to decode.
13 | /// The URL decoded string.
14 | public static string Decode(string arg)
15 | {
16 | return Encoding.UTF8.GetString(DecodeBytes(arg));
17 | }
18 |
19 | ///
20 | /// URL decodes a string into a byte array
21 | ///
22 | /// The string to decode
23 | /// The decoded byte array
24 | public static byte[] DecodeBytes(string value)
25 | {
26 | const char BASE64_PAD_CHARACTER = '=';
27 | const string DOUBLE_BASE64_PAD_CHARACTER = "==";
28 |
29 | const char BASE64_CHARACTER_62 = '+';
30 | const char BASE64URL_CHARACTER_62 = '-';
31 |
32 | const char BASE64_CHARACTER_63 = '/';
33 | const char BASE64URL_CHARACTER_63 = '\u005F';
34 |
35 | byte[] ret;
36 |
37 | if (string.IsNullOrEmpty(value))
38 | {
39 | throw new ArgumentNullException("value", "A null value cannot be decoded.");
40 | }
41 |
42 | string convertedValue = value;
43 |
44 | //Replace "-" with "+"
45 | convertedValue = convertedValue.Replace(BASE64URL_CHARACTER_62, BASE64_CHARACTER_62);
46 | //Replace the ENQ character with "/"
47 | convertedValue = convertedValue.Replace(BASE64URL_CHARACTER_63, BASE64_CHARACTER_63);
48 |
49 | switch (convertedValue.Length % 4)
50 | {
51 | case 0:
52 | {
53 | ret = Convert.FromBase64String(convertedValue);
54 | break;
55 | }
56 | case 2:
57 | {
58 | convertedValue += DOUBLE_BASE64_PAD_CHARACTER;
59 | ret = Convert.FromBase64String(convertedValue);
60 | break;
61 | }
62 | case 3:
63 | {
64 | convertedValue += BASE64_PAD_CHARACTER;
65 | ret = Convert.FromBase64String(convertedValue);
66 | break;
67 | }
68 | default:
69 | {
70 | throw new ArgumentException("Not a valid base64 URL string", value);
71 | }
72 | }
73 |
74 | return ret;
75 | }
76 |
77 | }
78 | }
--------------------------------------------------------------------------------
/JsonWebToken.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Security.Cryptography;
6 | using System.Text;
7 | using System.Web.Script.Serialization;
8 |
9 | namespace SPOAuthFiddlerExt
10 | {
11 | public class JsonWebToken
12 | {
13 | ///
14 | /// The decoded and formatted header of the JWT token
15 | ///
16 | public string Header { get; set; }
17 | ///
18 | /// The decoded and formatted body of the JWT token
19 | ///
20 | public string Body { get; set; }
21 | ///
22 | /// The decoded signature of the JWT token
23 | ///
24 | public string Signature { get; set; }
25 |
26 | ///
27 | /// A dictionary of the claims from the decoded JWT header
28 | ///
29 | public IDictionary HeaderClaims { get; set; }
30 | ///
31 | /// A dictionary of the claims from the decoded JWT body
32 | ///
33 | public IDictionary BodyClaims { get; set; }
34 |
35 | public string IssuerID { get; set; }
36 |
37 | public string ClientID { get; set; }
38 |
39 | public string UserID { get; set; }
40 |
41 | public string TenantID { get; set; }
42 |
43 | public string HostName { get; set; }
44 |
45 |
46 |
47 | ///
48 | /// Given a JWT token, decodes it and splits the parts into a
49 | /// JsonWebToken object.
50 | ///
51 | /// String value formatted according to JWT spec
52 | /// Decoded JsonWebToken object
53 | public static JsonWebToken GetTokenFromString(string token)
54 | {
55 | if(string.IsNullOrEmpty(token))
56 | {
57 | throw new ArgumentException("Token is null or empty", "token");
58 | }
59 | JsonWebToken ret = new JsonWebToken();
60 |
61 | string[] decodedToken = Decode(token);
62 |
63 | ret.Header = JsonWebToken.GetPrettyPrintedJson(decodedToken[0]);
64 | ret.Body = JsonWebToken.GetPrettyPrintedJson(decodedToken[1]);
65 | //signature is not JSON, so output it as the raw value
66 | ret.Signature = decodedToken[2];
67 |
68 | ret.HeaderClaims = JsonConvert.DeserializeObject>(ret.Header);
69 | ret.BodyClaims = JsonConvert.DeserializeObject>(ret.Body);
70 |
71 | if (ret.BodyClaims.ContainsKey("actortoken"))
72 | {
73 | //Actor token is an encoded inner token. Decode it and get the parts.
74 | JsonWebToken actorToken = GetTokenFromString(ret.BodyClaims["actortoken"].ToString());
75 | ret.BodyClaims["actortoken"] = actorToken;
76 | }
77 |
78 | string audience = ret.BodyClaims["aud"].ToString();
79 |
80 | ret.HostName = string.Empty;
81 | ret.TenantID = string.Empty;
82 | ret.ClientID = string.Empty;
83 | ret.UserID = string.Empty;
84 | ret.IssuerID = string.Empty;
85 |
86 | bool isHighTrust = false;
87 | bool isLowTrust = false;
88 | bool isContext = false;
89 |
90 | if(ret.BodyClaims.ContainsKey("appctx") && ret.BodyClaims.ContainsKey("appctxsender") && ret.BodyClaims.ContainsKey("isbrowserhostedapp"))
91 | {
92 | //This is a SharePoint context token
93 | isContext = true;
94 | }
95 | else if (audience.StartsWith("00000003-0000-0ff1-ce00-000000000000/"))
96 | {
97 | //This is a SharePoint access token. Now figure out if it's high or low trust
98 | if(ret.BodyClaims.ContainsKey("actortoken"))
99 | {
100 | //This is a high trust token
101 | isHighTrust = true;
102 | }
103 | else
104 | {
105 | isLowTrust = true;
106 | }
107 | }
108 | else
109 | {
110 | //This is a JWT token but not one from SharePoint
111 | //no-op
112 | }
113 |
114 | if(isHighTrust || isLowTrust || isContext)
115 | {
116 | ret.HostName = audience.Substring(audience.IndexOf("/") + 1, audience.IndexOf("@") - audience.IndexOf("/") - 1);
117 | ret.TenantID = audience.Substring(audience.IndexOf("@") + 1, audience.Length - audience.IndexOf("@") - 1);
118 | if (ret.BodyClaims.ContainsKey("nameid"))
119 | {
120 | ret.UserID = ret.BodyClaims["nameid"].ToString();
121 | }
122 | }
123 |
124 | if(isHighTrust)
125 | {
126 | //For high-trust apps, the issuerID is in the actortoken
127 | ret.IssuerID = ((JsonWebToken)ret.BodyClaims["actortoken"]).BodyClaims["iss"].ToString();
128 |
129 | //For high-trust apps, the nameid in the actortoken is the app's client ID
130 | string clientID = ((JsonWebToken)ret.BodyClaims["actortoken"]).BodyClaims["nameid"].ToString();
131 | ret.ClientID = clientID.Substring(0, clientID.IndexOf("@"));
132 | }
133 |
134 | if (isLowTrust)
135 | {
136 | //For low-trust apps, the issuer is Azure ACS.
137 | ret.IssuerID = ret.BodyClaims["iss"].ToString();
138 |
139 | if (ret.BodyClaims.ContainsKey("actor"))
140 | {
141 | string clientID = ret.BodyClaims["actor"].ToString();
142 | if (clientID.Contains("@"))
143 | {
144 | ret.ClientID = clientID.Substring(0, clientID.IndexOf("@"));
145 | }
146 | else
147 | {
148 | ret.ClientID = clientID;
149 | }
150 | }
151 | else
152 | {
153 | if(ret.BodyClaims.ContainsKey("nameid"))
154 | {
155 | //App-only low-trust
156 | string clientID = ret.BodyClaims["nameid"].ToString();
157 | ret.ClientID = clientID.Substring(0, clientID.IndexOf("@"));
158 | }
159 | }
160 | }
161 | if(isContext)
162 | {
163 | ret.IssuerID = ret.BodyClaims["iss"].ToString();
164 | ret.ClientID = audience.Substring(0, audience.IndexOf("/") - 1);
165 |
166 | }
167 |
168 | return ret;
169 | }
170 |
171 |
172 |
173 |
174 | ///
175 | /// Splits a JWT token into its parts and decodes each part
176 | ///
177 | /// The JWT token to decode
178 | /// String array containing the header, body, and signature
179 | private static string[] Decode(string jwtToken)
180 | {
181 | var parts = jwtToken.Split('.');
182 | //A JWT token *should* be 3 parts: header, body, and signature.
183 | //We will accept unsigned tokens, where there is only 2 parts.
184 | if (parts.Length < 2)
185 | {
186 | throw new ArgumentException("Invalid JWT token, missing required '.' characters.", jwtToken);
187 | }
188 | string[] ret = new string[3];
189 |
190 | var header = parts[0];
191 | var body = parts[1];
192 |
193 | var decodedHeader = Base64UrlDecoder.Decode(header);
194 | ret[0] = decodedHeader;
195 |
196 | string decodedBody = Base64UrlDecoder.Decode(body);
197 | ret[1] = decodedBody;
198 |
199 | if(parts.Length == 3)
200 | {
201 | string decodedSignature = Base64UrlDecoder.Decode(parts[2]);
202 | ret[2] = decodedSignature;
203 | }
204 | else
205 | {
206 | ret[2] = string.Empty;
207 | }
208 |
209 | return ret;
210 | }
211 |
212 |
213 | ///
214 | /// Gets a formatted and indented representation of the JSON string
215 | ///
216 | /// The JSON to format
217 | /// A formatted and indented representation
218 | public static string GetPrettyPrintedJson(string json)
219 | {
220 | dynamic parsedJson = JsonConvert.DeserializeObject(json);
221 | return JsonConvert.SerializeObject(parsedJson, Formatting.Indented);
222 | }
223 |
224 | ///
225 | /// Returns a string representation of the object, formatted as JSON
226 | ///
227 | /// string
228 | public override string ToString()
229 | {
230 | string body = this.Body;
231 |
232 | if (this.BodyClaims.ContainsKey("actortoken"))
233 | {
234 | //Replace the encoded actortoken with the decoded body value
235 | JsonWebToken actorToken = this.BodyClaims["actortoken"] as JsonWebToken;
236 |
237 | //Find the start of the actortoken claim value
238 | int index = body.IndexOf("actortoken\": ") + "actortoken\": ".Length;
239 | //Find the length of the actortoken claim value
240 | int length = body.IndexOf('\n', index) - index;
241 |
242 | //Increase indentation so it looks like a nested object
243 | string actorBody = actorToken.Body.Replace("\n ", "\n ");
244 |
245 | //Increase indentation of the brackets
246 | actorBody = actorBody.Replace("{", "\n {");
247 | actorBody = actorBody.Replace("}"," }");
248 |
249 | //Replace the actortoken claim value with the decoded and formatted token body
250 | body = body.Replace(body.Substring(index, length), actorBody);
251 |
252 | }
253 | return string.Format("{0}\n{1}", this.Header, body);
254 | }
255 | }
256 |
257 | }
258 |
259 |
260 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SPOAuthExtension")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SPOAuthExtension")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("15797913-3257-4761-9131-bfbc8aa9cc15")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.1.0.0")]
36 | [assembly: AssemblyFileVersion("1.1.0.0")]
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | SPOAuthFiddlerExt
2 | =================
3 |
4 | Fiddler extension for inspecting the OAuth token used in SharePoint 2013+
5 |
6 | This project is the source repository for the work by Kirk Evans as documented on his blog post here:
7 | http://blogs.msdn.com/b/kaevans/archive/2013/08/25/creating-a-fiddler-extension-for-sharepoint-2013-app-tokens.aspx
8 |
9 | Kirk asked me to post this to GitHub for the community.
--------------------------------------------------------------------------------
/SPOAuthExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 | using Fiddler;
4 |
5 | [assembly: Fiddler.RequiredVersion("4.4.5.1")]
6 |
7 | namespace SPOAuthFiddlerExt {
8 | public class SPOAuthExtension : Inspector2, IRequestInspector2 {
9 |
10 | private bool _readOnly;
11 | HTTPRequestHeaders _headers;
12 | private byte[] _body;
13 | SPOAuthRequestControl _displayControl;
14 |
15 | #region Inspector2 implementation
16 | public override void AddToTab(TabPage o) {
17 |
18 | _displayControl = new SPOAuthRequestControl();
19 | o.Text = "SPOAuth";
20 | o.Controls.Add(_displayControl);
21 | o.Controls[0].Dock = DockStyle.Fill;
22 | }
23 |
24 | public override int GetOrder() {
25 | return 0;
26 | }
27 | #endregion
28 |
29 |
30 | #region IRequestInspector2 implementation
31 | public HTTPRequestHeaders headers {
32 | get {
33 | return _headers;
34 | }
35 | set {
36 |
37 | _headers = value;
38 | System.Collections.Generic.Dictionary httpHeaders = new System.Collections.Generic.Dictionary();
39 | foreach (var item in headers) {
40 | httpHeaders.Add(item.Name, item.Value);
41 | }
42 | _displayControl.HTTPHeaders = httpHeaders;
43 | }
44 | }
45 |
46 | public void Clear() {
47 | _displayControl.Clear();
48 | }
49 |
50 | public bool bDirty {
51 | get { return false; }
52 | }
53 |
54 | public bool bReadOnly {
55 | get {
56 | return _readOnly;
57 | }
58 | set {
59 | _readOnly = value;
60 | }
61 | }
62 |
63 | public byte[] body {
64 | get {
65 | return _body;
66 | }
67 | set {
68 | _body = value;
69 | _displayControl.HTTPBody = body;
70 | }
71 | }
72 | #endregion
73 |
74 | }
75 |
76 | }
--------------------------------------------------------------------------------
/SPOAuthFiddlerExt.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {15D2BC82-414A-40BB-933E-563311BA9FAB}
8 | Library
9 | Properties
10 | SPOAuthFiddlerExt
11 | SPOAuthFiddlerExt
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | TRACE;DEBUG
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | C:\Program Files (x86)\Fiddler2\Fiddler.exe
35 |
36 |
37 | False
38 | packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | UserControl
59 |
60 |
61 | SPOAuthRequestControl.cs
62 |
63 |
64 |
65 |
66 | SPOAuthRequestControl.cs
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | copy "$(TargetDir)$(TargetFileName)" "C:\Program Files (x86)\Fiddler2\Inspectors"
75 | copy "$(TargetDir)Newtonsoft.Json.dll" "C:\Program Files (x86)\Fiddler2\Inspectors"
76 |
77 |
84 |
--------------------------------------------------------------------------------
/SPOAuthFiddlerExt.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPOAuthFiddlerExt", "SPOAuthFiddlerExt.csproj", "{15D2BC82-414A-40BB-933E-563311BA9FAB}"
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 | {15D2BC82-414A-40BB-933E-563311BA9FAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {15D2BC82-414A-40BB-933E-563311BA9FAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {15D2BC82-414A-40BB-933E-563311BA9FAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {15D2BC82-414A-40BB-933E-563311BA9FAB}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/SPOAuthRequestControl.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace SPOAuthFiddlerExt {
2 | partial class SPOAuthRequestControl {
3 | ///
4 | /// Required designer variable.
5 | ///
6 | private System.ComponentModel.IContainer components = null;
7 |
8 | ///
9 | /// Clean up any resources being used.
10 | ///
11 | /// true if managed resources should be disposed; otherwise, false.
12 | protected override void Dispose(bool disposing) {
13 | if (disposing && (components != null)) {
14 | components.Dispose();
15 | }
16 | base.Dispose(disposing);
17 | }
18 |
19 | #region Component Designer generated code
20 |
21 | ///
22 | /// Required method for Designer support - do not modify
23 | /// the contents of this method with the code editor.
24 | ///
25 | private void InitializeComponent() {
26 | this.tabControl1 = new System.Windows.Forms.TabControl();
27 | this.tabPage1 = new System.Windows.Forms.TabPage();
28 | this.tabPage2 = new System.Windows.Forms.TabPage();
29 | this.tabControl2 = new System.Windows.Forms.TabControl();
30 | this.tabPage3 = new System.Windows.Forms.TabPage();
31 | this.txtContext = new System.Windows.Forms.TextBox();
32 | this.tabPage4 = new System.Windows.Forms.TabPage();
33 | this.splitContainer1 = new System.Windows.Forms.SplitContainer();
34 | this.groupBox1 = new System.Windows.Forms.GroupBox();
35 | this.dataGridView1 = new System.Windows.Forms.DataGridView();
36 | this.colKey = new System.Windows.Forms.DataGridViewTextBoxColumn();
37 | this.colValue = new System.Windows.Forms.DataGridViewTextBoxColumn();
38 | this.groupBox2 = new System.Windows.Forms.GroupBox();
39 | this.dataGridView2 = new System.Windows.Forms.DataGridView();
40 | this.Key = new System.Windows.Forms.DataGridViewTextBoxColumn();
41 | this.Value = new System.Windows.Forms.DataGridViewTextBoxColumn();
42 | this.tabPage5 = new System.Windows.Forms.TabPage();
43 | this.dataGridView3 = new System.Windows.Forms.DataGridView();
44 | this.Property = new System.Windows.Forms.DataGridViewTextBoxColumn();
45 | this.PropertyValue = new System.Windows.Forms.DataGridViewTextBoxColumn();
46 | this.tabControl1.SuspendLayout();
47 | this.tabControl2.SuspendLayout();
48 | this.tabPage3.SuspendLayout();
49 | this.tabPage4.SuspendLayout();
50 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
51 | this.splitContainer1.Panel1.SuspendLayout();
52 | this.splitContainer1.Panel2.SuspendLayout();
53 | this.splitContainer1.SuspendLayout();
54 | this.groupBox1.SuspendLayout();
55 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
56 | this.groupBox2.SuspendLayout();
57 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
58 | this.tabPage5.SuspendLayout();
59 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView3)).BeginInit();
60 | this.SuspendLayout();
61 | //
62 | // tabControl1
63 | //
64 | this.tabControl1.Controls.Add(this.tabPage1);
65 | this.tabControl1.Controls.Add(this.tabPage2);
66 | this.tabControl1.Location = new System.Drawing.Point(104, 288);
67 | this.tabControl1.Name = "tabControl1";
68 | this.tabControl1.SelectedIndex = 0;
69 | this.tabControl1.Size = new System.Drawing.Size(8, 8);
70 | this.tabControl1.TabIndex = 5;
71 | //
72 | // tabPage1
73 | //
74 | this.tabPage1.Location = new System.Drawing.Point(4, 25);
75 | this.tabPage1.Name = "tabPage1";
76 | this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
77 | this.tabPage1.Size = new System.Drawing.Size(0, 0);
78 | this.tabPage1.TabIndex = 0;
79 | this.tabPage1.Text = "tabPage1";
80 | this.tabPage1.UseVisualStyleBackColor = true;
81 | //
82 | // tabPage2
83 | //
84 | this.tabPage2.Location = new System.Drawing.Point(4, 25);
85 | this.tabPage2.Name = "tabPage2";
86 | this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
87 | this.tabPage2.Size = new System.Drawing.Size(0, 0);
88 | this.tabPage2.TabIndex = 1;
89 | this.tabPage2.Text = "tabPage2";
90 | this.tabPage2.UseVisualStyleBackColor = true;
91 | //
92 | // tabControl2
93 | //
94 | this.tabControl2.Controls.Add(this.tabPage3);
95 | this.tabControl2.Controls.Add(this.tabPage4);
96 | this.tabControl2.Controls.Add(this.tabPage5);
97 | this.tabControl2.Dock = System.Windows.Forms.DockStyle.Fill;
98 | this.tabControl2.Location = new System.Drawing.Point(0, 0);
99 | this.tabControl2.Name = "tabControl2";
100 | this.tabControl2.SelectedIndex = 0;
101 | this.tabControl2.Size = new System.Drawing.Size(916, 561);
102 | this.tabControl2.TabIndex = 6;
103 | //
104 | // tabPage3
105 | //
106 | this.tabPage3.Controls.Add(this.txtContext);
107 | this.tabPage3.Location = new System.Drawing.Point(4, 25);
108 | this.tabPage3.Name = "tabPage3";
109 | this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
110 | this.tabPage3.Size = new System.Drawing.Size(908, 532);
111 | this.tabPage3.TabIndex = 0;
112 | this.tabPage3.Text = "Text View";
113 | this.tabPage3.UseVisualStyleBackColor = true;
114 | //
115 | // txtContext
116 | //
117 | this.txtContext.Dock = System.Windows.Forms.DockStyle.Fill;
118 | this.txtContext.Location = new System.Drawing.Point(3, 3);
119 | this.txtContext.Margin = new System.Windows.Forms.Padding(4);
120 | this.txtContext.Multiline = true;
121 | this.txtContext.Name = "txtContext";
122 | this.txtContext.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
123 | this.txtContext.Size = new System.Drawing.Size(902, 526);
124 | this.txtContext.TabIndex = 1;
125 | //
126 | // tabPage4
127 | //
128 | this.tabPage4.Controls.Add(this.splitContainer1);
129 | this.tabPage4.Location = new System.Drawing.Point(4, 25);
130 | this.tabPage4.Name = "tabPage4";
131 | this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
132 | this.tabPage4.Size = new System.Drawing.Size(908, 532);
133 | this.tabPage4.TabIndex = 1;
134 | this.tabPage4.Text = "Grid View";
135 | this.tabPage4.UseVisualStyleBackColor = true;
136 | //
137 | // splitContainer1
138 | //
139 | this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
140 | this.splitContainer1.Location = new System.Drawing.Point(3, 3);
141 | this.splitContainer1.Name = "splitContainer1";
142 | this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
143 | //
144 | // splitContainer1.Panel1
145 | //
146 | this.splitContainer1.Panel1.Controls.Add(this.groupBox1);
147 | //
148 | // splitContainer1.Panel2
149 | //
150 | this.splitContainer1.Panel2.Controls.Add(this.groupBox2);
151 | this.splitContainer1.Size = new System.Drawing.Size(902, 526);
152 | this.splitContainer1.SplitterDistance = 263;
153 | this.splitContainer1.TabIndex = 9;
154 | //
155 | // groupBox1
156 | //
157 | this.groupBox1.Controls.Add(this.dataGridView1);
158 | this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
159 | this.groupBox1.Location = new System.Drawing.Point(0, 0);
160 | this.groupBox1.Name = "groupBox1";
161 | this.groupBox1.Size = new System.Drawing.Size(902, 263);
162 | this.groupBox1.TabIndex = 8;
163 | this.groupBox1.TabStop = false;
164 | this.groupBox1.Text = "Outer token";
165 | //
166 | // dataGridView1
167 | //
168 | this.dataGridView1.AllowUserToAddRows = false;
169 | this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
170 | this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
171 | this.colKey,
172 | this.colValue});
173 | this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
174 | this.dataGridView1.Location = new System.Drawing.Point(3, 18);
175 | this.dataGridView1.Margin = new System.Windows.Forms.Padding(4);
176 | this.dataGridView1.Name = "dataGridView1";
177 | this.dataGridView1.Size = new System.Drawing.Size(896, 242);
178 | this.dataGridView1.TabIndex = 7;
179 | //
180 | // colKey
181 | //
182 | this.colKey.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
183 | this.colKey.HeaderText = "Key";
184 | this.colKey.Name = "colKey";
185 | this.colKey.Width = 57;
186 | //
187 | // colValue
188 | //
189 | this.colValue.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
190 | this.colValue.HeaderText = "Value";
191 | this.colValue.Name = "colValue";
192 | //
193 | // groupBox2
194 | //
195 | this.groupBox2.Controls.Add(this.dataGridView2);
196 | this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
197 | this.groupBox2.Location = new System.Drawing.Point(0, 0);
198 | this.groupBox2.Name = "groupBox2";
199 | this.groupBox2.Size = new System.Drawing.Size(902, 259);
200 | this.groupBox2.TabIndex = 10;
201 | this.groupBox2.TabStop = false;
202 | this.groupBox2.Text = "Actor token";
203 | //
204 | // dataGridView2
205 | //
206 | this.dataGridView2.AllowUserToAddRows = false;
207 | this.dataGridView2.AllowUserToDeleteRows = false;
208 | this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
209 | this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
210 | this.Key,
211 | this.Value});
212 | this.dataGridView2.Dock = System.Windows.Forms.DockStyle.Fill;
213 | this.dataGridView2.Location = new System.Drawing.Point(3, 18);
214 | this.dataGridView2.Name = "dataGridView2";
215 | this.dataGridView2.ReadOnly = true;
216 | this.dataGridView2.RowTemplate.Height = 24;
217 | this.dataGridView2.Size = new System.Drawing.Size(896, 238);
218 | this.dataGridView2.TabIndex = 7;
219 | this.dataGridView2.Visible = false;
220 | //
221 | // Key
222 | //
223 | this.Key.HeaderText = "Key";
224 | this.Key.Name = "Key";
225 | this.Key.ReadOnly = true;
226 | //
227 | // Value
228 | //
229 | this.Value.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
230 | this.Value.HeaderText = "Value";
231 | this.Value.Name = "Value";
232 | this.Value.ReadOnly = true;
233 | //
234 | // tabPage5
235 | //
236 | this.tabPage5.Controls.Add(this.dataGridView3);
237 | this.tabPage5.Location = new System.Drawing.Point(4, 25);
238 | this.tabPage5.Name = "tabPage5";
239 | this.tabPage5.Padding = new System.Windows.Forms.Padding(3);
240 | this.tabPage5.Size = new System.Drawing.Size(908, 532);
241 | this.tabPage5.TabIndex = 2;
242 | this.tabPage5.Text = "Property Values";
243 | this.tabPage5.UseVisualStyleBackColor = true;
244 | //
245 | // dataGridView3
246 | //
247 | this.dataGridView3.AllowUserToAddRows = false;
248 | this.dataGridView3.AllowUserToDeleteRows = false;
249 | this.dataGridView3.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
250 | this.dataGridView3.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
251 | this.Property,
252 | this.PropertyValue});
253 | this.dataGridView3.Dock = System.Windows.Forms.DockStyle.Fill;
254 | this.dataGridView3.Location = new System.Drawing.Point(3, 3);
255 | this.dataGridView3.Name = "dataGridView3";
256 | this.dataGridView3.ReadOnly = true;
257 | this.dataGridView3.RowTemplate.Height = 24;
258 | this.dataGridView3.Size = new System.Drawing.Size(902, 526);
259 | this.dataGridView3.TabIndex = 0;
260 | //
261 | // Property
262 | //
263 | this.Property.HeaderText = "Property";
264 | this.Property.Name = "Property";
265 | this.Property.ReadOnly = true;
266 | //
267 | // PropertyValue
268 | //
269 | this.PropertyValue.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
270 | this.PropertyValue.HeaderText = "PropertyValue";
271 | this.PropertyValue.Name = "PropertyValue";
272 | this.PropertyValue.ReadOnly = true;
273 | //
274 | // SPOAuthRequestControl
275 | //
276 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
277 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
278 | this.AutoSize = true;
279 | this.Controls.Add(this.tabControl2);
280 | this.Controls.Add(this.tabControl1);
281 | this.Margin = new System.Windows.Forms.Padding(4);
282 | this.Name = "SPOAuthRequestControl";
283 | this.Size = new System.Drawing.Size(916, 561);
284 | this.tabControl1.ResumeLayout(false);
285 | this.tabControl2.ResumeLayout(false);
286 | this.tabPage3.ResumeLayout(false);
287 | this.tabPage3.PerformLayout();
288 | this.tabPage4.ResumeLayout(false);
289 | this.splitContainer1.Panel1.ResumeLayout(false);
290 | this.splitContainer1.Panel2.ResumeLayout(false);
291 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
292 | this.splitContainer1.ResumeLayout(false);
293 | this.groupBox1.ResumeLayout(false);
294 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
295 | this.groupBox2.ResumeLayout(false);
296 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
297 | this.tabPage5.ResumeLayout(false);
298 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView3)).EndInit();
299 | this.ResumeLayout(false);
300 |
301 | }
302 |
303 | #endregion
304 |
305 | private System.Windows.Forms.TabControl tabControl1;
306 | private System.Windows.Forms.TabPage tabPage1;
307 | private System.Windows.Forms.TabPage tabPage2;
308 | private System.Windows.Forms.TabControl tabControl2;
309 | private System.Windows.Forms.TabPage tabPage3;
310 | private System.Windows.Forms.TextBox txtContext;
311 | private System.Windows.Forms.TabPage tabPage4;
312 | private System.Windows.Forms.SplitContainer splitContainer1;
313 | private System.Windows.Forms.GroupBox groupBox1;
314 | private System.Windows.Forms.DataGridView dataGridView1;
315 | private System.Windows.Forms.DataGridViewTextBoxColumn colKey;
316 | private System.Windows.Forms.DataGridViewTextBoxColumn colValue;
317 | private System.Windows.Forms.GroupBox groupBox2;
318 | private System.Windows.Forms.DataGridView dataGridView2;
319 | private System.Windows.Forms.DataGridViewTextBoxColumn Key;
320 | private System.Windows.Forms.DataGridViewTextBoxColumn Value;
321 | private System.Windows.Forms.TabPage tabPage5;
322 | private System.Windows.Forms.DataGridView dataGridView3;
323 | private System.Windows.Forms.DataGridViewTextBoxColumn Property;
324 | private System.Windows.Forms.DataGridViewTextBoxColumn PropertyValue;
325 |
326 |
327 |
328 | }
329 | }
330 |
--------------------------------------------------------------------------------
/SPOAuthRequestControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Data;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using System.Web.Script.Serialization;
11 | using Newtonsoft.Json;
12 |
13 |
14 |
15 |
16 | namespace SPOAuthFiddlerExt
17 | {
18 | public partial class SPOAuthRequestControl : UserControl
19 | {
20 | public SPOAuthRequestControl()
21 | {
22 | InitializeComponent();
23 |
24 | }
25 |
26 | ///
27 | /// The HTTP headers that are being set for the control
28 | ///
29 | public Dictionary HTTPHeaders
30 | {
31 | set
32 | {
33 | txtContext.Text = string.Empty;
34 | #if LOCAL_DEBUG
35 | //This section only used for debugging. Remove the LOCAL_DEBUG
36 | //directive and recompile for normal operation.
37 |
38 | //TODO: Pull a token from the tests
39 |
40 | UpdateUI(token);
41 |
42 | #else
43 | foreach (string key in value.Keys)
44 | {
45 | if (key == "Authorization")
46 | {
47 | //Access token
48 | string accessToken = value[key].Replace("Bearer ", string.Empty);
49 |
50 | UpdateUI(accessToken);
51 |
52 | }
53 | }
54 | #endif
55 |
56 | }
57 | }
58 |
59 | ///
60 | /// The HTTP body that is being set for the control
61 | ///
62 | public byte[] HTTPBody
63 | {
64 | set
65 | {
66 | bool found = false;
67 | if (null != value)
68 | {
69 | string ret = System.Text.Encoding.UTF8.GetString(value);
70 |
71 | //Context token may be sent as a querystring with these names, but this is not
72 | //recommended practice and is not implemented here as a result. Only POST values
73 | //are processed.
74 | string[] formParameters = ret.Split('&');
75 | string[] paramNames = { "AppContext", "AppContextToken", "AccessToken", "SPAppToken" };
76 |
77 | foreach (string valuePair in formParameters)
78 | {
79 | string[] formParameter = valuePair.Split('=');
80 | foreach (string paramName in paramNames)
81 | {
82 | if (formParameter[0] == paramName)
83 | {
84 | UpdateUI(formParameter[1]);
85 |
86 | found = true;
87 | break;
88 | }
89 | }
90 | if (found)
91 | break;
92 | }
93 | }
94 |
95 | }
96 | }
97 |
98 | private void UpdateUI(string tokenString)
99 | {
100 | JsonWebToken token = JsonWebToken.GetTokenFromString(tokenString);
101 |
102 | txtContext.Text = token.ToString();
103 |
104 | dataGridView1.Rows.Clear();
105 | dataGridView2.Rows.Clear();
106 | dataGridView3.Rows.Clear();
107 |
108 | PopulateClaimsGrid(token.BodyClaims, dataGridView1);
109 | PopulatePropertyGrid(token);
110 | }
111 |
112 |
113 | public void Clear()
114 | {
115 | dataGridView1.Rows.Clear();
116 | dataGridView2.Rows.Clear();
117 | txtContext.Text = string.Empty;
118 |
119 | }
120 |
121 | private void PopulatePropertyGrid(JsonWebToken token)
122 | {
123 | dataGridView3.Rows.Add("ClientID", token.ClientID);
124 | dataGridView3.Rows.Add("TenantID", token.TenantID);
125 | dataGridView3.Rows.Add("HostName", token.HostName);
126 | dataGridView3.Rows.Add("IssuerID", token.IssuerID);
127 | dataGridView3.Rows.Add("UserID", token.UserID);
128 |
129 |
130 | }
131 | private void PopulateClaimsGrid(IDictionary dictionary, DataGridView grid)
132 | {
133 | foreach (string key in dictionary.Keys)
134 | {
135 | switch (key)
136 | {
137 | case "nbf":
138 | case "exp":
139 | double d = double.Parse(dictionary[key].ToString());
140 | DateTime dt = new DateTime(1970, 1, 1).AddSeconds(d);
141 | grid.Rows.Add(key, dt);
142 | break;
143 | case "actortoken":
144 | //actortoken is a JsonWebToken type
145 | JsonWebToken token = (JsonWebToken)dictionary[key];
146 | string formatted = string.Format("{0}.{1}.{2}", token.Header, token.Body, token.Signature);
147 |
148 | grid.Rows.Add(key, formatted);
149 |
150 | //Show the actor token in the second data grid view
151 | dataGridView2.Visible = true;
152 | PopulateClaimsGrid(token.BodyClaims, dataGridView2);
153 | break;
154 | default:
155 | grid.Rows.Add(key, dictionary[key]);
156 | break;
157 | }
158 |
159 | }
160 | }
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/SPOAuthRequestControl.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | True
122 |
123 |
124 | True
125 |
126 |
127 | True
128 |
129 |
130 | True
131 |
132 |
133 | True
134 |
135 |
136 | True
137 |
138 |
--------------------------------------------------------------------------------
/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------