{"id":17740576,"url":"https://github.com/rusq/slackauth","last_synced_at":"2025-05-07T16:56:37.523Z","repository":{"id":214712775,"uuid":"736850355","full_name":"rusq/slackauth","owner":"rusq","description":"Experimental slack authentication library using Rod browser automation","archived":false,"fork":false,"pushed_at":"2024-12-16T05:31:06.000Z","size":109,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-04T12:51:40.529Z","etag":null,"topics":["authentication","golang","golang-library","slack","slack-api","slack-client","slackdump"],"latest_commit_sha":null,"homepage":"https://github.com/rusq/slackdump","language":"Go","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/rusq.png","metadata":{"files":{"readme":"README.adoc","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":"2023-12-29T04:08:29.000Z","updated_at":"2025-01-08T03:55:40.000Z","dependencies_parsed_at":"2024-02-02T10:27:49.408Z","dependency_job_id":"8d1c6438-dd6c-44c5-a906-81eecae29de6","html_url":"https://github.com/rusq/slackauth","commit_stats":{"total_commits":38,"total_committers":1,"mean_commits":38.0,"dds":0.0,"last_synced_commit":"38e469ee64c47cc0144d4fbc57978677573562f2"},"previous_names":["rusq/slackauth"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusq%2Fslackauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusq%2Fslackauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusq%2Fslackauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusq%2Fslackauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rusq","download_url":"https://codeload.github.com/rusq/slackauth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252921953,"owners_count":21825632,"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","golang","golang-library","slack","slack-api","slack-client","slackdump"],"created_at":"2024-10-26T03:06:38.000Z","updated_at":"2025-05-07T16:56:37.465Z","avatar_url":"https://github.com/rusq.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Slackauth\n:hide-uri-scheme:\n\nSlackauth is an experimental Slack authentication library using\nhttps://github.com/go-rod/rod[Rod] library.\n\nThe advantage over the Playwright is that rod utilises \nhttps://chromedevtools.github.io/devtools-protocol/[CDP], which is faster\nand does not require nodejs.  The drawback is that it can't use Firefox.\n\nhttps://pkg.go.dev/github.com/rusq/slackauth[Go package documentation]\n\n== Types of login\n\nThe library implements two types of Login:\n\n1. Manual (interactive)\n2. Headless (automatic)\n\n=== Manual (interactive)\n\nIn the Manual mode, the browser opens on the address of the Slack\nworkspace, and user needs to follow the usual authentication flow, it could be\na Email/Password, SSO, etc., except Google Auth.  Google has bot detection\nthat detects the puppet browser (read below)\n\nCall the `client.Manual` function to start the Manual login.  It will\nblock until the timeout expires or the user does something, i.e. logs in or\ncloses the page/browser.\n\nThe library detects if the user closes the tab with Slack website or the\nbrowser, in this case the function returns an error.  It doesn't track the\nwebsite that user is on, so user can navigate away and browse the web, if they\ndecide so, until the timeout destroys the browser.\n\n==== Google Auth\n\nGoogle Authentication is a special case, as it detects the automated browser.\nTo authenticate with Google Auth, one needs to use the \"WithForceUser\" when\ninitialising the client with \"New\", i.e.:\n\n[source,go]\n---\ncl, err := slackauth.New(\"my_workspace\", slackauth.WithForceUser)\n// check error\n---\n\nThe user browser must be closed completely (the browser process should not be\nstarted) before using this option, otherwise ROD will fail to establish the\nconnection to the browser, and return an error.\n\nWhen \"cl.Manual()\" is called, it will start up the Chrome-family browser\ninstalled on the system and offer the user to login.  If the browser already\nlogged in to the requested workspace, it will hijack the cookies immediately\nafter the slack page loads without any required user interaction.\n\n==== Example\n\n[source,go]\n----\nfunc browserLogin(ctx context.Context) {\n\tconst workspace = \"some workspace\"\n\tctx, cancel := context.WithTimeoutCause(ctx, 180*time.Second, errors.New(\"user too slow\"))\n\tdefer cancel()\n\n\tcl, err := slackauth.New(workspace, slackauth.WithNoConsentPrompt())\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer cl.Close()\n\n\ttoken, cookies, err := cl.Manual(ctx)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(token)\n\tfmt.Println(cookies)\n}\n----\n\n=== Headless\n\nIn the Headless mode, the browser is not visible to the user, and the\nauthentication flow is automated.  The user needs to provide the workspace,\nemail and password, and the library will do the rest.\n\nCall the `slackauth.Headless` function to start the Headless login.  It will\nblock until login succeeds or fails.\n\nThere's a special case when Slack does not recognise the browser and asks the\nuser to enter the confirmation code that was sent on the user's email.  In\nthis case, Headless calls the provided interactive challenge function (see the\n`WithChallengeFunc` option) and waits for the user to enter the code.  After\nthe user enters the code, it will be passed to the page and the login process\nwill continue.\n\nThere's the fallback challenge function, but it's simple and ugly, so you're\nencouraged to provide your own beautiful one.\n\nOverall, headless login looks nicer, but more fragile - it will start failing\nshould Slack decide to change the login elements.\n\n==== Example\n\n[source,go]\n----\nfunc autoLogin(ctx context.Context) {\n\tctx, cancel := context.WithTimeoutCause(ctx, 180*time.Second, errors.New(\"user too slow\"))\n\tdefer cancel()\n\n\tworkspace := envOrScan(\"AUTH_WORKSPACE\", \"Enter workspace: \")\n\tusername := envOrScan(\"EMAIL\", \"Enter email: \")\n\tpassword := envOrScan(\"PASSWORD\", \"Enter password: \")\n\n\tcl, err := slackauth.New(ctx, workspace, slackauth.WithDebug(), slackauth.WithNoConsentPrompt())\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer cl.Close()\n\n\ttoken, cookies, err := cl.Headless(ctx, username, password)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(token)\n\tfmt.Println(cookies)\n}\n\nfunc envOrScan(env, prompt string) string {\n\tv := os.Getenv(env)\n\tif v != \"\" {\n\t\treturn v\n\t}\n\tfor v == \"\" {\n\t\tfmt.Print(prompt)\n\t\tfmt.Scanln(\u0026v)\n\t}\n\treturn v\n}\n----\n\n== References\n- https://pkg.go.dev/github.com/rusq/slackauth[slackauth package documentation]\n- https://go-rod.github.io/[Rod documentation]\n- https://chromedevtools.github.io/devtools-protocol/1-3/[Chrome DevTools Protocol (stable, 1.3)]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusq%2Fslackauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frusq%2Fslackauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusq%2Fslackauth/lists"}