{"id":18577536,"url":"https://github.com/ecomplus/sso-php","last_synced_at":"2025-05-16T01:32:38.865Z","repository":{"id":103581390,"uuid":"170135307","full_name":"ecomplus/sso-php","owner":"ecomplus","description":"Single-Sign-On for E-Com Plus platform users with PHP","archived":false,"fork":false,"pushed_at":"2024-04-01T12:57:36.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-17T15:27:05.695Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/ecomplus.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":"2019-02-11T13:41:43.000Z","updated_at":"2025-01-17T14:05:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"599a273e-4ea7-4d47-b7c8-3c6c8570c9e7","html_url":"https://github.com/ecomplus/sso-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomplus%2Fsso-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomplus%2Fsso-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomplus%2Fsso-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomplus%2Fsso-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ecomplus","download_url":"https://codeload.github.com/ecomplus/sso-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254453484,"owners_count":22073608,"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":[],"created_at":"2024-11-06T23:29:33.142Z","updated_at":"2025-05-16T01:32:38.846Z","avatar_url":"https://github.com/ecomplus.png","language":"PHP","readme":"# sso-php\nSingle-Sign-On for E-Com Plus platform users with PHP\n\n## Reference\n\nBased on [Official Single-Sign-On for Discourse (sso)](https://meta.discourse.org/t/official-single-sign-on-for-discourse-sso/13045)\n\n## Usage\n\n1. Save the secret (32 bytes string) on __SSO_SECRET__ environment variable\n2. Import the script and create new object with `EcomSSO` class\n3. Call `login_url` to redirect user to new login flow\n4. Call `handle_response` at callback endpoint __/session/sso_login__\n\n## Samples\n\n```php\nrequire './ecomplus-sso.php';\n$sso = new EcomSSO();\n```\n\n### Start login flow\n\n```php\n$sso-\u003elogin_url(true);\n```\n\n### Handle callback redirect\n\n```php\n$user = $sso-\u003ehandle_response();\nif ($user !== null) {\n  if ($user['logged']) {\n    /*\n    user attributes:\n    name; external_id; email; username; require_activation;\n    custom.locale; custom.edit_storefront; custom.store_id;\n    custom.access_token.\n    */\n    if ($user['email']) {\n      // do the stuff\n    }\n  } else {\n    // user unlogged\n    http_response_code(401);\n  }\n} else {\n  // invalid request\n  http_response_code(400);\n}\n```\n\n### Custom secret and service\n\nCustom secret token:\n\n```php\n// default is to get from SSO_SECRET env\n$sso = new EcomSSO('cb68251eefb5211e58c00ff1395f0c0b');\n```\n\nCustom service name:\n\n```php\n// default service name is 'market'\n// must match with subdomain name\n// eg.: 'builder' for 'builder.e-com.plus'\n$sso = new EcomSSO(null, 'builder');\n```\n\nBoth custom secret and service:\n\n```php\n$sso = new EcomSSO('cb68251eefb5211e58c00ff1395f0c0b', 'builder');\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecomplus%2Fsso-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecomplus%2Fsso-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecomplus%2Fsso-php/lists"}