Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Helios Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Helios Server
Commits
2b57d3c9
Commit
2b57d3c9
authored
9 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
first pass at login with clever
parent
c847f38c
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
helios_auth/auth_systems/__init__.py
+2
-1
2 additions, 1 deletion
helios_auth/auth_systems/__init__.py
helios_auth/auth_systems/clever.py
+80
-0
80 additions, 0 deletions
helios_auth/auth_systems/clever.py
settings.py
+4
-0
4 additions, 0 deletions
settings.py
with
88 additions
and
2 deletions
.gitignore
+
2
−
1
View file @
2b57d3c9
...
@@ -5,3 +5,4 @@ deploy-latest.sh
...
@@ -5,3 +5,4 @@ deploy-latest.sh
media/*
media/*
venv
venv
celerybeat-*
celerybeat-*
env.sh
\ No newline at end of file
This diff is collapsed.
Click to expand it.
helios_auth/auth_systems/__init__.py
+
2
−
1
View file @
2b57d3c9
AUTH_SYSTEMS
=
{}
AUTH_SYSTEMS
=
{}
import
twitter
,
password
,
cas
,
facebook
,
google
,
yahoo
,
linkedin
import
twitter
,
password
,
cas
,
facebook
,
google
,
yahoo
,
linkedin
,
clever
AUTH_SYSTEMS
[
'
twitter
'
]
=
twitter
AUTH_SYSTEMS
[
'
twitter
'
]
=
twitter
AUTH_SYSTEMS
[
'
linkedin
'
]
=
linkedin
AUTH_SYSTEMS
[
'
linkedin
'
]
=
linkedin
AUTH_SYSTEMS
[
'
password
'
]
=
password
AUTH_SYSTEMS
[
'
password
'
]
=
password
...
@@ -9,6 +9,7 @@ AUTH_SYSTEMS['cas'] = cas
...
@@ -9,6 +9,7 @@ AUTH_SYSTEMS['cas'] = cas
AUTH_SYSTEMS
[
'
facebook
'
]
=
facebook
AUTH_SYSTEMS
[
'
facebook
'
]
=
facebook
AUTH_SYSTEMS
[
'
google
'
]
=
google
AUTH_SYSTEMS
[
'
google
'
]
=
google
AUTH_SYSTEMS
[
'
yahoo
'
]
=
yahoo
AUTH_SYSTEMS
[
'
yahoo
'
]
=
yahoo
AUTH_SYSTEMS
[
'
clever
'
]
=
clever
# not ready
# not ready
#import live
#import live
...
...
This diff is collapsed.
Click to expand it.
helios_auth/auth_systems/clever.py
0 → 100644
+
80
−
0
View file @
2b57d3c9
"""
Clever Authentication
"""
from
django.http
import
*
from
django.core.mail
import
send_mail
from
django.conf
import
settings
import
httplib2
,
json
import
sys
,
os
,
cgi
,
urllib
,
urllib2
,
re
from
oauth2client.client
import
OAuth2WebServerFlow
# some parameters to indicate that status updating is not possible
STATUS_UPDATES
=
False
# display tweaks
LOGIN_MESSAGE
=
"
Log in with Clever
"
def
get_flow
(
redirect_url
=
None
):
return
OAuth2WebServerFlow
(
client_id
=
settings
.
CLEVER_CLIENT_ID
,
client_secret
=
settings
.
CLEVER_CLIENT_SECRET
,
scope
=
'
read:students read:teachers read:user_id read:sis
'
,
auth_uri
=
"
https://clever.com/oauth/authorize
"
,
token_uri
=
"
https://clever.com/oauth/tokens
"
,
redirect_uri
=
redirect_url
)
def
get_auth_url
(
request
,
redirect_url
):
flow
=
get_flow
(
redirect_url
)
request
.
session
[
'
clever-redirect-url
'
]
=
redirect_url
return
flow
.
step1_get_authorize_url
()
def
get_user_info_after_auth
(
request
):
flow
=
get_flow
(
request
.
session
[
'
clever-redirect-url
'
])
del
request
.
session
[
'
clever-redirect-url
'
]
code
=
request
.
GET
[
'
code
'
]
credentials
=
flow
.
step2_exchange
(
code
)
# at this stage, just an access token
# get the nice name
http
=
httplib2
.
Http
(
"
.cache
"
)
http
=
credentials
.
authorize
(
http
)
(
resp_headers
,
content
)
=
http
.
request
(
"
https://api.clever.com/me
"
,
"
GET
"
)
response
=
json
.
loads
(
content
)
# watch out, response also contains email addresses, but not sure whether thsoe are verified or not
# so for email address we will only look at the id_token
return
{
'
type
'
:
'
clever
'
,
'
user_id
'
:
response
[
"
data
"
][
"
id
"
],
'
name
'
:
""
,
'
info
'
:
{
"
district
"
:
response
[
"
data
"
][
"
district
"
],
"
type
"
:
response
[
"
data
"
][
"
type
"
]},
'
token
'
:{}}
def
do_logout
(
user
):
"""
logout of Google
"""
return
None
def
update_status
(
token
,
message
):
"""
simple update
"""
pass
def
send_message
(
user_id
,
name
,
user_info
,
subject
,
body
):
"""
send email to google users. user_id is the email for google.
"""
pass
def
check_constraint
(
constraint
,
user_info
):
"""
for eligibility
"""
pass
This diff is collapsed.
Click to expand it.
settings.py
+
4
−
0
View file @
2b57d3c9
...
@@ -234,6 +234,10 @@ CAS_PASSWORD = get_from_env('CAS_PASSWORD', "")
...
@@ -234,6 +234,10 @@ CAS_PASSWORD = get_from_env('CAS_PASSWORD', "")
CAS_ELIGIBILITY_URL
=
get_from_env
(
'
CAS_ELIGIBILITY_URL
'
,
""
)
CAS_ELIGIBILITY_URL
=
get_from_env
(
'
CAS_ELIGIBILITY_URL
'
,
""
)
CAS_ELIGIBILITY_REALM
=
get_from_env
(
'
CAS_ELIGIBILITY_REALM
'
,
""
)
CAS_ELIGIBILITY_REALM
=
get_from_env
(
'
CAS_ELIGIBILITY_REALM
'
,
""
)
# Clever
CLEVER_CLIENT_ID
=
get_from_env
(
'
CLEVER_CLIENT_ID
'
,
""
)
CLEVER_CLIENT_SECRET
=
get_from_env
(
'
CLEVER_CLIENT_SECRET
'
,
""
)
# email server
# email server
EMAIL_HOST
=
get_from_env
(
'
EMAIL_HOST
'
,
'
localhost
'
)
EMAIL_HOST
=
get_from_env
(
'
EMAIL_HOST
'
,
'
localhost
'
)
EMAIL_PORT
=
int
(
get_from_env
(
'
EMAIL_PORT
'
,
"
2525
"
))
EMAIL_PORT
=
int
(
get_from_env
(
'
EMAIL_PORT
'
,
"
2525
"
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment