{"id":15064612,"url":"https://github.com/omarluq/keycloak_rails","last_synced_at":"2025-10-05T01:30:54.947Z","repository":{"id":143383517,"uuid":"615574405","full_name":"omarluq/keycloak_rails","owner":"omarluq","description":"ruby on rails integration with redhat's SSO keycloak","archived":true,"fork":false,"pushed_at":"2023-03-18T03:37:07.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-15T21:43:35.724Z","etag":null,"topics":["authentication","java","keycloak","redhat","ruby","ruby-on-rails","sso"],"latest_commit_sha":null,"homepage":"","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/omarluq.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"MIT-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-03-18T03:15:16.000Z","updated_at":"2024-11-24T03:17:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"620a9287-ea0f-48ce-9d19-e202312c9754","html_url":"https://github.com/omarluq/keycloak_rails","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/omarluq/keycloak_rails","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omarluq%2Fkeycloak_rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omarluq%2Fkeycloak_rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omarluq%2Fkeycloak_rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omarluq%2Fkeycloak_rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omarluq","download_url":"https://codeload.github.com/omarluq/keycloak_rails/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omarluq%2Fkeycloak_rails/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278399626,"owners_count":25980330,"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-10-04T02:00:05.491Z","response_time":63,"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":["authentication","java","keycloak","redhat","ruby","ruby-on-rails","sso"],"created_at":"2024-09-25T00:22:29.100Z","updated_at":"2025-10-05T01:30:54.616Z","avatar_url":"https://github.com/omarluq.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Gem Version](https://badge.fury.io/rb/keycloak_rails.svg)](https://badge.fury.io/rb/keycloak_rails)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits\u0026logoColor=white)](https://conventionalcommits.org)\n[![unstable](http://badges.github.io/stability-badges/dist/unstable.svg)](http://github.com/badges/stability-badges)\n\n# KeycloakRails\nKeycloak_rails is an api wrapper for open source project [Keycloak](https://www.keycloak.org/)\n\n* the gem assumes that you have a configured and ready to use keycloak server\n* the gem is still in beta and the docs does not reflect the latest updates, multiple bugs might occur\n\n## Installation\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"keycloak_rails\"\n```\n\nAnd then execute:\n```bash\n$ bundle\n```\n\nOr install it yourself as:\n```bash\n$ gem install keycloak_rails\n```\n\n## Getting started\nto generate keycloak_rails initializer execute:\n```bash\n$ bundle exec rails g keycloak_rails:config\n```\n \ngo to `config/initializers/keycloak_rails.rb`\n\nwhere you will find \n```ruby\n# frozen_string_literal: true\n\n# Keycloak Rails initializer\n\nKeycloakRails.configure do |config|\n  ####################################################\n  # keyclaok rails need your user model name\n  # config.user_model = 'user'\n  ####################################################\n  # Auth server info\n  # config.auth_server_url = ''\n  # config.realm = 'realm'\n  # config.public_key = \"public_key\"\n  # config.secret = ''\n  # config.client_id = 'client_id'\n  ####################################################\nend\n```\nuncomment config options and enter your apps info\n\n**Note** do not uncomment controller config if you just want to use keycloak_rails user/client helpers\n\n## use\n### with controller helpers\nif you decided to use all of keycloak rails functionallity (pass controller options) keycloack rails will automatically hook up to named controllers and extend the base classes with our controller concerns which will provide the following methods\n#### KeycloakRails::Controller::Helpers\n***\nThis concern will be inherited by all controllers as it extends application controller\n\nthe following helpers will be added to your app \n```ruby\nensure_active_session # redirects to root if user not logged in\nensure_no_active_session # redirects to root if user is logged in\ncurrent_user # returns current user by session cookie\nuser_has_active_sso_session? # returns true if current user has an active session in auth server\n```\n\n#### KeycloakRails::Controller::Sessions\n***\nextends the controller passed to `KeycloakRails.config.sessions_controller`\n\nIn your app \n\n\n`keycloak_rails.rb`\n```ruby\nKeycloakRails.configure do |config|\n   config.sessions_controller = 'sessions'\nend\n```\n\n`app/controllers/sessions_controller.rb`\n```ruby\nclass SessionsController \u003c ApplicationController\n  skip_before_action :ensure_active_session, only: %i[new log_in]\n  before_action :ensure_no_active_session, only: %i[new log_in]\n\n  def new; end\n\n  def log_in\n    start_sso_session(params[:email], params[:password])\n    # keycloak_rails will take care of setting the session cookie \u0026 current_user for you\n  end\n\n  def log_out\n    end_sso_session\n  end\nend\n```\n\n\n#### KeycloakRails::Controller::Registrations\n***\nThe main idea behind keycloak_rails is to make adding sso easy to an existing rails app thats already in prod, and the registrations module is the backbone to achive that.\n\nIn your app \n\n\n`keycloak_rails.rb`\n```ruby\nKeycloakRails.configure do |config|\n   config.registrations_controller = 'registrations'\nend\n```\n\n`app/controllers/registrations_controller.rb`\n```ruby\nclass RegistrationsController \u003c ApplicationController\n  skip_before_action :ensure_active_session, only: %i[new create_user]\n  before_action :ensure_no_active_session, only: %i[new create_user]\n  \n  def new; end\n\n  def sign_up\n    sso_user = create_sso_user(email: params[:email], password: params[:password],\n                               first_name: params[:first_name], last_name: params[:last_name])\n    user = User.create!(sso_user)\n    # sso_user = { sso_sub: user_keycloak_sub, \n    #              email: params[:email], \n    #              first_name: params[:first_name], \n    #              last_name: params[:last_name] }\n    # as shown above the sso_sub returned from will need to be added to the DB user record\n    # the sso sub is a uniqe identifier generated by keycloak auth server\n    # it can be used to link multiple apps together\n    if user\n      render json: user\n    else \n      render json: user.errors\n    end\n  end\n  \n  \nend\n```\n\n#### KeycloakRails::Controller::Passwords\n***\n#### KeycloakRails::Controller::Unlocks\n***\n#### KeycloakRails::Controller::Omniauth\n***\n\n### without controller helpers\n#### KeycloakRails::User\n\n#### KeycloakRails::Client\n\n## Contributing\nrefer to [CONTRIBUTING.md](https://github.com/Laborocity/keycloak_rails/blob/main/CONTRIBUTING.md) .\n\n## License\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomarluq%2Fkeycloak_rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomarluq%2Fkeycloak_rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomarluq%2Fkeycloak_rails/lists"}