Class: SsoProvyder::AuthWebController

Inherits:
AuthController show all
Defined in:
app/controllers/sso_provyder/auth_web_controller.rb

Instance Method Summary collapse

Methods inherited from AuthController

#authenticate_app, #authenticate_application

Instance Method Details

#access_tokenObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/sso_provyder/auth_web_controller.rb', line 13

def access_token
  authenticate_app
  
  access_grant = SsoProvyder::AccessGrant.authenticate_with({:code => params[:code], :client_id => @application.id})
  if access_grant.nil?
    render :json => {:error => "Could not authenticate access code"}
    return
  end

  access_grant = access_grant.start_expiry_period!
  render :json => {:access_token => access_grant.access_token, :refresh_token => access_grant.refresh_token, :expires_in => (access_grant.access_token_expires_at - Time.now).to_i}
end

#authorizeObject



5
6
7
8
9
10
11
# File 'app/controllers/sso_provyder/auth_web_controller.rb', line 5

def authorize
  SsoProvyder::AccessGrant.prune!
  access_grant = current_user.access_grants.create({  :client => application,
                                                      :state => params[:state] },
                                                      :without_protection => true)
  redirect_to access_grant.redirect_uri_for(params[:redirect_uri])
end

#userObject

IDEA: we could provide a way to customize this in options + extend Authentifyd user model attributes



29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/sso_provyder/auth_web_controller.rb', line 29

def user
  hash = {
    :provider => 'sso',
    :id => current_user.id.to_s,
    :info => { :email      => current_user.email },
    :extra => {}
  }

  render :json => hash.to_json
end