Net::O...rdGrant(3pm)

πŸ“¦
version 0.28 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… Net::O...rdGrant(3pm) β€” Net::OAuth2::AuthorizationServer::PasswordGrant

okay so this page is straight out of the User Contributed Perl Documentation, file name Net::O...rdGrant(3pm), and bestie… it's giving "we need to talk" energy from the very first line. buckle up πŸŽ€


✨ NAME ✨

Net::OAuth2::AuthorizationServer::PasswordGrant β€” the OAuth2 Resource Owner Password Credentials Grant πŸ’–

🚨 You "MUST NOT" use this grant type (see <https://tools.ietf.org/html/draft-ietf-oauth-security-topics-15>). That's not me being dramatic, that's literally what the doc says. no cap. πŸ’€

πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole vibe, copy it exactly bestie:

  my $Grant = Net::OAuth2::AuthorizationServer::PasswordGrant->new(
    clients => {
      TrendyNewService => {
        client_secret => 'TopSecretClientSecret',
        scopes        => {
          post_images   => 1,
          annoy_friends => 1,
        },
      },
    },
    users => {
      bob => 'j$s03R#!\fs',
      tom => 'dE0@@s^tWg1',
    },
  );

  # verify a client and username against known clients/users
  my ( $client_id,$error,$scopes,$username ) = $Grant->verify_user_password(
    client_id     => $client_id,
    client_secret => $client_secret,
    username      => $username,
    password      => $password,
    scopes        => [ qw/ list of scopes / ],
  );

  if ( ! $Grant->login_resource_owner ) {
    # resource owner needs to login
    ...
  }

  # have resource owner confirm (and perhaps modify) scopes
  my ( $confirmed,$error,$scopes_ref ) = $Grant->confirm_by_resource_owner(
    client_id       => $client_id,
    scopes          => [ qw/ list of scopes / ],
  );

  # generate a token
  my $token = $Grant->token(
    client_id       => $client_id,
    scopes          => $scopes_ref,
    type            => 'access', # one of: access, refresh
    redirect_uri    => $redirect_uri,
    user_id         => $user_id,      # optional
        jwt_claims_cb   => sub { ... },   # optional, see jwt_claims_cb in Manual
  );

  # store access token
  $Grant->store_access_token(
    client_id         => $client,
    access_token      => $access_token,
    refresh_token     => $refresh_token,
    scopes            => $scopes_ref,
    old_refresh_token => $old_refresh_token,
  );

  # verify an access token
  my ( $is_valid,$error ) = $Grant->verify_access_token(
    access_token     => $access_token,
    scopes           => $scopes_ref,
    is_refresh_token => 0,
  );

  # or:
  my ( $oauth_details,$error ) = $Grant->verify_token_and_scope(
    refresh_token    => $refresh_token,
    auth_header      => $http_authorization_header,
  );

🌸 DESCRIPTION 🌸

so this module implements the OAuth2 "Resource Owner Password Credentials Grant" flow, exactly as described over at <http://tools.ietf.org/html/rfc6749#section-4.3> ✨


πŸŽ€ CONSTRUCTOR ARGUMENTS πŸŽ€

along with all the ones detailed in "CONSTRUCTOR ARGUMENTS" in Net::OAuth2::AuthorizationServer::Manual, this grant type also supports the following, bestie:

🌈 users

a hashref of client details, keyed like this:

  $username => $password

that's it. username in, password out, iconic behavior fr fr πŸ’…


πŸ’– CALLBACK FUNCTIONS πŸ’–

this grant type supports these callbacks:

  login_resource_owner_cb
  confirm_by_resource_owner_cb
  verify_client_cb
  verify_user_password_cb
  store_access_token_cb
  verify_access_token_cb

and if you need the deets on what each one actually does, go read "CALLBACK FUNCTIONS" in Net::OAuth2::AuthorizationServer::Manual. i'm not gatekeeping, it's all there 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Lee Johnson - leejo@cpan.org β€” the main character who wrote this 🌟


⭐ LICENSE ⭐

this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself πŸ’œ and if you wanna contribute documentation or file a bug report, please raise an issue / pull request at:

    https://github.com/Humanstate/net-oauth2-authorizationserver

and that's the whole page bestie!! πŸ¦‹βœ¨ sperl v5.36.0, dated 2022-08-28, and this absolute legend of a manual page is Net::O...rdGrant(3pm). go forth, but remember β€” you MUST NOT actually use this grant type. mwah πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from