Compare commits

..

No commits in common. "5e20cec59d702c3809c7b8fcd99e719db451d39c" and "bc03597dd4551181fdd18f41a326dcabfa2aa2d4" have entirely different histories.

6 changed files with 8 additions and 44 deletions

View File

@ -82,7 +82,7 @@ func completeAuth(w http.ResponseWriter, username string, email string, firstnam
Expires: time.Now().Add(30 * 24 * time.Hour), Expires: time.Now().Add(30 * 24 * time.Hour),
HttpOnly: true, HttpOnly: true,
SameSite: http.SameSiteStrictMode, SameSite: http.SameSiteStrictMode,
Secure: true, //Secure: true,
}) })
return return

View File

@ -51,7 +51,7 @@ func checkAuthKrb5(w http.ResponseWriter, _ httprouter.Params, body []byte) (int
} }
} }
if !userExists(lf.Login) && !found { if !found {
return nil, fmt.Errorf("You are not allowed to log you in this way. Please use OpenID Connect.") return nil, fmt.Errorf("You are not allowed to log you in this way. Please use OpenID Connect.")
} }

View File

@ -20,7 +20,6 @@ var (
oidcRedirectURL = "https://srs.nemunai.re" oidcRedirectURL = "https://srs.nemunai.re"
oauth2Config oauth2.Config oauth2Config oauth2.Config
oidcVerifier *oidc.IDTokenVerifier oidcVerifier *oidc.IDTokenVerifier
nextSessionMap = map[string]string{}
) )
func init() { func init() {
@ -61,12 +60,6 @@ func initializeOIDC() {
func redirectOIDC_CRI(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { func redirectOIDC_CRI(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
session, err := NewSession() session, err := NewSession()
// Save next parameter
if len(r.URL.Query().Get("next")) > 0 {
nextSessionMap[fmt.Sprintf("%x", session.Id)] = r.URL.Query().Get("next")
}
if err != nil { if err != nil {
http.Error(w, fmt.Sprintf("{'errmsg':%q}", err.Error()), http.StatusInternalServerError) http.Error(w, fmt.Sprintf("{'errmsg':%q}", err.Error()), http.StatusInternalServerError)
} else { } else {
@ -128,12 +121,5 @@ func OIDC_CRI_complete(w http.ResponseWriter, r *http.Request, ps httprouter.Par
return return
} }
// Retrieve next URL associated with session http.Redirect(w, r, "/", http.StatusFound)
if next, ok := nextSessionMap[fmt.Sprintf("%x", session.Id)]; ok {
http.Redirect(w, r, next, http.StatusFound)
delete(nextSessionMap, fmt.Sprintf("%x", session.Id))
} else {
http.Redirect(w, r, "/", http.StatusFound)
}
} }

View File

@ -1,19 +0,0 @@
<script>
import { page } from '$app/stores';
let className = '';
export { className as class };
let auth_route = 'auth/CRI'
$: {
if ($page.url.searchParams.get('next')) {
auth_route = 'auth/CRI?next=' + encodeURIComponent($page.url.searchParams.get('next'));
} else {
auth_route = 'auth/CRI?';
}
}
</script>
<a href={auth_route} target="_self" class="{className}">
<slot></slot>
</a>

View File

@ -42,7 +42,6 @@
</script> </script>
<script> <script>
import AuthButton from '../components/AuthButton.svelte';
import Toaster from '../components/Toaster.svelte'; import Toaster from '../components/Toaster.svelte';
export let rroute = ''; export let rroute = '';
@ -130,9 +129,9 @@
</li> </li>
{:else} {:else}
<li class="nav-item"> <li class="nav-item">
<AuthButton class="btn btn-dark"> <a href="auth/CRI" target="_self" class="btn btn-dark">
Se connecter Se connecter
</AuthButton> </a>
</li> </li>
{/if} {/if}
</ul> </ul>

View File

@ -14,8 +14,6 @@
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { page } from '$app/stores' import { page } from '$app/stores'
import AuthButton from '../components/AuthButton.svelte';
let auth = { username: "", password: "" }; let auth = { username: "", password: "" };
let pleaseWait = false; let pleaseWait = false;
@ -72,9 +70,9 @@
<div class="col"> <div class="col">
<h2>OpenId Connect</h2> <h2>OpenId Connect</h2>
<div class="text-center"> <div class="text-center">
<AuthButton class="btn btn-primary"> <a href="auth/CRI" class="btn btn-primary" target="_self">
Me connecter avec mon compte CRI Me connecter avec mon compte CRI
</AuthButton> </a>
</div> </div>
</div> </div>
</div> </div>