{"id":25598197,"url":"https://github.com/code0-tech/code0-identities","last_synced_at":"2025-04-13T04:04:52.639Z","repository":{"id":253476274,"uuid":"843495367","full_name":"code0-tech/code0-identities","owner":"code0-tech","description":"Library for external user identities.","archived":false,"fork":false,"pushed_at":"2024-12-21T18:07:44.000Z","size":76,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T04:04:20.906Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/code0-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2024-08-16T16:35:05.000Z","updated_at":"2024-12-21T18:07:45.000Z","dependencies_parsed_at":"2024-08-21T14:59:19.641Z","dependency_job_id":"721a791a-d0d3-40d7-85ef-6fd6c1edc6ba","html_url":"https://github.com/code0-tech/code0-identities","commit_stats":null,"previous_names":["code0-tech/code0-identities"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code0-tech%2Fcode0-identities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code0-tech%2Fcode0-identities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code0-tech%2Fcode0-identities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code0-tech%2Fcode0-identities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code0-tech","download_url":"https://codeload.github.com/code0-tech/code0-identities/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248661707,"owners_count":21141450,"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":"2025-02-21T13:30:50.249Z","updated_at":"2025-04-13T04:04:52.608Z","avatar_url":"https://github.com/code0-tech.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Code0::Identities [![Build Status](https://img.shields.io/github/actions/workflow/status/code0-tech/code0-identities/main.yml?branch=main)](https://github.com/code0-tech/code0-identities/actions) ![GitHub Release](https://img.shields.io/github/v/release/code0-tech/code0-identities) ![Discord](https://img.shields.io/discord/1173625923724124200?label=Discord\u0026color=blue)\n\nThis gem can load and validate external identities\n\n## Supported platforms\n\nOAuth:\n- Google\n- Discord\n- Microsoft\n- Github\n- Gitlab\n- OIDC / oAuth2\n- SAML\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    $ bundle add code0-identities\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n    $ gem install code0-identities\n\n## Usage\n\nYou can use predefined Providers to load an identity from for example Discord:\n```ruby\n\nrequire \"code0/identities\"\n\nbegin\n\n  identity = Code0::Identities::Provider::Discord.new(\n    {\n      redirect_uri: \"http://localhost:8080/redirect\",\n      client_id: \"id\",\n      client_secret: \"xxxx\"\n    }).load_identity({ code: \"a_valid_code\" })\n\nrescue Code0::Error =\u003e e\n  puts \"Error occurred while loading the identity\", e\n  exit!\nend\n\n# Then you can use the details from the user\nputs identity.provider # = :discord\nputs identity.username\nputs identity.identifier\n# ...\n\n```\n\nOr you can use a provider with multiple configured providers:\n\n```ruby\n\nrequire \"code0/identities\"\n\nidentity_provider = Code0::Identities::IdentityProvider.new\n\nidentity_provider.add_provider(:gitlab, my_gitlab_configuration)\nidentity_provider.add_named_provider(:my_custom_gitlab_provider, :gitlab, my_custom_gitlab_provider_configuration)\n\n# Now you can either use the custom \"my_custom_gitlab_provider\" provider\n# or the \"gitlab\" provider\n\nidentity_provider.load_identity(:gitlab, params)\n\n# or\n\nidentity_provider.load_identity(:my_custom_gitlab_provider, params)\n\n```\n\nWe also support passing in a function as a configuration instead of a hash\n\n```ruby\n\ndef get_identity\n  provider = Code0::Identities::Provider::Discord.new(-\u003e { fetch_configuration })\n\n  provider.load_identity(params)\nend\n\ndef fetch_configuration\n  # Do some database action, to dynamicly load the configuration\n  {\n    redirect_uri: \"http://localhost:8080/redirect\",\n    client_id: \"some dynamic value\",\n    client_secret: \"xxxx\"\n  }\nend\n\n```\n\n# Configuration\n\nAs you already know, we allow / require to pass in a configuration. Here are all avaiable configuration keys:\n\n\n## Oauth Based:\nHere is the updated table where each key in the JSON (`identifier`, `username`, etc.) is explicitly labeled:\n\n| Name                               | Description                                                                                | Default                                             |\n|------------------------------------|--------------------------------------------------------------------------------------------|-----------------------------------------------------|\n| `client_id`                        | The client id of the application (needs to be set)                                         | **(no default specified)**                          |\n| `client_secret`                    | The client secret of the application (needs to be set)                                     | **(no default specified)**                          |\n| `redirect_uri`                     | The redirect URL of the application (needs to be set)                                      | **(no default specified)**                          |\n| `provider_name`                    | The provider name (not necessarily)                                                        | depends on the provider (e.g., `discord`, `github`) |\n| `user_details_url`                 | The user details URL to gather user information (only for OIDC)                            | **(no default specified)**                          |\n| `authorization_url`                | The URL which the user has to access to authorize (only for OIDC)                          | **(no default specified)**                          |\n| `attribute_statements`             | The keys which the response of the user details has (id, name, email, ...) (only for OIDC) | `{}` (see below for more)                           |\n| `attribute_statements.identifier`  | The identifier of the user to identify (only for OIDC)                                     | `[\"id\", \"sub\", \"identifier\"]`                       |\n| `attribute_statements.username`    | The username of the user (only for OIDC)                                                   | `[\"username\", \"name\", \"login\"]`                     |\n| `attribute_statements.email`       | The email address of the user (only for OIDC)                                              | `[\"email\", \"mail\"]`                                 |\n| `attribute_statements.firstname`   | The first name of the user (only for OIDC)                                                 | `[\"first_name\", \"firstname\", ...]`                  |\n| `attribute_statements.lastname`    | The last name of the user (only for OIDC)                                                  | `[\"last_name\", \"lastname\", ...]`                    |\n\n## SAML\n\n| Name                             | Description                                                                                                                                                        | Default                            |\n|----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|\n| `provider_name`                  | The provider name (not necessarily)                                                                                                                                | `saml`                             |\n| `attribute_statements`           | The keys which the response of the user details has (id, name, email, ...) (only for OIDC)                                                                         | `{}` (see below for more)          |\n| `attribute_statements.username`  | The username of the user                                                                                                                                           | `[\"username\", \"name\", ...]`        |\n| `attribute_statements.email`     | The email address of the user                                                                                                                                      | `[\"email\", \"mail\", ...]`           |\n| `attribute_statements.firstname` | The first name of the user                                                                                                                                         | `[\"first_name\", \"firstname\", ...]` |\n| `attribute_statements.lastname`  | The last name of the user                                                                                                                                          | `[\"last_name\", \"lastname\", ...]`   |\n| `settings`                       | The settings to configure the saml response/requests (see [SAML-Toolkits#L200](https://github.com/SAML-Toolkits/ruby-saml/blob/master/README.md?plain=1#L200))     | `{}`                               |\n| `response_settings`              | The response settings to disable some checks if you want (see [SAML-Toolkits#L234](https://github.com/SAML-Toolkits/ruby-saml/blob/master/README.md?plain=1#L234)) | `{}`                               |\n| `metadata_url`                   | The metadata url to fetch the metadatas (replacement for `settings`)                                                                                               | **(no default specified)**         |\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode0-tech%2Fcode0-identities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode0-tech%2Fcode0-identities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode0-tech%2Fcode0-identities/lists"}