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

Implement authenticated access for Public Clients (Implicit Code Grant) #4183

Closed
sebgie opened this issue Sep 26, 2014 · 4 comments
Closed
Labels
affects:api Affects the Ghost API

Comments

@sebgie
Copy link
Contributor

sebgie commented Sep 26, 2014

This belongs to the OAuth Epic: #4004 - please read this for the big picture of what this issue is for :)


In order to allow public clients to make authenticated requests to the Ghost API we need to implement the Implicit Code Grant (RFC 6749 4.2) flow:

  • User initiates the authentication process from a JavaScript client running in a browser.
  • JavaScript client redirects the user to the Ghost authentication endpoint using the following request.
    • response_type: 'token'
    • client_id: client_id generated by Ghost
    • state: random value to prevent csrf
    • redirect_uri: redirect uri must exactly match one of the values listed for this client
    • scope: tbd
GET /ghost/authorize?response_type=token&client_id=<client_id>&state=<random-value>
        &redirect_uri=<redirect_uri>
  • Ghost verifies the validity of client_id and redirect_uri
  • User authenticates with username and password
  • Ghost redirects the user back to the client

Success redirect:

HTTP/1.1 302 Found
     Location: <redirect_uri>#access_token=<new-access-token>
               &state=<state-from-request>&token_type=<token-type>&expires_in=<ttl>

Error redirect:

HTTP/1.1 302 Found
   Location: <redirect_uri>#error=access_denied&state=<state-from-request>
  • The client needs to validate the access_token and ensure that the state parameter matches the one sent to the server.
  • The client can now access the Ghost API using the access token.

An example on how to implement the implicit code grant flow can be found at https://github.com/jaredhanson/oauth2orize.

@sebgie sebgie added affects:api Affects the Ghost API OAuth labels Sep 26, 2014
@sebgie sebgie added this to the Future Backlog milestone Sep 26, 2014
@novaugust
Copy link
Contributor

Is the error meant to still be a 302?

@javorszky
Copy link
Contributor

As opposed to a 303?

@sebgie
Copy link
Contributor Author

sebgie commented Sep 26, 2014

Is the error meant to still be a 302?

Yes, according to the RFC (http://tools.ietf.org/html/rfc6749#section-4.2.2) status code 302 is correct. The status code is used to redirect the browser rather than informing the user about a problem in this case.

As opposed to a 303?

303 See Other would mean that the result can be looked up under a different URI. The result is already sent with the response, the browser has to redirect back to the requesting JavaScript client which should then interpret the response.

@ErisDS ErisDS modified the milestone: Future Backlog Oct 9, 2015
@ErisDS ErisDS added the later [triage] Things we intend to work but are not immediate priority label Sep 20, 2016
@ErisDS
Copy link
Member

ErisDS commented Sep 20, 2016

I'm closing all OAuth and most API issues temporarily with the later label.

RE: OAuth, for the next 2-3 months we'll be implementing an official Ghost OAuth login system, providing global access to all Ghost blogs with a single login. We'll be opening issues around this system soon, and I don't want to cause confusion with OAuth for the API.

JSON API Overhaul & OAuth access are currently scheduled next on the roadmap

@ErisDS ErisDS closed this as completed Sep 20, 2016
@ErisDS ErisDS removed later [triage] Things we intend to work but are not immediate priority labels Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects:api Affects the Ghost API
Projects
None yet
Development

No branches or pull requests

4 participants