{"id":23536616,"url":"https://github.com/mockingbot/gitlab-license","last_synced_at":"2025-09-11T11:41:54.423Z","repository":{"id":139142449,"uuid":"234491628","full_name":"mockingbot/gitlab-license","owner":"mockingbot","description":null,"archived":false,"fork":false,"pushed_at":"2020-01-17T07:12:13.000Z","size":7,"stargazers_count":13,"open_issues_count":1,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-23T12:17:38.016Z","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/mockingbot.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,"zenodo":null}},"created_at":"2020-01-17T07:06:53.000Z","updated_at":"2023-05-10T16:07:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"e3abce33-6405-4ffe-ae33-0cdf4419ddf3","html_url":"https://github.com/mockingbot/gitlab-license","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mockingbot/gitlab-license","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mockingbot%2Fgitlab-license","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mockingbot%2Fgitlab-license/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mockingbot%2Fgitlab-license/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mockingbot%2Fgitlab-license/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mockingbot","download_url":"https://codeload.github.com/mockingbot/gitlab-license/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mockingbot%2Fgitlab-license/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274628000,"owners_count":25320565,"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","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-12-26T02:29:44.806Z","updated_at":"2025-09-11T11:41:54.414Z","avatar_url":"https://github.com/mockingbot.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gitlab::License\n\ngitlab-license helps you generate, verify and enforce software licenses. It is used in GitLab Enterprise Edition.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'gitlab-license'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install gitlab-license\n\n## Usage\n\n```ruby\n# Generate a key pair. You should do this only once.\nkey_pair = OpenSSL::PKey::RSA.generate(2048)\n\n# Write it to a file to use in the license generation application.\nFile.open(\"license_key\", \"w\") { |f| f.write(key_pair.to_pem) }\n\n# Extract the public key.\npublic_key = key_pair.public_key\n# Write it to a file to ship along with the main application.\nFile.open(\"license_key.pub\", \"w\") { |f| f.write(public_key.to_pem) }\n\n# In the license generation application, load the private key from a file.\nprivate_key = OpenSSL::PKey::RSA.new File.read(\"license_key\")\nGitlab::License.encryption_key = private_key\n\n# Build a new license.\nlicense = Gitlab::License.new\n\n# License information to be rendered as a table in the admin panel.\n# E.g.: \"This instance of GitLab Enterprise Edition is licensed to:\"\n# Specific keys don't matter, but there needs to be at least one.\nlicense.licensee = {\n  \"Name\"    =\u003e \"Douwe Maan\",\n  \"Company\" =\u003e \"GitLab B.V.\",\n  \"Email\"   =\u003e \"douwe@gitlab.com\"\n}\n\n# The date the license starts. \n# Required.\nlicense.starts_at         = Date.new(2015, 4, 24)\n# The date the license expires. \n# Not required, to allow lifetime licenses.\nlicense.expires_at        = Date.new(2016, 4, 23)\n\n# The below dates are hardcoded in the license so that you can play with the\n# period after which there are \"repercussions\" to license expiration.\n\n# The date admins will be notified about the license's pending expiration. \n# Not required.\nlicense.notify_admins_at  = Date.new(2016, 4, 19)\n\n# The date regular users will be notified about the license's pending expiration.\n# Not required.\nlicense.notify_users_at   = Date.new(2016, 4, 23)\n\n# The date \"changes\" like code pushes, issue or merge request creation \n# or modification and project creation will be blocked.\n# Not required.\nlicense.block_changes_at  = Date.new(2016, 5, 7)\n\n# Restrictions bundled with this license.\n# Not required, to allow unlimited-user licenses for things like educational organizations.\nlicense.restrictions  = {\n  # The maximum allowed number of active users.\n  # Not required.\n  active_user_count: 10000\n\n  # We don't currently have any other restrictions, but we might in the future.\n}\n\nputs \"License:\"\nputs license\n\n# Export the license, which encrypts and encodes it.\ndata = license.export\n\nputs \"Exported license:\"\nputs data\n\n# Write the license to a file to send to a customer.\nFile.open(\"GitLabBV.gitlab-license\", \"w\") { |f| f.write(data) }\n\n\n# In the customer's application, load the public key from a file.\npublic_key = OpenSSL::PKey::RSA.new File.read(\"license_key.pub\")\nGitlab::License.encryption_key = public_key\n\n# Read the license from a file.\ndata = File.read(\"GitLabBV.gitlab-license\")\n\n# Import the license, which decodes and decrypts it.\n$license = Gitlab::License.import(data)\n\nputs \"Imported license:\"\nputs $license\n\n# Quit if the license is invalid\nunless $license\n  raise \"The license is invalid.\"\nend\n\n# Quit if the active user count exceeds the allowed amount:\nif $license.restricted?(:active_user_count)\n  active_user_count = User.active.count\n  if active_user_count \u003e $license.restrictions[:active_user_count]\n    raise \"The active user count exceeds the allowed amount!\"\n  end\nend\n\n# Show admins a message if the license is about to expire.\nif $license.notify_admins?\n  puts \"The license is due to expire on #{$license.expires_at}.\"\nend\n\n# Show users a message if the license is about to expire.\nif $license.notify_users?\n  puts \"The license is due to expire on #{$license.expires_at}.\"\nend\n\n# Block pushes when the license expired two weeks ago.\nmodule Gitlab\n  class GitAccess\n    # ...\n    def check(cmd, changes = nil)\n      if $license.block_changes?\n        return build_status_object(false, \"License expired\")\n      end\n\n      # Do other Git access verification\n      # ...\n    end\n    # ...\n  end\nend\n\n# Show information about the license in the admin panel.\nputs \"This instance of GitLab Enterprise Edition is licensed to:\"\n$license.licensee.each do |key, value|\n  puts \"#{key}: #{value}\"\nend\n\nif $license.expired?\n  puts \"The license expired on #{$license.expires_at}\"\nelsif $license.will_expire?\n  puts \"The license will expire on #{$license.expires_at}\"\nelse\n  puts \"The license will never expire.\"\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmockingbot%2Fgitlab-license","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmockingbot%2Fgitlab-license","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmockingbot%2Fgitlab-license/lists"}