{"id":31572207,"url":"https://github.com/pgraemer/mojolicious-plugin-httpbasicauth","last_synced_at":"2025-10-05T13:50:07.446Z","repository":{"id":11930374,"uuid":"14499067","full_name":"pgraemer/Mojolicious-Plugin-HttpBasicAuth","owner":"pgraemer","description":"Http-Basic-Authentication implementation for Mojolicious","archived":false,"fork":false,"pushed_at":"2016-05-31T05:25:54.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-05T13:50:02.529Z","etag":null,"topics":["basic-authentication","httpbasicauth","perl","realm"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgraemer.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-18T17:04:52.000Z","updated_at":"2019-01-16T17:50:30.000Z","dependencies_parsed_at":"2022-08-30T11:50:31.778Z","dependency_job_id":null,"html_url":"https://github.com/pgraemer/Mojolicious-Plugin-HttpBasicAuth","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/pgraemer/Mojolicious-Plugin-HttpBasicAuth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgraemer%2FMojolicious-Plugin-HttpBasicAuth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgraemer%2FMojolicious-Plugin-HttpBasicAuth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgraemer%2FMojolicious-Plugin-HttpBasicAuth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgraemer%2FMojolicious-Plugin-HttpBasicAuth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgraemer","download_url":"https://codeload.github.com/pgraemer/Mojolicious-Plugin-HttpBasicAuth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgraemer%2FMojolicious-Plugin-HttpBasicAuth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278464272,"owners_count":25991177,"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-05T02:00:06.059Z","response_time":54,"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":["basic-authentication","httpbasicauth","perl","realm"],"created_at":"2025-10-05T13:50:01.905Z","updated_at":"2025-10-05T13:50:07.438Z","avatar_url":"https://github.com/pgraemer.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nMojolicious::Plugin::HttpBasicAuth - Http-Basic-Authentication implementation for Mojolicious\n\n# SYNOPSIS\n\n    # in your startup\n    $self-\u003eplugin(\n        'http_basic_auth', {\n            validate =\u003e sub {\n                my $c         = shift;\n                my $loginname = shift;\n                my $password  = shift;\n                my $realm     = shift;\n                return 1 if($realm eq 'Evergreen Terrace' \u0026\u0026 $loginname eq 'Homer' \u0026\u0026 $password eq 'Marge');\n                return 0;\n            },\n            realm =\u003e 'Evergreen Terrace'\n        }\n    );\n\n    # in your routes\n    sub index {\n        my $self = shift;\n        return unless $self-\u003ebasic_auth(\\%options);\n        $self-\u003erender();\n    }\n\n    # or bridged\n    my $foo = $r-\u003ebridge('/bridge')-\u003eto(cb =\u003e sub {\n        my $self = shift;\n        # Authenticated\n        return unless $self-\u003ebasic_auth({realm =\u003e 'Castle Bridge', validate =\u003e sub {return 1;}});\n    });\n    $foo-\u003eroute('/bar')-\u003eto(controller =\u003e 'foo', action =\u003e 'bar');\n\n# DESCRIPTION\n\n[Mojolicious::Plugin::HttpBasicAuth](https://metacpan.org/pod/Mojolicious::Plugin::HttpBasicAuth) is a implementation of the Http-Basic-Authentication\n\n# OPTIONS\n\n[Mojolicious::Plugin::HttpBasicAuth](https://metacpan.org/pod/Mojolicious::Plugin::HttpBasicAuth) supports the following options.\n\n## realm\n\n    $self-\u003eplugin('http_basic_auth', {realm =\u003e 'My Castle!'});\n\nHTTP-Realm, defaults to 'WWW'\n\n## validate\n\n    $self-\u003eplugin('http_basic_auth', {\n        validate =\u003e sub {\n              my $c          = shift;\n              my $loginname  = shift;\n              my $password   = shift;\n              my $realm      = shift;\n              return 1 if($realm eq 'Springfield' \u0026\u0026 $loginname eq 'Homer' \u0026\u0026 $password eq 'Marge');\n              return 0;\n        }\n    });\n\nValidation callback to verify user. This option is **mandatory**.\n\n## invalid\n\n    $self-\u003eplugin('http_basic_auth', {\n        invalid =\u003e sub {\n            my $controller = shift;\n            return (\n                json =\u003e { json     =\u003e { error =\u003e 'HTTP 401: Unauthorized' } },\n                html =\u003e { template =\u003e 'auth/basic' },\n                any  =\u003e { data     =\u003e 'HTTP 401: Unauthorized' }\n            );\n        }\n    });\n\nCallback for invalid requests, default can be seen here. Return values are dispatched to [\"respond\\_to\" in Mojolicious::Controller](https://metacpan.org/pod/Mojolicious::Controller#respond_to)\n\n# HELPERS\n\n[Mojolicious::Plugin::HttpBasicAuth](https://metacpan.org/pod/Mojolicious::Plugin::HttpBasicAuth) implements the following helpers.\n\n## basic\\_auth\n\n    return unless $self-\u003ebasic_auth({realm =\u003e 'Kitchen'});\n\nAll default options can be overwritten in every call.\n\n# METHODS\n\n[Mojolicious::Plugin::HttpBasicAuth](https://metacpan.org/pod/Mojolicious::Plugin::HttpBasicAuth) inherits all methods from\n[Mojolicious::Plugin](https://metacpan.org/pod/Mojolicious::Plugin) and implements the following new ones.\n\n## register\n\n    my $route = $plugin-\u003eregister(Mojolicious-\u003enew);\n    my $route = $plugin-\u003eregister(Mojolicious-\u003enew, {realm =\u003e 'Fort Knox', validate =\u003e sub {\n        return 0;\n    }});\n\nRegister renderer and helper in [Mojolicious](https://metacpan.org/pod/Mojolicious) application.\n\n# SEE ALSO\n\n[Mojolicious](https://metacpan.org/pod/Mojolicious), [Mojolicious::Guides](https://metacpan.org/pod/Mojolicious::Guides), [http://mojolicio.us](http://mojolicio.us).\n\n# AUTHOR\n\nPatrick Grämer \u003cpgraemer@cpan.org\u003e\n, [http://graemer.org](http://graemer.org).\n\n# CONTRIBUTOR\n\nMarkus Michel \u003cmmichel@cpan.org\u003e\n, [http://markusmichel.org](http://markusmichel.org).\n\n# COPYRIGHT\n\nCopyright 2015 Patrick Grämer\n\n# LICENSE\n\nThis library is free software; you can redistribute it and/or modify\nit under the same terms as Perl itself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgraemer%2Fmojolicious-plugin-httpbasicauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgraemer%2Fmojolicious-plugin-httpbasicauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgraemer%2Fmojolicious-plugin-httpbasicauth/lists"}