{"id":21655904,"url":"https://github.com/koltyakov/spauthn","last_synced_at":"2025-07-04T11:06:33.857Z","repository":{"id":40913302,"uuid":"108401305","full_name":"koltyakov/SPAuthN","owner":"koltyakov","description":"SharePoint .Net auth via Node.js","archived":false,"fork":false,"pushed_at":"2024-09-06T08:54:27.000Z","size":17975,"stargazers_count":5,"open_issues_count":14,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-18T04:16:31.271Z","etag":null,"topics":["authentication","crazystuff","dotnet","nodejs","sharepoint","sharepoint-online"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koltyakov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-26T11:17:03.000Z","updated_at":"2021-03-29T22:41:56.000Z","dependencies_parsed_at":"2024-11-25T08:37:56.035Z","dependency_job_id":"fbadc565-b108-4c6b-a8b9-08c73a196a23","html_url":"https://github.com/koltyakov/SPAuthN","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/koltyakov/SPAuthN","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koltyakov%2FSPAuthN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koltyakov%2FSPAuthN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koltyakov%2FSPAuthN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koltyakov%2FSPAuthN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koltyakov","download_url":"https://codeload.github.com/koltyakov/SPAuthN/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koltyakov%2FSPAuthN/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263499193,"owners_count":23476021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","crazystuff","dotnet","nodejs","sharepoint","sharepoint-online"],"created_at":"2024-11-25T08:37:44.309Z","updated_at":"2025-07-04T11:06:33.827Z","avatar_url":"https://github.com/koltyakov.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SPAuthN - SharePoint .Net auth via Node.js\n\n[![NuGet version](https://img.shields.io/nuget/v/SPAuthN.svg)](https://www.nuget.org/packages/SPAuthN)\n[![Downloads](https://img.shields.io/nuget/dt/SPAuthN.svg)](https://www.nuget.org/packages/SPAuthN)\n![Build Status](https://koltyakov.visualstudio.com/SPNode/_apis/build/status/SPAuthN?branchName=master)\n[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/sharepoint-node/Lobby)\n\n---\n\nThe wrapper for [node-sp-auth](https://www.npmjs.com/package/node-sp-auth) and [node-sp-auth-config](https://www.npmjs.com/package/node-sp-auth-config) for usage in .Net assemblies.\n\nAllows authenticating in SharePoint in whatever you need scenarios and provides a wizard-like approach for building and managing connection config files.\n\n---\n\nOn the first place, it is an experiment which solves one of our very specific tasks for a frontier technology stack with SharePoint/Node.js/.Net where we need running the same exactly auth mechanisms which we use in Node.js but in .Net applications. We know exactly what we're doing and why. Please use the lib only in the case when native .Net credentials strategies do not suite your app.\n\n## For whom is this library?\n\nFor folks who used to create applications for SharePoint with authentication level powered by `node-sp-auth-config` and `node-sp-auth-config` and who desire reuse authentication settings parameters and formats in .Net application.\n\nFor geeks from geeks passionated with funky technology experiments on their way doing awesome stuff.\n\nFor the cases when one tool should rule *all possible authentication strategies in SharePoint.\n\nAnd definitely not for the situations when these work for you:\n\n- context.Credentials = new SharePointOnlineCredentials(\"username\", \"securepass\");\n- context.Credentials = new NetworkCredential(\"username\", \"password\", \"domain\");\n- Any other native authentication routes.\n\n## Versions supported\n\n- SharePoint Online\n- SharePoint 2019\n- SharePoint 2016\n- SharePoint 2013\n- SharePoint 2010 (limited support)\n\n## Authentication options\n\n- SharePoint Online:\n  - User credentials (SAML/ADFS)\n  - Add-In Only permissions\n  - On-Demand authentication (using Electron popup)\n- SharePoint 2019, 2016, 2013:\n  - User credentials (NTLM, NTLM v2)\n  - ADFS user credentials\n  - Form-based authentication (FBA)\n  - Form-based authentication (Forefront TMG)\n  - Add-In Only permissions\n  - On-Demand authentication (using Electron popup)\n- SharePoint 2010:\n  - User credentials (NTLM, NTMLv2)\n  - Form-based authentication (FBA)\n  - Form-based authentication (Forefront TMG)\n\nConfig layer and auth supports Office 365 Dedicated (SPO on custom domain) as well.\n\n## How to install\n\n```PowerShell\nInstall-Package SPAuthN\n```\n\n## How to use\n\n```csharp\nOptions options = SPAuth.GetAuth();\n```\n\nThat's it! Really!\n\nNow `options.headers` object contains Cookie or Authorization which can be injected to web requests.\nThis is a low level, session timeouts should be controlled manually.\n\n## First run\n\nDuring very first execution, node modules dependencies are installed. This can take a couple of seconds, second run doesn't need this process repetition so is much faster.\n\n## Credentials\n\n[node-sp-auth-config](https://github.com/koltyakov/node-sp-auth-config) is responsible for prompting auth strategy and credentials:\n\n![](./Assets/auth-wizard.gif)\n\nBy default, after the propmpts are done `./config/private.json` file is created in the root folder of the app.\n\n![](./Assets/private-json.png)\n\n`GetAuth` checks for `./config/private.json` and continues without prompts if all needed for the strategy parameters are filled in.\nPassword is stored as a secure string, it can be used only on the machine where it was generated. Password can be rewritten in the config and it will be encrypted on next auth method run.\n\n## Arguments\n\n`GetAuth` method receives a string with arguments which are passed as initiators to [AuthConfigSettings](https://github.com/koltyakov/node-sp-auth-config/blob/master/src/interfaces/index.ts#L35).\n\n```csharp\nOptions options = SPAuth.GetAuth(\"--encryptPassword=false --configPath='./config/private.uat.json'\");\n```\n\n### Arguments use cases\n\n#### Redefine private config file path\n\n```bash\n--configPath='./config/private.prod.json'\n```\n\n#### Disable password encryption\n\n```bash\n--encryptPassword=false\n```\n\n#### Disable saving private config on disc\n\n```bash\n--saveConfigOnDisk=false\n```\n\n#### Enforce parameters prompts\n\n```bash\n--forcePrompts=true\n```\n\n#### Raw auth options (example)\n\n```bash\n--authOptions.siteUrl=\"http://sharepoint\" --authOptions.username=\"user@contoso.com\" --authOptions.password=\"p@ssw0rd\" --saveConfigOnDisk=false\n```\n\n### Usage examples\n\n#### WebRequest\n\n```csharp\nOptions options = SPAuth.GetAuth(\"--configPath='./config/private.json'\");\nHttpWebRequest request = (HttpWebRequest)WebRequest.Create(options.SiteUrl + \"/_api/web?$select=Title\");\nRequest.ApplyAuth(request, options);\nrequest.Method = \"GET\";\nrequest.Accept = \"application/json; odata=verbose\";\nusing (HttpWebResponse response = (HttpWebResponse)request.GetResponse())\n{\n  if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.NoContent)\n  {\n    using (Stream dataStream = response.GetResponseStream())\n    {\n      using (StreamReader reader = new StreamReader(dataStream))\n      {\n        string strResponse = reader.ReadToEnd();\n        dynamic results = JsonConvert.DeserializeObject(strResponse);\n\n        Console.WriteLine(\"REST | Web title is: {0}\", results.d.Title);\n      }\n    }\n  }\n}\n```\n\n#### CSOM\n\n```csharp\nOptions options = SPAuth.GetAuth(\"--configPath='./config/private.json'\");\nusing (ClientContext clientContext = new ClientContext(options.SiteUrl))\n{\n  Request.ApplyAuth\u003cWebRequestEventArgs\u003e(clientContext, options);\n\n  var web = clientContext.Web;\n  clientContext.Load(web);\n  clientContext.ExecuteQuery();\n\n  Console.WriteLine(\"CSOM | Web title is: {0}\", web.Title);\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoltyakov%2Fspauthn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoltyakov%2Fspauthn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoltyakov%2Fspauthn/lists"}