Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#17] [API] As a User, I can sign up and sign in/out with a username and password #35

Merged
merged 129 commits into from
Jun 23, 2021

Conversation

malparty
Copy link
Owner

@malparty malparty commented Jun 11, 2021

#17 [API] As a User, I can sign up and sign in/out with a username and password

What happened

Adding OAuth2 API to sign_in, sign_out and sign_up

Insight

Routes (all POST)

  • Sign Up: /api/v1/users => Api::V1::UsersController/create
  • Sign In: /api/v1/oauth/token => Doorkeeper::TokensController/create
  • Sign Out: /api/v1/oauth/revoke => Doorkeeper::TokensController/revoke
  • Manage applications (Doorkeeper UI): /oauth/applications/ => Doorkeeper::ApplicationsController/index

Proof Of Work

All 3 examples are available in the postman documentation (link available in the GitHub Wiki too)

Following @junan feedback, we now have Doorkeeper UI to manage apps:

Note that only the user id == 1 is authorized. I did not want to add complexity with role managements, it would be to far from the initial need.

image

@malparty malparty added $user-login Authentication: Sign up, sign in and sign out @0.2.0 First usable release. Feature API priority: normal labels Jun 11, 2021
@malparty malparty added this to the 0.2.0 milestone Jun 11, 2021
@malparty malparty self-assigned this Jun 11, 2021
@malparty malparty changed the title WIP - [#17] [API] As a User, I can sign up and sign in/out with a username and password [#17] [API] As a User, I can sign up and sign in/out with a username and password Jun 14, 2021
db/seeds.rb Show resolved Hide resolved
@ankitkalia1195
Copy link
Collaborator

@malparty Last few minor comments, very close to approving it. :)

include ErrorHandlerConcern

# Overridden from doorkeeper as the doorkeeper revoke action does not return response according to json-api spec
def revoke
Copy link

@github-actions github-actions bot Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Remove unused methods (api::v1::tokenscontroller#revoke)

# The authorization server responds with HTTP status code 200 if the client
# submitted an invalid token or the token has been revoked successfully.
if token.blank?
render json: token_revoke_response, status: :ok
Copy link

@github-actions github-actions bot Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Calls 'render json: token_revoke_response, status: :ok' 2 times

# of the error by the authorization server as described below.
elsif authorized?
revoke_token
render json: token_revoke_response, status: :ok
Copy link

@github-actions github-actions bot Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Calls 'render json: token_revoke_response, status: :ok' 2 times

}
end

def token_revoke_response
Copy link

@github-actions github-actions bot Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Doesn't depend on instance state (maybe move it to another class?)

Copy link
Contributor

@junan junan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@malparty
Copy link
Owner Author

LGTM 🎉

@junan, "Looks Good To Me" or "Let's Go To Merge"? 😄

@malparty malparty merged commit 3fc9b39 into develop Jun 23, 2021
@malparty malparty deleted the feature/user-login-api branch June 23, 2021 08:54
@malparty malparty modified the milestones: 0.2.0, 0.3.0 Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Feature priority: normal $user-login Authentication: Sign up, sign in and sign out @0.2.0 First usable release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants